Commit e8d19122 authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

cc: Don't use unnecessary colorspace conversion canvas

Colorspace conversion is showing up in profiles, and this is unnecessary
on the renderer side when it is SRGB.

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I9de0be7700ceffa44f072e8160ddb6fed5fd7730
Reviewed-on: https://chromium-review.googlesource.com/1147491Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Commit-Queue: enne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577338}
parent 49d91137
...@@ -89,8 +89,16 @@ PaintOpBufferSerializer::PaintOpBufferSerializer( ...@@ -89,8 +89,16 @@ PaintOpBufferSerializer::PaintOpBufferSerializer(
max_texture_size, max_texture_size,
max_texture_bytes)) { max_texture_bytes)) {
DCHECK(serialize_cb_); DCHECK(serialize_cb_);
canvas_ = SkCreateColorSpaceXformCanvas(&text_blob_canvas_, if (color_space->isSRGB()) {
sk_ref_sp<SkColorSpace>(color_space)); // Colorspace converting every paint is not free. Only images have a
// non-srgb colorspace and this serializer does not handle images.
// Therefore, it's correct to just ignore the conversion for srgb.
canvas_ = &text_blob_canvas_;
} else {
color_canvas_ = SkCreateColorSpaceXformCanvas(
&text_blob_canvas_, sk_ref_sp<SkColorSpace>(color_space));
canvas_ = color_canvas_.get();
}
} }
PaintOpBufferSerializer::~PaintOpBufferSerializer() = default; PaintOpBufferSerializer::~PaintOpBufferSerializer() = default;
...@@ -107,7 +115,7 @@ void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer, ...@@ -107,7 +115,7 @@ void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer,
// save / final restore. SerializeBuffer will create its own SerializeOptions // save / final restore. SerializeBuffer will create its own SerializeOptions
// and PlaybackParams based on the post-preamble canvas. // and PlaybackParams based on the post-preamble canvas.
PaintOp::SerializeOptions options = MakeSerializeOptions(); PaintOp::SerializeOptions options = MakeSerializeOptions();
PlaybackParams params = MakeParams(canvas_.get()); PlaybackParams params = MakeParams(canvas_);
Save(options, params); Save(options, params);
SerializePreamble(preamble, options, params); SerializePreamble(preamble, options, params);
...@@ -129,7 +137,7 @@ void PaintOpBufferSerializer::Serialize( ...@@ -129,7 +137,7 @@ void PaintOpBufferSerializer::Serialize(
DCHECK(canvas_->getTotalMatrix().isIdentity()); DCHECK(canvas_->getTotalMatrix().isIdentity());
PaintOp::SerializeOptions options = MakeSerializeOptions(); PaintOp::SerializeOptions options = MakeSerializeOptions();
PlaybackParams params = MakeParams(canvas_.get()); PlaybackParams params = MakeParams(canvas_);
// TODO(khushalsagar): remove this clip rect if it's not needed. // TODO(khushalsagar): remove this clip rect if it's not needed.
if (!playback_rect.IsEmpty()) { if (!playback_rect.IsEmpty()) {
...@@ -272,7 +280,7 @@ void PaintOpBufferSerializer::SerializeBuffer( ...@@ -272,7 +280,7 @@ void PaintOpBufferSerializer::SerializeBuffer(
const std::vector<size_t>* offsets) { const std::vector<size_t>* offsets) {
DCHECK(buffer); DCHECK(buffer);
PaintOp::SerializeOptions options = MakeSerializeOptions(); PaintOp::SerializeOptions options = MakeSerializeOptions();
PlaybackParams params = MakeParams(canvas_.get()); PlaybackParams params = MakeParams(canvas_);
for (PaintOpBuffer::PlaybackFoldingIterator iter(buffer, offsets); iter; for (PaintOpBuffer::PlaybackFoldingIterator iter(buffer, offsets); iter;
++iter) { ++iter) {
...@@ -281,7 +289,7 @@ void PaintOpBufferSerializer::SerializeBuffer( ...@@ -281,7 +289,7 @@ void PaintOpBufferSerializer::SerializeBuffer(
// Skip ops outside the current clip if they have images. This saves // Skip ops outside the current clip if they have images. This saves
// performing an unnecessary expensive decode. // performing an unnecessary expensive decode.
const bool skip_op = PaintOp::OpHasDiscardableImages(op) && const bool skip_op = PaintOp::OpHasDiscardableImages(op) &&
PaintOp::QuickRejectDraw(op, canvas_.get()); PaintOp::QuickRejectDraw(op, canvas_);
if (skip_op) if (skip_op)
continue; continue;
...@@ -352,9 +360,9 @@ bool PaintOpBufferSerializer::SerializeOp( ...@@ -352,9 +360,9 @@ bool PaintOpBufferSerializer::SerializeOp(
if (op->IsPaintOpWithFlags() && options.flags_to_serialize) { if (op->IsPaintOpWithFlags() && options.flags_to_serialize) {
static_cast<const PaintOpWithFlags*>(op)->RasterWithFlags( static_cast<const PaintOpWithFlags*>(op)->RasterWithFlags(
canvas_.get(), options.flags_to_serialize, params); canvas_, options.flags_to_serialize, params);
} else { } else {
op->Raster(canvas_.get(), params); op->Raster(canvas_, params);
} }
return true; return true;
} }
...@@ -378,8 +386,8 @@ void PaintOpBufferSerializer::RestoreToCount( ...@@ -378,8 +386,8 @@ void PaintOpBufferSerializer::RestoreToCount(
PaintOp::SerializeOptions PaintOpBufferSerializer::MakeSerializeOptions() { PaintOp::SerializeOptions PaintOpBufferSerializer::MakeSerializeOptions() {
return PaintOp::SerializeOptions( return PaintOp::SerializeOptions(
image_provider_, transfer_cache_, canvas_.get(), strike_server_, image_provider_, transfer_cache_, canvas_, strike_server_, color_space_,
color_space_, can_use_lcd_text_, context_supports_distance_field_text_, can_use_lcd_text_, context_supports_distance_field_text_,
max_texture_size_, max_texture_bytes_, canvas_->getTotalMatrix()); max_texture_size_, max_texture_bytes_, canvas_->getTotalMatrix());
} }
......
...@@ -110,7 +110,8 @@ class CC_PAINT_EXPORT PaintOpBufferSerializer { ...@@ -110,7 +110,8 @@ class CC_PAINT_EXPORT PaintOpBufferSerializer {
size_t max_texture_bytes_; size_t max_texture_bytes_;
SkTextBlobCacheDiffCanvas text_blob_canvas_; SkTextBlobCacheDiffCanvas text_blob_canvas_;
std::unique_ptr<SkCanvas> canvas_; std::unique_ptr<SkCanvas> color_canvas_;
SkCanvas* canvas_ = nullptr;
bool valid_ = true; bool valid_ = true;
}; };
......
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