Commit 421f75da authored by Mike Reed's avatar Mike Reed Committed by Commit Bot

Specify colorspace directly on surface, don't use xformcanvas

Bug: skia:8773
Change-Id: Ib8695ce0ed7a1018781c2b9161a1d29c3a1d0b1e
Reviewed-on: https://chromium-review.googlesource.com/c/1476535Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Cr-Commit-Position: refs/heads/master@{#635230}
parent 95d45bae
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
#include "gpu/command_buffer/service/skia_utils.h" #include "gpu/command_buffer/service/skia_utils.h"
#include "gpu/command_buffer/service/wrapped_sk_image.h" #include "gpu/command_buffer/service/wrapped_sk_image.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h" #include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSurfaceProps.h" #include "third_party/skia/include/core/SkSurfaceProps.h"
...@@ -577,7 +576,7 @@ class RasterDecoderImpl final : public RasterDecoder, ...@@ -577,7 +576,7 @@ class RasterDecoderImpl final : public RasterDecoder,
std::unique_ptr<cc::ServicePaintCache> paint_cache_; std::unique_ptr<cc::ServicePaintCache> paint_cache_;
std::unique_ptr<SkDeferredDisplayListRecorder> recorder_; std::unique_ptr<SkDeferredDisplayListRecorder> recorder_;
std::unique_ptr<SkCanvas> raster_canvas_; SkCanvas* raster_canvas_ = nullptr; // ptr into recorder_ or sk_surface_
uint32_t raster_color_space_id_; uint32_t raster_color_space_id_;
std::vector<SkDiscardableHandleId> locked_handles_; std::vector<SkDiscardableHandleId> locked_handles_;
...@@ -1379,9 +1378,10 @@ ServiceTransferCache* RasterDecoderImpl::GetTransferCacheForTest() { ...@@ -1379,9 +1378,10 @@ ServiceTransferCache* RasterDecoderImpl::GetTransferCacheForTest() {
void RasterDecoderImpl::SetUpForRasterCHROMIUMForTest() { void RasterDecoderImpl::SetUpForRasterCHROMIUMForTest() {
// Some tests use mock GL which doesn't work with skia. Just use a bitmap // Some tests use mock GL which doesn't work with skia. Just use a bitmap
// backed surface for OOP raster commands. // backed surface for OOP raster commands.
sk_surface_ = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(10, 10)); auto info = SkImageInfo::MakeN32(10, 10, kPremul_SkAlphaType,
raster_canvas_ = SkCreateColorSpaceXformCanvas(sk_surface_->getCanvas(), SkColorSpace::MakeSRGB());
SkColorSpace::MakeSRGB()); sk_surface_ = SkSurface::MakeRaster(info);
raster_canvas_ = sk_surface_->getCanvas();
} }
void RasterDecoderImpl::SetOOMErrorForTest() { void RasterDecoderImpl::SetOOMErrorForTest() {
...@@ -2078,25 +2078,21 @@ void RasterDecoderImpl::DoBeginRasterCHROMIUM( ...@@ -2078,25 +2078,21 @@ void RasterDecoderImpl::DoBeginRasterCHROMIUM(
if (!color_space_entry || !color_space_entry->color_space().IsValid()) { if (!color_space_entry || !color_space_entry->color_space().IsValid()) {
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginRasterCHROMIUM", LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginRasterCHROMIUM",
"failed to find valid color space"); "failed to find valid color space");
shared_image_->EndWriteAccess(std::move(sk_surface_));
shared_image_.reset(); shared_image_.reset();
return; return;
} }
SkCanvas* canvas = nullptr;
if (use_ddl_) { if (use_ddl_) {
SkSurfaceCharacterization characterization; SkSurfaceCharacterization characterization;
bool result = sk_surface_->characterize(&characterization); bool result = sk_surface_->characterize(&characterization);
DCHECK(result) << "Failed to characterize raster SkSurface."; DCHECK(result) << "Failed to characterize raster SkSurface.";
recorder_ = recorder_ =
std::make_unique<SkDeferredDisplayListRecorder>(characterization); std::make_unique<SkDeferredDisplayListRecorder>(characterization);
canvas = recorder_->getCanvas(); raster_canvas_ = recorder_->getCanvas();
} else { } else {
canvas = sk_surface_->getCanvas(); raster_canvas_ = sk_surface_->getCanvas();
} }
raster_canvas_ = SkCreateColorSpaceXformCanvas(
canvas, color_space_entry->color_space().ToSkColorSpace());
raster_color_space_id_ = color_space_transfer_cache_id; raster_color_space_id_ = color_space_transfer_cache_id;
// All or nothing clearing, as no way to validate the client's input on what // All or nothing clearing, as no way to validate the client's input on what
...@@ -2164,7 +2160,6 @@ void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id, ...@@ -2164,7 +2160,6 @@ void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id,
alignas( alignas(
cc::PaintOpBuffer::PaintOpAlign) char data[sizeof(cc::LargestPaintOp)]; cc::PaintOpBuffer::PaintOpAlign) char data[sizeof(cc::LargestPaintOp)];
SkCanvas* canvas = raster_canvas_.get();
cc::PlaybackParams playback_params(nullptr, SkMatrix::I()); cc::PlaybackParams playback_params(nullptr, SkMatrix::I());
TransferCacheDeserializeHelperImpl impl(raster_decoder_id_, transfer_cache()); TransferCacheDeserializeHelperImpl impl(raster_decoder_id_, transfer_cache());
cc::PaintOp::DeserializeOptions options( cc::PaintOp::DeserializeOptions options(
...@@ -2186,7 +2181,7 @@ void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id, ...@@ -2186,7 +2181,7 @@ void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id,
return; return;
} }
deserialized_op->Raster(canvas, playback_params); deserialized_op->Raster(raster_canvas_, playback_params);
deserialized_op->DestroyThis(); deserialized_op->DestroyThis();
paint_buffer_size -= skip; paint_buffer_size -= skip;
...@@ -2204,7 +2199,7 @@ void RasterDecoderImpl::DoEndRasterCHROMIUM() { ...@@ -2204,7 +2199,7 @@ void RasterDecoderImpl::DoEndRasterCHROMIUM() {
shared_context_state_->set_need_context_state_reset(true); shared_context_state_->set_need_context_state_reset(true);
raster_canvas_.reset(); raster_canvas_ = nullptr;
if (use_ddl_) { if (use_ddl_) {
auto ddl = recorder_->detach(); auto ddl = recorder_->detach();
......
...@@ -219,8 +219,8 @@ class SharedImageRepresentationSkiaGLAHB ...@@ -219,8 +219,8 @@ class SharedImageRepresentationSkiaGLAHB
/*gpu_compositing=*/true, format()); /*gpu_compositing=*/true, format());
auto surface = SkSurface::MakeFromBackendTextureAsRenderTarget( auto surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
gr_context, promise_texture_->backendTexture(), gr_context, promise_texture_->backendTexture(),
kTopLeft_GrSurfaceOrigin, final_msaa_count, sk_color_type, nullptr, kTopLeft_GrSurfaceOrigin, final_msaa_count, sk_color_type,
&surface_props); backing()->color_space().ToSkColorSpace(), &surface_props);
write_surface_ = surface.get(); write_surface_ = surface.get();
return surface; return surface;
} }
......
...@@ -270,8 +270,8 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia { ...@@ -270,8 +270,8 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia {
/*gpu_compositing=*/true, format()); /*gpu_compositing=*/true, format());
auto surface = SkSurface::MakeFromBackendTextureAsRenderTarget( auto surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
gr_context, promise_texture_->backendTexture(), gr_context, promise_texture_->backendTexture(),
kTopLeft_GrSurfaceOrigin, final_msaa_count, sk_color_type, nullptr, kTopLeft_GrSurfaceOrigin, final_msaa_count, sk_color_type,
&surface_props); backing()->color_space().ToSkColorSpace(), &surface_props);
write_surface_ = surface.get(); write_surface_ = surface.get();
return surface; return surface;
} }
......
...@@ -70,6 +70,7 @@ class WrappedSkImage : public SharedImageBacking { ...@@ -70,6 +70,7 @@ class WrappedSkImage : public SharedImageBacking {
sk_sp<SkSurface> GetSkSurface(int final_msaa_count, sk_sp<SkSurface> GetSkSurface(int final_msaa_count,
SkColorType color_type, SkColorType color_type,
sk_sp<SkColorSpace> color_space,
const SkSurfaceProps& surface_props) { const SkSurfaceProps& surface_props) {
if (context_state_->context_lost()) if (context_state_->context_lost())
return nullptr; return nullptr;
...@@ -79,7 +80,7 @@ class WrappedSkImage : public SharedImageBacking { ...@@ -79,7 +80,7 @@ class WrappedSkImage : public SharedImageBacking {
DCHECK(gr_texture.isValid()); DCHECK(gr_texture.isValid());
return SkSurface::MakeFromBackendTextureAsRenderTarget( return SkSurface::MakeFromBackendTextureAsRenderTarget(
context_state_->gr_context(), gr_texture, kTopLeft_GrSurfaceOrigin, context_state_->gr_context(), gr_texture, kTopLeft_GrSurfaceOrigin,
final_msaa_count, color_type, /*colorSpace=*/nullptr, &surface_props); final_msaa_count, color_type, color_space, &surface_props);
} }
sk_sp<SkPromiseImageTexture> promise_texture() { return promise_texture_; } sk_sp<SkPromiseImageTexture> promise_texture() { return promise_texture_; }
...@@ -194,7 +195,8 @@ class WrappedSkImageRepresentation : public SharedImageRepresentationSkia { ...@@ -194,7 +195,8 @@ class WrappedSkImageRepresentation : public SharedImageRepresentationSkia {
/*gpu_compositing=*/true, format()); /*gpu_compositing=*/true, format());
auto surface = wrapped_sk_image()->GetSkSurface( auto surface = wrapped_sk_image()->GetSkSurface(
final_msaa_count, sk_color_type, surface_props); final_msaa_count, sk_color_type,
backing()->color_space().ToSkColorSpace(), surface_props);
write_surface_ = surface.get(); write_surface_ = surface.get();
return surface; return surface;
} }
......
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