Skip to content

Commit

Permalink
🔧
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon committed Oct 19, 2024
1 parent 7ac3630 commit 2bc93bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/webgpu/cpp/rnwgpu/api/GPUCanvasContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ void GPUCanvasContext::configure(
if (!conv(surfaceConfiguration.usage, configuration->usage) || !conv(surfaceConfiguration.format, configuration->format)) {
throw std::runtime_error("Error with SurfaceConfiguration");
}

#ifdef __APPLE__
surfaceConfiguration.alphaMode = configuration->alphaMode;
#endif
_surfaceInfo->configure(surfaceConfiguration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct GPUCanvasConfiguration {
std::optional<double> usage; // GPUTextureUsageFlags
std::optional<std::vector<wgpu::TextureFormat>>
viewFormats; // Iterable<GPUTextureFormat>
wgpu::CompositeAlphaMode alphaMode;
wgpu::CompositeAlphaMode alphaMode = wgpu::CompositeAlphaMode::Opaque;
};

} // namespace rnwgpu
Expand Down Expand Up @@ -61,7 +61,9 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUCanvasConfiguration>> {
}
if (value.hasProperty(runtime, "alphaMode")) {
auto prop = value.getProperty(runtime, "alphaMode").asString(runtime).utf8(runtime);
result->alphaMode = prop == "premultiplied" ? wgpu::CompositeAlphaMode::Premultiplied : wgpu::CompositeAlphaMode::Opaque;
if (prop == "premultiplied") {
result->alphaMode = wgpu::CompositeAlphaMode::Premultiplied;
}
}
}

Expand Down

0 comments on commit 2bc93bc

Please sign in to comment.