Commit c04ea9dd authored by Sean Gilhuly's avatar Sean Gilhuly Committed by Commit Bot

Update SkiaRenderer Dawn to swapchain change

The Dawn swapchains now return TextureViews instead of Textures. Update
to match the latest API.

Following the swapchain change, this Skia patch is also needed to build
SkiaRenderer Dawn:
https://skia-review.googlesource.com/c/skia/+/254810

Bug: 1021566
Change-Id: I5ff967e5ddfc1fd66e59c4724c6e8f74bd6ff0ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1941188Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720026}
parent 46326599
......@@ -405,7 +405,7 @@ viz_source_set("gpu_service_dependencies") {
deps += [
"//third_party/dawn:libdawn_native",
"//third_party/dawn:libdawn_native_sources",
"//third_party/dawn/src/dawn:dawncpp",
"//third_party/dawn/src/dawn:libdawn",
]
}
}
......
......@@ -49,7 +49,6 @@ bool SkiaOutputDeviceDawn::Reshape(const gfx::Size& size,
gfx::OverlayTransform transform) {
DCHECK_EQ(transform, gfx::OVERLAY_TRANSFORM_NONE);
DiscardBackbuffer();
size_ = size;
sk_color_space_ = color_space.ToSkColorSpace();
......@@ -61,8 +60,6 @@ bool SkiaOutputDeviceDawn::Reshape(const gfx::Size& size,
return false;
swap_chain_.Configure(kSwapChainFormat, kUsage, size_.width(),
size_.height());
EnsureBackbuffer();
return true;
}
......@@ -70,26 +67,25 @@ void SkiaOutputDeviceDawn::SwapBuffers(
BufferPresentedCallback feedback,
std::vector<ui::LatencyInfo> latency_info) {
StartSwapBuffers(std::move(feedback));
swap_chain_.Present(texture_);
texture_ = swap_chain_.GetNextTexture();
swap_chain_.Present();
FinishSwapBuffers(gfx::SwapResult::SWAP_ACK,
gfx::Size(size_.width(), size_.height()),
std::move(latency_info));
}
SkSurface* SkiaOutputDeviceDawn::BeginPaint() {
GrDawnImageInfo info;
info.fTexture = texture_;
GrDawnRenderTargetInfo info;
info.fTextureView = swap_chain_.GetCurrentTextureView();
info.fFormat = kSwapChainFormat;
info.fLevelCount = 1;
GrBackendTexture backend_texture(size_.width(), size_.height(), info);
DCHECK(backend_texture.isValid());
sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget(
context_provider_->GetGrContext(), backend_texture,
GrBackendRenderTarget backend_target(
size_.width(), size_.height(), /*sampleCnt=*/0, /*stencilBits=*/0, info);
DCHECK(backend_target.isValid());
sk_surface_ = SkSurface::MakeFromBackendRenderTarget(
context_provider_->GetGrContext(), backend_target,
!capabilities_.flipped_output_surface ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin,
/*sampleCount=*/0, kSurfaceColorType, sk_color_space_,
/*surfaceProps=*/nullptr);
kSurfaceColorType, sk_color_space_, /*surfaceProps=*/nullptr);
return sk_surface_.get();
}
......@@ -99,15 +95,6 @@ void SkiaOutputDeviceDawn::EndPaint(const GrBackendSemaphore& semaphore) {
sk_surface_.reset();
}
void SkiaOutputDeviceDawn::EnsureBackbuffer() {
if (swap_chain_)
texture_ = swap_chain_.GetNextTexture();
}
void SkiaOutputDeviceDawn::DiscardBackbuffer() {
texture_ = nullptr;
}
void SkiaOutputDeviceDawn::CreateSwapChainImplementation() {
#if defined(OS_WIN)
swap_chain_implementation_ = dawn_native::d3d12::CreateNativeSwapChainImpl(
......
......@@ -37,8 +37,6 @@ class SkiaOutputDeviceDawn : public SkiaOutputDevice {
std::vector<ui::LatencyInfo> latency_info) override;
SkSurface* BeginPaint() override;
void EndPaint(const GrBackendSemaphore& semaphore) override;
void EnsureBackbuffer() override;
void DiscardBackbuffer() override;
private:
// Create a platform-specific swapchain implementation.
......
......@@ -204,9 +204,9 @@ class WrappedSkImage : public SharedImageBacking {
}
#if BUILDFLAG(SKIA_USE_DAWN)
case GrBackendApi::kDawn: {
GrDawnImageInfo image_info;
if (backend_texture.getDawnImageInfo(&image_info))
tracing_id_ = reinterpret_cast<uint64_t>(image_info.fTexture.Get());
GrDawnTextureInfo tex_info;
if (backend_texture.getDawnTextureInfo(&tex_info))
tracing_id_ = reinterpret_cast<uint64_t>(tex_info.fTexture.Get());
break;
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment