| Index: cc/playback/image_hijack_canvas.cc
|
| diff --git a/cc/playback/image_hijack_canvas.cc b/cc/playback/image_hijack_canvas.cc
|
| index a5d596d7e2f88a1eab3ba5b62cfcad2fe3cbcb26..18cb673f8e01e078622248c90f7bbf8a3963f1d0 100644
|
| --- a/cc/playback/image_hijack_canvas.cc
|
| +++ b/cc/playback/image_hijack_canvas.cc
|
| @@ -24,7 +24,7 @@ class ScopedDecodedImageLock {
|
| sk_sp<const SkImage> image,
|
| const SkRect& src_rect,
|
| const SkMatrix& matrix,
|
| - const SkPaint* paint)
|
| + const PaintFlags* paint)
|
| : image_decode_cache_(image_decode_cache),
|
| draw_image_(std::move(image),
|
| RoundOutRect(src_rect),
|
| @@ -54,7 +54,7 @@ class ScopedDecodedImageLock {
|
| }
|
|
|
| const DecodedDrawImage& decoded_image() const { return decoded_draw_image_; }
|
| - const SkPaint* decoded_paint() const {
|
| + const PaintFlags* decoded_paint() const {
|
| return decoded_paint_ ? &decoded_paint_.value() : nullptr;
|
| }
|
|
|
| @@ -62,20 +62,20 @@ class ScopedDecodedImageLock {
|
| ImageDecodeCache* image_decode_cache_;
|
| DrawImage draw_image_;
|
| DecodedDrawImage decoded_draw_image_;
|
| - base::Optional<SkPaint> decoded_paint_;
|
| + base::Optional<PaintFlags> decoded_paint_;
|
| };
|
|
|
| -// Encapsulates a ScopedDecodedImageLock and an SkPaint. Use of this class
|
| -// ensures that the ScopedDecodedImageLock outlives the dependent SkPaint.
|
| +// Encapsulates a ScopedDecodedImageLock and PaintFlags. Use of this class
|
| +// ensures that the ScopedDecodedImageLock outlives the dependent PaintFlags.
|
| class ScopedImagePaint {
|
| public:
|
| - // Tries to create a ScopedImagePaint for the provided SkPaint. If a
|
| - // the SkPaint does not contain an image that we support replacing,
|
| + // Tries to create a ScopedImagePaint for the provided PaintFlags. If a
|
| + // the PaintFlags does not contain an image that we support replacing,
|
| // an empty base::Optional will be returned.
|
| static base::Optional<ScopedImagePaint> TryCreate(
|
| ImageDecodeCache* image_decode_cache,
|
| const SkMatrix& ctm,
|
| - const SkPaint& paint) {
|
| + const PaintFlags& paint) {
|
| SkShader* shader = paint.getShader();
|
| if (!shader)
|
| return base::Optional<ScopedImagePaint>();
|
| @@ -102,20 +102,20 @@ class ScopedImagePaint {
|
| matrix.preScale(1.f / decoded_image.scale_adjustment().width(),
|
| 1.f / decoded_image.scale_adjustment().height());
|
| }
|
| - SkPaint scratch_paint = paint;
|
| + PaintFlags scratch_paint = paint;
|
| scratch_paint.setShader(
|
| decoded_image.image()->makeShader(xy[0], xy[1], &matrix));
|
| return ScopedImagePaint(std::move(scoped_lock), std::move(scratch_paint));
|
| }
|
|
|
| - const SkPaint& paint() { return paint_; }
|
| + const PaintFlags& paint() { return paint_; }
|
|
|
| private:
|
| - ScopedImagePaint(ScopedDecodedImageLock lock, SkPaint paint)
|
| + ScopedImagePaint(ScopedDecodedImageLock lock, PaintFlags paint)
|
| : lock_(std::move(lock)), paint_(std::move(paint)) {}
|
|
|
| ScopedDecodedImageLock lock_;
|
| - SkPaint paint_;
|
| + PaintFlags paint_;
|
| };
|
|
|
| } // namespace
|
| @@ -123,22 +123,23 @@ class ScopedImagePaint {
|
| ImageHijackCanvas::ImageHijackCanvas(int width,
|
| int height,
|
| ImageDecodeCache* image_decode_cache)
|
| - : SkNWayCanvas(width, height), image_decode_cache_(image_decode_cache) {}
|
| + : PaintCanvasPassThrough(width, height),
|
| + image_decode_cache_(image_decode_cache) {}
|
|
|
| -void ImageHijackCanvas::onDrawPicture(const SkPicture* picture,
|
| +void ImageHijackCanvas::onDrawPicture(const PaintRecord* picture,
|
| const SkMatrix* matrix,
|
| - const SkPaint* paint) {
|
| + const PaintFlags* paint) {
|
| // Ensure that pictures are unpacked by this canvas, instead of being
|
| // forwarded to the raster canvas.
|
| - SkCanvas::onDrawPicture(picture, matrix, paint);
|
| + PaintCanvas::onDrawPicture(picture, matrix, paint);
|
| }
|
|
|
| void ImageHijackCanvas::onDrawImage(const SkImage* image,
|
| SkScalar x,
|
| SkScalar y,
|
| - const SkPaint* paint) {
|
| + const PaintFlags* paint) {
|
| if (!image->isLazyGenerated()) {
|
| - SkNWayCanvas::onDrawImage(image, x, y, paint);
|
| + PaintCanvasPassThrough::onDrawImage(image, x, y, paint);
|
| return;
|
| }
|
|
|
| @@ -153,26 +154,28 @@ void ImageHijackCanvas::onDrawImage(const SkImage* image,
|
|
|
| DCHECK_EQ(0, static_cast<int>(decoded_image.src_rect_offset().width()));
|
| DCHECK_EQ(0, static_cast<int>(decoded_image.src_rect_offset().height()));
|
| - const SkPaint* decoded_paint = scoped_lock.decoded_paint();
|
| + const PaintFlags* decoded_paint = scoped_lock.decoded_paint();
|
|
|
| bool need_scale = !decoded_image.is_scale_adjustment_identity();
|
| if (need_scale) {
|
| - SkNWayCanvas::save();
|
| - SkNWayCanvas::scale(1.f / (decoded_image.scale_adjustment().width()),
|
| - 1.f / (decoded_image.scale_adjustment().height()));
|
| + PaintCanvasPassThrough::save();
|
| + PaintCanvasPassThrough::scale(
|
| + 1.f / (decoded_image.scale_adjustment().width()),
|
| + 1.f / (decoded_image.scale_adjustment().height()));
|
| }
|
| - SkNWayCanvas::onDrawImage(decoded_image.image().get(), x, y, decoded_paint);
|
| + PaintCanvasPassThrough::onDrawImage(decoded_image.image().get(), x, y,
|
| + decoded_paint);
|
| if (need_scale)
|
| - SkNWayCanvas::restore();
|
| + PaintCanvasPassThrough::restore();
|
| }
|
|
|
| void ImageHijackCanvas::onDrawImageRect(const SkImage* image,
|
| const SkRect* src,
|
| const SkRect& dst,
|
| - const SkPaint* paint,
|
| + const PaintFlags* paint,
|
| SrcRectConstraint constraint) {
|
| if (!image->isLazyGenerated()) {
|
| - SkNWayCanvas::onDrawImageRect(image, src, dst, paint, constraint);
|
| + PaintCanvasPassThrough::onDrawImageRect(image, src, dst, paint, constraint);
|
| return;
|
| }
|
|
|
| @@ -191,7 +194,7 @@ void ImageHijackCanvas::onDrawImageRect(const SkImage* image,
|
| if (!decoded_image.image())
|
| return;
|
|
|
| - const SkPaint* decoded_paint = scoped_lock.decoded_paint();
|
| + const PaintFlags* decoded_paint = scoped_lock.decoded_paint();
|
|
|
| SkRect adjusted_src =
|
| src->makeOffset(decoded_image.src_rect_offset().width(),
|
| @@ -203,69 +206,73 @@ void ImageHijackCanvas::onDrawImageRect(const SkImage* image,
|
| adjusted_src.x() * x_scale, adjusted_src.y() * y_scale,
|
| adjusted_src.width() * x_scale, adjusted_src.height() * y_scale);
|
| }
|
| - SkNWayCanvas::onDrawImageRect(decoded_image.image().get(), &adjusted_src, dst,
|
| - decoded_paint, constraint);
|
| + PaintCanvasPassThrough::onDrawImageRect(decoded_image.image().get(),
|
| + &adjusted_src, dst, decoded_paint,
|
| + constraint);
|
| }
|
|
|
| -void ImageHijackCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) {
|
| +void ImageHijackCanvas::onDrawRect(const SkRect& r, const PaintFlags& paint) {
|
| base::Optional<ScopedImagePaint> image_paint =
|
| ScopedImagePaint::TryCreate(image_decode_cache_, getTotalMatrix(), paint);
|
| if (!image_paint.has_value()) {
|
| - SkNWayCanvas::onDrawRect(r, paint);
|
| + PaintCanvasPassThrough::onDrawRect(r, paint);
|
| return;
|
| }
|
| - SkNWayCanvas::onDrawRect(r, image_paint.value().paint());
|
| + PaintCanvasPassThrough::onDrawRect(r, image_paint.value().paint());
|
| }
|
|
|
| -void ImageHijackCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
|
| +void ImageHijackCanvas::onDrawPath(const SkPath& path,
|
| + const PaintFlags& paint) {
|
| base::Optional<ScopedImagePaint> image_paint =
|
| ScopedImagePaint::TryCreate(image_decode_cache_, getTotalMatrix(), paint);
|
| if (!image_paint.has_value()) {
|
| - SkNWayCanvas::onDrawPath(path, paint);
|
| + PaintCanvasPassThrough::onDrawPath(path, paint);
|
| return;
|
| }
|
| - SkNWayCanvas::onDrawPath(path, image_paint.value().paint());
|
| + PaintCanvasPassThrough::onDrawPath(path, image_paint.value().paint());
|
| }
|
|
|
| -void ImageHijackCanvas::onDrawOval(const SkRect& r, const SkPaint& paint) {
|
| +void ImageHijackCanvas::onDrawOval(const SkRect& r, const PaintFlags& paint) {
|
| base::Optional<ScopedImagePaint> image_paint =
|
| ScopedImagePaint::TryCreate(image_decode_cache_, getTotalMatrix(), paint);
|
| if (!image_paint.has_value()) {
|
| - SkNWayCanvas::onDrawOval(r, paint);
|
| + PaintCanvasPassThrough::onDrawOval(r, paint);
|
| return;
|
| }
|
| - SkNWayCanvas::onDrawOval(r, image_paint.value().paint());
|
| + PaintCanvasPassThrough::onDrawOval(r, image_paint.value().paint());
|
| }
|
|
|
| void ImageHijackCanvas::onDrawArc(const SkRect& r,
|
| SkScalar start_angle,
|
| SkScalar sweep_angle,
|
| bool use_center,
|
| - const SkPaint& paint) {
|
| + const PaintFlags& paint) {
|
| base::Optional<ScopedImagePaint> image_paint =
|
| ScopedImagePaint::TryCreate(image_decode_cache_, getTotalMatrix(), paint);
|
| if (!image_paint.has_value()) {
|
| - SkNWayCanvas::onDrawArc(r, start_angle, sweep_angle, use_center, paint);
|
| + PaintCanvasPassThrough::onDrawArc(r, start_angle, sweep_angle, use_center,
|
| + paint);
|
| return;
|
| }
|
| - SkNWayCanvas::onDrawArc(r, start_angle, sweep_angle, use_center,
|
| - image_paint.value().paint());
|
| + PaintCanvasPassThrough::onDrawArc(r, start_angle, sweep_angle, use_center,
|
| + image_paint.value().paint());
|
| }
|
|
|
| -void ImageHijackCanvas::onDrawRRect(const SkRRect& rr, const SkPaint& paint) {
|
| +void ImageHijackCanvas::onDrawRRect(const SkRRect& rr,
|
| + const PaintFlags& paint) {
|
| base::Optional<ScopedImagePaint> image_paint =
|
| ScopedImagePaint::TryCreate(image_decode_cache_, getTotalMatrix(), paint);
|
| if (!image_paint.has_value()) {
|
| - SkNWayCanvas::onDrawRRect(rr, paint);
|
| + PaintCanvasPassThrough::onDrawRRect(rr, paint);
|
| return;
|
| }
|
| - SkNWayCanvas::onDrawRRect(rr, image_paint.value().paint());
|
| + PaintCanvasPassThrough::onDrawRRect(rr, image_paint.value().paint());
|
| }
|
|
|
| void ImageHijackCanvas::onDrawImageNine(const SkImage* image,
|
| const SkIRect& center,
|
| const SkRect& dst,
|
| - const SkPaint* paint) {
|
| + const PaintFlags* paint) {
|
| // No cc embedder issues image nine calls.
|
| NOTREACHED();
|
| }
|
|
|