SkiaGLRepresentation - Use vectors of Surfaces and PromiseTextures
For multiplanar shared images, promise textures and surfaces are stored per plane in the shared image backing/representations instead of creating shared image per plane. This change adds the support for multiple textures/surfaces in SkiaGLImageRepresentation which will be used for multiplanar formats. NOTE - This is pure refactoring and no logical changes. Need to add support for getting the format/size per plane based on the format. That will be done in follow-up changes. Bug: 1366481 Change-Id: If9a5fcbf7b0272802218a3d872c130e39ce12671 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3998938 Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Reviewed-by: Kyle Charbonneau <kylechar@chromium.org> Commit-Queue: Saifuddin Hitawala <hitawala@chromium.org> Cr-Commit-Position: refs/heads/main@{#1071202}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b0338c8f54
commit
991df64841
gpu/command_buffer/service/shared_image
@@ -103,20 +103,22 @@ SkiaGLImageRepresentationDXGISwapChain::Create(
|
|||||||
auto promise_texture = SkPromiseImageTexture::Make(backend_texture);
|
auto promise_texture = SkPromiseImageTexture::Make(backend_texture);
|
||||||
if (!promise_texture)
|
if (!promise_texture)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures = {
|
||||||
|
promise_texture};
|
||||||
return base::WrapUnique(new SkiaGLImageRepresentationDXGISwapChain(
|
return base::WrapUnique(new SkiaGLImageRepresentationDXGISwapChain(
|
||||||
std::move(gl_representation), std::move(promise_texture),
|
std::move(gl_representation), std::move(promise_textures),
|
||||||
std::move(context_state), manager, backing, tracker));
|
std::move(context_state), manager, backing, tracker));
|
||||||
}
|
}
|
||||||
|
|
||||||
SkiaGLImageRepresentationDXGISwapChain::SkiaGLImageRepresentationDXGISwapChain(
|
SkiaGLImageRepresentationDXGISwapChain::SkiaGLImageRepresentationDXGISwapChain(
|
||||||
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
||||||
sk_sp<SkPromiseImageTexture> promise_texture,
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures,
|
||||||
scoped_refptr<SharedContextState> context_state,
|
scoped_refptr<SharedContextState> context_state,
|
||||||
SharedImageManager* manager,
|
SharedImageManager* manager,
|
||||||
SharedImageBacking* backing,
|
SharedImageBacking* backing,
|
||||||
MemoryTypeTracker* tracker)
|
MemoryTypeTracker* tracker)
|
||||||
: SkiaGLImageRepresentation(std::move(gl_representation),
|
: SkiaGLImageRepresentation(std::move(gl_representation),
|
||||||
std::move(promise_texture),
|
std::move(promise_textures),
|
||||||
std::move(context_state),
|
std::move(context_state),
|
||||||
manager,
|
manager,
|
||||||
backing,
|
backing,
|
||||||
|
@@ -75,7 +75,7 @@ class SkiaGLImageRepresentationDXGISwapChain
|
|||||||
private:
|
private:
|
||||||
SkiaGLImageRepresentationDXGISwapChain(
|
SkiaGLImageRepresentationDXGISwapChain(
|
||||||
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
||||||
sk_sp<SkPromiseImageTexture> promise_texture,
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures,
|
||||||
scoped_refptr<SharedContextState> context_state,
|
scoped_refptr<SharedContextState> context_state,
|
||||||
SharedImageManager* manager,
|
SharedImageManager* manager,
|
||||||
SharedImageBacking* backing,
|
SharedImageBacking* backing,
|
||||||
|
@@ -39,33 +39,37 @@ std::unique_ptr<SkiaGLImageRepresentation> SkiaGLImageRepresentation::Create(
|
|||||||
SharedImageManager* manager,
|
SharedImageManager* manager,
|
||||||
SharedImageBacking* backing,
|
SharedImageBacking* backing,
|
||||||
MemoryTypeTracker* tracker) {
|
MemoryTypeTracker* tracker) {
|
||||||
|
DCHECK(backing->format().is_single_plane());
|
||||||
GrBackendTexture backend_texture;
|
GrBackendTexture backend_texture;
|
||||||
|
// TODO(hitawala): Use format/size per plane for multiplanar formats.
|
||||||
if (!GetGrBackendTexture(
|
if (!GetGrBackendTexture(
|
||||||
context_state->feature_info(),
|
context_state->feature_info(),
|
||||||
gl_representation->GetTextureBase()->target(), backing->size(),
|
gl_representation->GetTextureBase()->target(), backing->size(),
|
||||||
gl_representation->GetTextureBase()->service_id(),
|
gl_representation->GetTextureBase()->service_id(),
|
||||||
(backing->format()).resource_format(),
|
backing->format().resource_format(),
|
||||||
context_state->gr_context()->threadSafeProxy(), &backend_texture)) {
|
context_state->gr_context()->threadSafeProxy(), &backend_texture)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto promise_texture = SkPromiseImageTexture::Make(backend_texture);
|
auto promise_texture = SkPromiseImageTexture::Make(backend_texture);
|
||||||
if (!promise_texture)
|
if (!promise_texture)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures = {
|
||||||
|
promise_texture};
|
||||||
return base::WrapUnique(new SkiaGLImageRepresentation(
|
return base::WrapUnique(new SkiaGLImageRepresentation(
|
||||||
std::move(gl_representation), std::move(promise_texture),
|
std::move(gl_representation), std::move(promise_textures),
|
||||||
std::move(context_state), manager, backing, tracker));
|
std::move(context_state), manager, backing, tracker));
|
||||||
}
|
}
|
||||||
|
|
||||||
SkiaGLImageRepresentation::SkiaGLImageRepresentation(
|
SkiaGLImageRepresentation::SkiaGLImageRepresentation(
|
||||||
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
||||||
sk_sp<SkPromiseImageTexture> promise_texture,
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures,
|
||||||
scoped_refptr<SharedContextState> context_state,
|
scoped_refptr<SharedContextState> context_state,
|
||||||
SharedImageManager* manager,
|
SharedImageManager* manager,
|
||||||
SharedImageBacking* backing,
|
SharedImageBacking* backing,
|
||||||
MemoryTypeTracker* tracker)
|
MemoryTypeTracker* tracker)
|
||||||
: SkiaImageRepresentation(manager, backing, tracker),
|
: SkiaImageRepresentation(manager, backing, tracker),
|
||||||
gl_representation_(std::move(gl_representation)),
|
gl_representation_(std::move(gl_representation)),
|
||||||
promise_texture_(std::move(promise_texture)),
|
promise_textures_(std::move(promise_textures)),
|
||||||
context_state_(std::move(context_state)) {
|
context_state_(std::move(context_state)) {
|
||||||
DCHECK(gl_representation_);
|
DCHECK(gl_representation_);
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
@@ -75,7 +79,7 @@ SkiaGLImageRepresentation::SkiaGLImageRepresentation(
|
|||||||
|
|
||||||
SkiaGLImageRepresentation::~SkiaGLImageRepresentation() {
|
SkiaGLImageRepresentation::~SkiaGLImageRepresentation() {
|
||||||
DCHECK_EQ(RepresentationAccessMode::kNone, mode_);
|
DCHECK_EQ(RepresentationAccessMode::kNone, mode_);
|
||||||
surface_.reset();
|
surfaces_.clear();
|
||||||
|
|
||||||
DCHECK_EQ(!has_context(), context_state_->context_lost());
|
DCHECK_EQ(!has_context(), context_state_->context_lost());
|
||||||
if (!has_context())
|
if (!has_context())
|
||||||
@@ -98,21 +102,24 @@ std::vector<sk_sp<SkSurface>> SkiaGLImageRepresentation::BeginWriteAccess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mode_ = RepresentationAccessMode::kWrite;
|
mode_ = RepresentationAccessMode::kWrite;
|
||||||
if (surface_) {
|
if (!surfaces_.empty())
|
||||||
return {surface_};
|
return surfaces_;
|
||||||
}
|
|
||||||
|
|
||||||
|
DCHECK(format().is_single_plane());
|
||||||
|
// TODO(hitawala): Get SkColorType based on plane_idx for multiplanar
|
||||||
|
// formats.
|
||||||
SkColorType sk_color_type = viz::ResourceFormatToClosestSkColorType(
|
SkColorType sk_color_type = viz::ResourceFormatToClosestSkColorType(
|
||||||
/*gpu_compositing=*/true, format());
|
/*gpu_compositing=*/true, format());
|
||||||
auto surface = SkSurface::MakeFromBackendTexture(
|
auto surface = SkSurface::MakeFromBackendTexture(
|
||||||
context_state_->gr_context(), promise_texture_->backendTexture(),
|
context_state_->gr_context(), promise_textures_[0]->backendTexture(),
|
||||||
surface_origin(), final_msaa_count, sk_color_type,
|
surface_origin(), final_msaa_count, sk_color_type,
|
||||||
backing()->color_space().ToSkColorSpace(), &surface_props);
|
backing()->color_space().ToSkColorSpace(), &surface_props);
|
||||||
surface_ = surface;
|
|
||||||
|
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return {};
|
return {};
|
||||||
return {surface};
|
|
||||||
|
std::vector<sk_sp<SkSurface>> surfaces = {surface};
|
||||||
|
surfaces_ = surfaces;
|
||||||
|
return surfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<sk_sp<SkPromiseImageTexture>>
|
std::vector<sk_sp<SkPromiseImageTexture>>
|
||||||
@@ -128,16 +135,13 @@ SkiaGLImageRepresentation::BeginWriteAccess(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
mode_ = RepresentationAccessMode::kWrite;
|
mode_ = RepresentationAccessMode::kWrite;
|
||||||
|
return promise_textures_;
|
||||||
if (!promise_texture_)
|
|
||||||
return {};
|
|
||||||
return {promise_texture_};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkiaGLImageRepresentation::EndWriteAccess() {
|
void SkiaGLImageRepresentation::EndWriteAccess() {
|
||||||
DCHECK_EQ(mode_, RepresentationAccessMode::kWrite);
|
DCHECK_EQ(mode_, RepresentationAccessMode::kWrite);
|
||||||
if (surface_)
|
for (auto& surface : surfaces_)
|
||||||
DCHECK(surface_->unique());
|
DCHECK(surface->unique());
|
||||||
|
|
||||||
gl_representation_->EndAccess();
|
gl_representation_->EndAccess();
|
||||||
mode_ = RepresentationAccessMode::kNone;
|
mode_ = RepresentationAccessMode::kNone;
|
||||||
@@ -156,10 +160,7 @@ SkiaGLImageRepresentation::BeginReadAccess(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
mode_ = RepresentationAccessMode::kRead;
|
mode_ = RepresentationAccessMode::kRead;
|
||||||
|
return promise_textures_;
|
||||||
if (!promise_texture_)
|
|
||||||
return {};
|
|
||||||
return {promise_texture_};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkiaGLImageRepresentation::EndReadAccess() {
|
void SkiaGLImageRepresentation::EndReadAccess() {
|
||||||
|
@@ -51,7 +51,7 @@ class GPU_GLES2_EXPORT SkiaGLImageRepresentation
|
|||||||
protected:
|
protected:
|
||||||
SkiaGLImageRepresentation(
|
SkiaGLImageRepresentation(
|
||||||
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
|
||||||
sk_sp<SkPromiseImageTexture> promise_texture,
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures,
|
||||||
scoped_refptr<SharedContextState> context_state,
|
scoped_refptr<SharedContextState> context_state,
|
||||||
SharedImageManager* manager,
|
SharedImageManager* manager,
|
||||||
SharedImageBacking* backing,
|
SharedImageBacking* backing,
|
||||||
@@ -61,9 +61,9 @@ class GPU_GLES2_EXPORT SkiaGLImageRepresentation
|
|||||||
void CheckContext();
|
void CheckContext();
|
||||||
|
|
||||||
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation_;
|
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation_;
|
||||||
sk_sp<SkPromiseImageTexture> promise_texture_;
|
std::vector<sk_sp<SkPromiseImageTexture>> promise_textures_;
|
||||||
scoped_refptr<SharedContextState> context_state_;
|
scoped_refptr<SharedContextState> context_state_;
|
||||||
sk_sp<SkSurface> surface_;
|
std::vector<sk_sp<SkSurface>> surfaces_;
|
||||||
RepresentationAccessMode mode_ = RepresentationAccessMode::kNone;
|
RepresentationAccessMode mode_ = RepresentationAccessMode::kNone;
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
raw_ptr<gl::GLContext> context_;
|
raw_ptr<gl::GLContext> context_;
|
||||||
|
Reference in New Issue
Block a user