diff options
author | ericrk <ericrk@chromium.org> | 2016-03-09 11:22:01 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-09 19:23:10 +0000 |
commit | 81e00287867911a113d3b251c1fe46f96c2e0ab2 (patch) | |
tree | c1509c074055fef80aedd6b5a431fbb40e682a84 /cc/playback | |
parent | 5a6a68a30d3830ca3c53a66d4e39df7ff9e87bfa (diff) | |
download | chromium_src-81e00287867911a113d3b251c1fe46f96c2e0ab2.zip chromium_src-81e00287867911a113d3b251c1fe46f96c2e0ab2.tar.gz chromium_src-81e00287867911a113d3b251c1fe46f96c2e0ab2.tar.bz2 |
DrawImage updates
GPU Image Decode Controller needs to get an image's full matrix, so
a matrix was added to DrawImage. DrawImage can now calculate its scale
and decomposability itself, rather than relying on the call site.
Additionaly, it turns out that perspective implies non-decomposability,
so the perspective flag was redundant. This has been removed.
BUG=
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1781493003
Cr-Commit-Position: refs/heads/master@{#380170}
Diffstat (limited to 'cc/playback')
-rw-r--r-- | cc/playback/discardable_image_map.cc | 16 | ||||
-rw-r--r-- | cc/playback/discardable_image_map.h | 4 | ||||
-rw-r--r-- | cc/playback/draw_image.cc | 34 | ||||
-rw-r--r-- | cc/playback/draw_image.h | 17 | ||||
-rw-r--r-- | cc/playback/image_hijack_canvas.cc | 18 |
5 files changed, 37 insertions, 52 deletions
diff --git a/cc/playback/discardable_image_map.cc b/cc/playback/discardable_image_map.cc index cb69bdf..5588a69 100644 --- a/cc/playback/discardable_image_map.cc +++ b/cc/playback/discardable_image_map.cc @@ -24,17 +24,6 @@ SkRect MapRect(const SkMatrix& matrix, const SkRect& src) { return dst; } -bool ExtractScale(const SkMatrix& matrix, SkSize* scale) { - *scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY()); - if (matrix.getType() & SkMatrix::kAffine_Mask) { - if (!matrix.decomposeScale(scale)) { - scale->set(1, 1); - return false; - } - } - return true; -} - namespace { // We're using an NWay canvas with no added canvases, so in effect @@ -155,11 +144,8 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas { SkIRect src_irect; src_rect.roundOut(&src_irect); - SkSize scale; - bool is_decomposable = ExtractScale(matrix, &scale); image_set_->push_back( - std::make_pair(DrawImage(image, src_irect, scale, filter_quality, - matrix.hasPerspective(), is_decomposable), + std::make_pair(DrawImage(image, src_irect, filter_quality, matrix), gfx::ToEnclosingRect(gfx::SkRectToRectF(paint_rect)))); } diff --git a/cc/playback/discardable_image_map.h b/cc/playback/discardable_image_map.h index 90c9da2..3b29da2 100644 --- a/cc/playback/discardable_image_map.h +++ b/cc/playback/discardable_image_map.h @@ -24,10 +24,6 @@ namespace cc { // Helper function to apply the matrix to the rect and return the result. SkRect MapRect(const SkMatrix& matrix, const SkRect& src); -// Helper funciton to extract a scale from the matrix. Returns true on success -// and false on failure. -bool ExtractScale(const SkMatrix& matrix, SkSize* scale); - // This class is used for generating discardable images data (see DrawImage // for the type of data it stores). It allows the client to query a particular // rect and get back a list of DrawImages in that rect. diff --git a/cc/playback/draw_image.cc b/cc/playback/draw_image.cc index a9c965a..17aef31 100644 --- a/cc/playback/draw_image.cc +++ b/cc/playback/draw_image.cc @@ -5,32 +5,48 @@ #include "cc/playback/draw_image.h" namespace cc { +namespace { + +// Helper funciton to extract a scale from the matrix. Returns true on success +// and false on failure. +bool ExtractScale(const SkMatrix& matrix, SkSize* scale) { + *scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY()); + if (matrix.getType() & SkMatrix::kAffine_Mask) { + if (!matrix.decomposeScale(scale)) { + scale->set(1, 1); + return false; + } + } + return true; +} + +} // namespace DrawImage::DrawImage() : image_(nullptr), src_rect_(SkIRect::MakeXYWH(0, 0, 0, 0)), + filter_quality_(kNone_SkFilterQuality), + matrix_(SkMatrix::I()), scale_(SkSize::Make(1.f, 1.f)), - filter_quality_(kNone_SkFilterQuality) {} + matrix_is_decomposable_(true) {} DrawImage::DrawImage(const SkImage* image, const SkIRect& src_rect, - const SkSize& scale, SkFilterQuality filter_quality, - bool matrix_has_perspective, - bool matrix_is_decomposable) + const SkMatrix& matrix) : image_(image), src_rect_(src_rect), - scale_(scale), filter_quality_(filter_quality), - matrix_has_perspective_(matrix_has_perspective), - matrix_is_decomposable_(matrix_is_decomposable) {} + matrix_(matrix) { + matrix_is_decomposable_ = ExtractScale(matrix_, &scale_); +} DrawImage::DrawImage(const DrawImage& other) : image_(other.image_), src_rect_(other.src_rect_), - scale_(other.scale_), filter_quality_(other.filter_quality_), - matrix_has_perspective_(other.matrix_has_perspective_), + matrix_(other.matrix_), + scale_(other.scale_), matrix_is_decomposable_(other.matrix_is_decomposable_) {} } // namespace cc diff --git a/cc/playback/draw_image.h b/cc/playback/draw_image.h index 88ecfdf..83b10ba 100644 --- a/cc/playback/draw_image.h +++ b/cc/playback/draw_image.h @@ -19,32 +19,29 @@ class CC_EXPORT DrawImage { DrawImage(); DrawImage(const SkImage* image, const SkIRect& src_rect, - const SkSize& scale, SkFilterQuality filter_quality, - bool matrix_has_perspective, - bool matrix_is_decomposable); + const SkMatrix& matrix); DrawImage(const DrawImage& other); const SkImage* image() const { return image_; } const SkSize& scale() const { return scale_; } const SkIRect src_rect() const { return src_rect_; } SkFilterQuality filter_quality() const { return filter_quality_; } - bool matrix_has_perspective() const { return matrix_has_perspective_; } bool matrix_is_decomposable() const { return matrix_is_decomposable_; } + const SkMatrix& matrix() { return matrix_; } DrawImage ApplyScale(float scale) const { - return DrawImage( - image_, src_rect_, - SkSize::Make(scale_.width() * scale, scale_.height() * scale), - filter_quality_, matrix_has_perspective_, matrix_is_decomposable_); + SkMatrix scaled_matrix = matrix_; + scaled_matrix.postScale(scale, scale); + return DrawImage(image_, src_rect_, filter_quality_, scaled_matrix); } private: const SkImage* image_; SkIRect src_rect_; - SkSize scale_; SkFilterQuality filter_quality_; - bool matrix_has_perspective_; + SkMatrix matrix_; + SkSize scale_; bool matrix_is_decomposable_; }; diff --git a/cc/playback/image_hijack_canvas.cc b/cc/playback/image_hijack_canvas.cc index aef2ac8..d0c5c5c7 100644 --- a/cc/playback/image_hijack_canvas.cc +++ b/cc/playback/image_hijack_canvas.cc @@ -22,17 +22,13 @@ class ScopedDecodedImageLock { ScopedDecodedImageLock(ImageDecodeController* image_decode_controller, const SkImage* image, const SkRect& src_rect, - const SkSize& scale, - bool is_decomposable, - bool has_perspective, + const SkMatrix& matrix, const SkPaint* paint) : image_decode_controller_(image_decode_controller), draw_image_(image, RoundOutRect(src_rect), - scale, paint ? paint->getFilterQuality() : kNone_SkFilterQuality, - has_perspective, - is_decomposable), + matrix), decoded_draw_image_( image_decode_controller_->GetDecodedImageForDraw(draw_image_)) { DCHECK(image->isLazyGenerated()); @@ -85,12 +81,9 @@ void ImageHijackCanvas::onDrawImage(const SkImage* image, SkMatrix ctm = getTotalMatrix(); - SkSize scale; - bool is_decomposable = ExtractScale(ctm, &scale); ScopedDecodedImageLock scoped_lock( image_decode_controller_, image, - SkRect::MakeIWH(image->width(), image->height()), scale, is_decomposable, - ctm.hasPerspective(), paint); + SkRect::MakeIWH(image->width(), image->height()), ctm, paint); const DecodedDrawImage& decoded_image = scoped_lock.decoded_image(); if (!decoded_image.image()) return; @@ -129,11 +122,8 @@ void ImageHijackCanvas::onDrawImageRect(const SkImage* image, matrix.setRectToRect(*src, dst, SkMatrix::kFill_ScaleToFit); matrix.postConcat(getTotalMatrix()); - SkSize scale; - bool is_decomposable = ExtractScale(matrix, &scale); ScopedDecodedImageLock scoped_lock(image_decode_controller_, image, *src, - scale, is_decomposable, - matrix.hasPerspective(), paint); + matrix, paint); const DecodedDrawImage& decoded_image = scoped_lock.decoded_image(); if (!decoded_image.image()) return; |