Commit 1612701e authored by Mike Reed's avatar Mike Reed Committed by Commit Bot

don't use ColorSpaceXformCanvas

Bug: skia:8773
Change-Id: Icb42a9604f44c342eb18a974068ba0584dc3a740
Reviewed-on: https://chromium-review.googlesource.com/c/1476972Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Cr-Commit-Position: refs/heads/master@{#635174}
parent cbc0648f
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "cc/paint/scoped_raster_flags.h" #include "cc/paint/scoped_raster_flags.h"
#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
namespace cc { namespace cc {
...@@ -91,16 +90,6 @@ PaintOpBufferSerializer::PaintOpBufferSerializer( ...@@ -91,16 +90,6 @@ PaintOpBufferSerializer::PaintOpBufferSerializer(
max_texture_size, max_texture_size,
max_texture_bytes)) { max_texture_bytes)) {
DCHECK(serialize_cb_); DCHECK(serialize_cb_);
if (color_space->isSRGB()) {
// 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;
...@@ -108,16 +97,16 @@ PaintOpBufferSerializer::~PaintOpBufferSerializer() = default; ...@@ -108,16 +97,16 @@ PaintOpBufferSerializer::~PaintOpBufferSerializer() = default;
void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer, void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer,
const std::vector<size_t>* offsets, const std::vector<size_t>* offsets,
const Preamble& preamble) { const Preamble& preamble) {
DCHECK(canvas_->getTotalMatrix().isIdentity()); DCHECK(text_blob_canvas_.getTotalMatrix().isIdentity());
static const int kInitialSaveCount = 1; static const int kInitialSaveCount = 1;
DCHECK_EQ(kInitialSaveCount, canvas_->getSaveCount()); DCHECK_EQ(kInitialSaveCount, text_blob_canvas_.getSaveCount());
// These SerializeOptions and PlaybackParams use the initial (identity) canvas // These SerializeOptions and PlaybackParams use the initial (identity) canvas
// matrix, as they are only used for serializing the preamble and the initial // matrix, as they are only used for serializing the preamble and the initial
// 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_); PlaybackParams params = MakeParams(&text_blob_canvas_);
Save(options, params); Save(options, params);
SerializePreamble(preamble, options, params); SerializePreamble(preamble, options, params);
...@@ -126,7 +115,7 @@ void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer, ...@@ -126,7 +115,7 @@ void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer,
} }
void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer) { void PaintOpBufferSerializer::Serialize(const PaintOpBuffer* buffer) {
DCHECK(canvas_->getTotalMatrix().isIdentity()); DCHECK(text_blob_canvas_.getTotalMatrix().isIdentity());
SerializeBuffer(buffer, nullptr); SerializeBuffer(buffer, nullptr);
} }
...@@ -136,10 +125,10 @@ void PaintOpBufferSerializer::Serialize( ...@@ -136,10 +125,10 @@ void PaintOpBufferSerializer::Serialize(
const gfx::Rect& playback_rect, const gfx::Rect& playback_rect,
const gfx::SizeF& post_scale, const gfx::SizeF& post_scale,
const SkMatrix& post_matrix_for_analysis) { const SkMatrix& post_matrix_for_analysis) {
DCHECK(canvas_->getTotalMatrix().isIdentity()); DCHECK(text_blob_canvas_.getTotalMatrix().isIdentity());
PaintOp::SerializeOptions options = MakeSerializeOptions(); PaintOp::SerializeOptions options = MakeSerializeOptions();
PlaybackParams params = MakeParams(canvas_); PlaybackParams params = MakeParams(&text_blob_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()) {
...@@ -153,7 +142,7 @@ void PaintOpBufferSerializer::Serialize( ...@@ -153,7 +142,7 @@ void PaintOpBufferSerializer::Serialize(
SerializeOp(&scale_op, options, params); SerializeOp(&scale_op, options, params);
} }
canvas_->concat(post_matrix_for_analysis); text_blob_canvas_.concat(post_matrix_for_analysis);
SerializeBuffer(buffer, nullptr); SerializeBuffer(buffer, nullptr);
} }
...@@ -281,7 +270,7 @@ void PaintOpBufferSerializer::SerializeBuffer( ...@@ -281,7 +270,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_); PlaybackParams params = MakeParams(&text_blob_canvas_);
for (PaintOpBuffer::PlaybackFoldingIterator iter(buffer, offsets); iter; for (PaintOpBuffer::PlaybackFoldingIterator iter(buffer, offsets); iter;
++iter) { ++iter) {
...@@ -290,7 +279,7 @@ void PaintOpBufferSerializer::SerializeBuffer( ...@@ -290,7 +279,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_); PaintOp::QuickRejectDraw(op, &text_blob_canvas_);
if (skip_op) if (skip_op)
continue; continue;
...@@ -308,7 +297,7 @@ void PaintOpBufferSerializer::SerializeBuffer( ...@@ -308,7 +297,7 @@ void PaintOpBufferSerializer::SerializeBuffer(
continue; continue;
} }
int save_count = canvas_->getSaveCount(); int save_count = text_blob_canvas_.getSaveCount();
Save(options, params); Save(options, params);
SerializeBuffer(static_cast<const DrawRecordOp*>(op)->record.get(), SerializeBuffer(static_cast<const DrawRecordOp*>(op)->record.get(),
nullptr); nullptr);
...@@ -371,9 +360,9 @@ void PaintOpBufferSerializer::PlaybackOnAnalysisCanvas( ...@@ -371,9 +360,9 @@ void PaintOpBufferSerializer::PlaybackOnAnalysisCanvas(
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_, options.flags_to_serialize, params); &text_blob_canvas_, options.flags_to_serialize, params);
} else { } else {
op->Raster(canvas_, params); op->Raster(&text_blob_canvas_, params);
} }
} }
...@@ -388,7 +377,7 @@ void PaintOpBufferSerializer::RestoreToCount( ...@@ -388,7 +377,7 @@ void PaintOpBufferSerializer::RestoreToCount(
const PaintOp::SerializeOptions& options, const PaintOp::SerializeOptions& options,
const PlaybackParams& params) { const PlaybackParams& params) {
RestoreOp restore_op; RestoreOp restore_op;
while (canvas_->getSaveCount() > count) { while (text_blob_canvas_.getSaveCount() > count) {
if (!SerializeOp(&restore_op, options, params)) if (!SerializeOp(&restore_op, options, params))
return; return;
} }
...@@ -396,9 +385,10 @@ void PaintOpBufferSerializer::RestoreToCount( ...@@ -396,9 +385,10 @@ void PaintOpBufferSerializer::RestoreToCount(
PaintOp::SerializeOptions PaintOpBufferSerializer::MakeSerializeOptions() { PaintOp::SerializeOptions PaintOpBufferSerializer::MakeSerializeOptions() {
return PaintOp::SerializeOptions( return PaintOp::SerializeOptions(
image_provider_, transfer_cache_, paint_cache_, canvas_, strike_server_, image_provider_, transfer_cache_, paint_cache_, &text_blob_canvas_,
color_space_, can_use_lcd_text_, context_supports_distance_field_text_, strike_server_, color_space_, can_use_lcd_text_,
max_texture_size_, max_texture_bytes_, canvas_->getTotalMatrix()); context_supports_distance_field_text_, max_texture_size_,
max_texture_bytes_, text_blob_canvas_.getTotalMatrix());
} }
SimpleBufferSerializer::SimpleBufferSerializer( SimpleBufferSerializer::SimpleBufferSerializer(
......
...@@ -117,8 +117,6 @@ class CC_PAINT_EXPORT PaintOpBufferSerializer { ...@@ -117,8 +117,6 @@ 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> color_canvas_;
SkCanvas* canvas_ = nullptr;
bool valid_ = true; bool valid_ = true;
}; };
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "skia/ext/opacity_filter_canvas.h" #include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "third_party/skia/include/core/SkMatrix.h" #include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkOverdrawCanvas.h" #include "third_party/skia/include/core/SkOverdrawCanvas.h"
#include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkPath.h"
...@@ -723,12 +722,6 @@ void SkiaRenderer::DrawPictureQuad(const PictureDrawQuad* quad, ...@@ -723,12 +722,6 @@ void SkiaRenderer::DrawPictureQuad(const PictureDrawQuad* quad,
SkCanvas* raster_canvas = current_canvas_; SkCanvas* raster_canvas = current_canvas_;
std::unique_ptr<SkCanvas> color_transform_canvas;
// TODO(enne): color transform needs to be replicated in gles2_cmd_decoder
color_transform_canvas = SkCreateColorSpaceXformCanvas(
current_canvas_, gfx::ColorSpace::CreateSRGB().ToSkColorSpace());
raster_canvas = color_transform_canvas.get();
base::Optional<skia::OpacityFilterCanvas> opacity_canvas; base::Optional<skia::OpacityFilterCanvas> opacity_canvas;
if (needs_transparency || disable_image_filtering) { if (needs_transparency || disable_image_filtering) {
// TODO(aelias): This isn't correct in all cases. We should detect these // TODO(aelias): This isn't correct in all cases. We should detect these
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "skia/ext/opacity_filter_canvas.h" #include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "third_party/skia/include/core/SkImageFilter.h" #include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkMatrix.h" #include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkPath.h"
...@@ -341,12 +340,6 @@ void SoftwareRenderer::DrawPictureQuad(const PictureDrawQuad* quad) { ...@@ -341,12 +340,6 @@ void SoftwareRenderer::DrawPictureQuad(const PictureDrawQuad* quad) {
SkCanvas* raster_canvas = current_canvas_; SkCanvas* raster_canvas = current_canvas_;
std::unique_ptr<SkCanvas> color_transform_canvas;
// TODO(enne): color transform needs to be replicated in gles2_cmd_decoder
color_transform_canvas = SkCreateColorSpaceXformCanvas(
current_canvas_, gfx::ColorSpace::CreateSRGB().ToSkColorSpace());
raster_canvas = color_transform_canvas.get();
base::Optional<skia::OpacityFilterCanvas> opacity_canvas; base::Optional<skia::OpacityFilterCanvas> opacity_canvas;
if (needs_transparency || disable_image_filtering) { if (needs_transparency || disable_image_filtering) {
// TODO(aelias): This isn't correct in all cases. We should detect these // TODO(aelias): This isn't correct in all cases. We should detect these
......
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