diff options
Diffstat (limited to 'chromium/gpu/command_buffer/service/shared_image_representation_skia_gl.cc')
-rw-r--r-- | chromium/gpu/command_buffer/service/shared_image_representation_skia_gl.cc | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/chromium/gpu/command_buffer/service/shared_image_representation_skia_gl.cc b/chromium/gpu/command_buffer/service/shared_image_representation_skia_gl.cc index 83613f6bfbf..4577518adc6 100644 --- a/chromium/gpu/command_buffer/service/shared_image_representation_skia_gl.cc +++ b/chromium/gpu/command_buffer/service/shared_image_representation_skia_gl.cc @@ -53,6 +53,31 @@ SharedImageRepresentationSkiaGL::Create( std::move(context_state), manager, backing, tracker)); } +std::unique_ptr<SharedImageRepresentationSkiaGL> +SharedImageRepresentationSkiaGL::CreateForPassthrough( + std::unique_ptr<SharedImageRepresentationGLTexturePassthrough> + passthrough_representation, + scoped_refptr<SharedContextState> context_state, + SharedImageManager* manager, + SharedImageBacking* backing, + MemoryTypeTracker* tracker) { + GrBackendTexture backend_texture; + if (!GetGrBackendTexture( + context_state->feature_info(), + passthrough_representation->GetTexturePassthrough()->target(), + backing->size(), + passthrough_representation->GetTexturePassthrough()->service_id(), + backing->format(), &backend_texture)) { + return nullptr; + } + auto promise_texture = SkPromiseImageTexture::Make(backend_texture); + if (!promise_texture) + return nullptr; + return base::WrapUnique(new SharedImageRepresentationSkiaGL( + std::move(passthrough_representation), std::move(promise_texture), + std::move(context_state), manager, backing, tracker)); +} + SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL( std::unique_ptr<SharedImageRepresentationGLTexture> gl_representation, sk_sp<SkPromiseImageTexture> promise_texture, @@ -64,6 +89,25 @@ SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL( gl_representation_(std::move(gl_representation)), promise_texture_(std::move(promise_texture)), context_state_(std::move(context_state)) { + DCHECK(gl_representation_); +#if DCHECK_IS_ON() + context_ = gl::GLContext::GetCurrent(); +#endif +} + +SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL( + std::unique_ptr<SharedImageRepresentationGLTexturePassthrough> + passthrough_representation, + sk_sp<SkPromiseImageTexture> promise_texture, + scoped_refptr<SharedContextState> context_state, + SharedImageManager* manager, + SharedImageBacking* backing, + MemoryTypeTracker* tracker) + : SharedImageRepresentationSkia(manager, backing, tracker), + passthrough_representation_(std::move(passthrough_representation)), + promise_texture_(std::move(promise_texture)), + context_state_(std::move(context_state)) { + DCHECK(passthrough_representation_); #if DCHECK_IS_ON() context_ = gl::GLContext::GetCurrent(); #endif @@ -83,9 +127,14 @@ sk_sp<SkSurface> SharedImageRepresentationSkiaGL::BeginWriteAccess( DCHECK(!surface_); CheckContext(); - if (!gl_representation_->BeginAccess( + if (gl_representation_ && + !gl_representation_->BeginAccess( GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM)) { return nullptr; + } else if (passthrough_representation_ && + !passthrough_representation_->BeginAccess( + GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM)) { + return nullptr; } SkColorType sk_color_type = viz::ResourceFormatToClosestSkColorType( @@ -105,7 +154,11 @@ void SharedImageRepresentationSkiaGL::EndWriteAccess(sk_sp<SkSurface> surface) { DCHECK_EQ(surface.get(), surface_); DCHECK(surface->unique()); - gl_representation_->EndAccess(); + if (gl_representation_) { + gl_representation_->EndAccess(); + } else { + passthrough_representation_->EndAccess(); + } mode_ = RepresentationAccessMode::kNone; surface_ = nullptr; } @@ -116,9 +169,14 @@ sk_sp<SkPromiseImageTexture> SharedImageRepresentationSkiaGL::BeginReadAccess( DCHECK_EQ(mode_, RepresentationAccessMode::kNone); CheckContext(); - if (!gl_representation_->BeginAccess( - GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM)) + if (gl_representation_ && !gl_representation_->BeginAccess( + GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM)) { + return nullptr; + } else if (passthrough_representation_ && + !passthrough_representation_->BeginAccess( + GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM)) { return nullptr; + } mode_ = RepresentationAccessMode::kRead; return promise_texture_; } @@ -127,7 +185,11 @@ void SharedImageRepresentationSkiaGL::EndReadAccess() { DCHECK_EQ(mode_, RepresentationAccessMode::kRead); CheckContext(); - gl_representation_->EndAccess(); + if (gl_representation_) { + gl_representation_->EndAccess(); + } else { + passthrough_representation_->EndAccess(); + } mode_ = RepresentationAccessMode::kNone; surface_ = nullptr; } @@ -138,4 +200,4 @@ void SharedImageRepresentationSkiaGL::CheckContext() { #endif } -} // namespace gpu +} // namespace gpu
\ No newline at end of file |