| Index: cc/playback/discardable_image_map.cc
|
| diff --git a/cc/playback/discardable_image_map.cc b/cc/playback/discardable_image_map.cc
|
| index 29201d6fa87700085a6282553a7a16106845103c..3bd099f0c3ae5deb0c334c011f15c2810d0bbfed 100644
|
| --- a/cc/playback/discardable_image_map.cc
|
| +++ b/cc/playback/discardable_image_map.cc
|
| @@ -12,9 +12,10 @@
|
| #include "base/containers/adapters.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "cc/base/math_util.h"
|
| +#include "cc/paint/paint_canvas.h"
|
| +#include "cc/paint/paint_flags.h"
|
| #include "cc/playback/display_item_list.h"
|
| #include "third_party/skia/include/core/SkPath.h"
|
| -#include "third_party/skia/include/utils/SkNWayCanvas.h"
|
| #include "ui/gfx/geometry/rect_conversions.h"
|
| #include "ui/gfx/skia_util.h"
|
|
|
| @@ -57,30 +58,30 @@ namespace {
|
|
|
| // We're using an NWay canvas with no added canvases, so in effect
|
| // non-overridden functions are no-ops.
|
| -class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| +class DiscardableImagesMetadataCanvas : public PaintCanvasNoDraw {
|
| public:
|
| DiscardableImagesMetadataCanvas(
|
| int width,
|
| int height,
|
| std::vector<std::pair<DrawImage, gfx::Rect>>* image_set)
|
| - : SkNWayCanvas(width, height),
|
| + : PaintCanvasNoDraw(width, height),
|
| image_set_(image_set),
|
| canvas_bounds_(SkRect::MakeIWH(width, height)),
|
| canvas_size_(width, height) {}
|
|
|
| protected:
|
| - // we need to "undo" the behavior of SkNWayCanvas, which will try to forward
|
| - // it.
|
| - void onDrawPicture(const SkPicture* picture,
|
| + // we need to "undo" the behavior of PaintCanvasNoDraw, which will try to
|
| + // forward it.
|
| + void onDrawPicture(const PaintRecord* picture,
|
| const SkMatrix* matrix,
|
| - const SkPaint* paint) override {
|
| - SkCanvas::onDrawPicture(picture, matrix, paint);
|
| + const PaintFlags* paint) override {
|
| + PaintCanvas::onDrawPicture(picture, matrix, paint);
|
| }
|
|
|
| void onDrawImage(const SkImage* image,
|
| SkScalar x,
|
| SkScalar y,
|
| - const SkPaint* paint) override {
|
| + const PaintFlags* paint) override {
|
| const SkMatrix& ctm = getTotalMatrix();
|
| AddImage(
|
| sk_ref_sp(image), SkRect::MakeIWH(image->width(), image->height()),
|
| @@ -91,7 +92,7 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| void onDrawImageRect(const SkImage* image,
|
| const SkRect* src,
|
| const SkRect& dst,
|
| - const SkPaint* paint,
|
| + const PaintFlags* paint,
|
| SrcRectConstraint) override {
|
| const SkMatrix& ctm = getTotalMatrix();
|
| SkRect src_storage;
|
| @@ -108,20 +109,20 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| void onDrawImageNine(const SkImage* image,
|
| const SkIRect& center,
|
| const SkRect& dst,
|
| - const SkPaint* paint) override {
|
| + const PaintFlags* paint) override {
|
| // No cc embedder issues image nine calls.
|
| NOTREACHED();
|
| }
|
|
|
| - void onDrawRect(const SkRect& r, const SkPaint& paint) override {
|
| + void onDrawRect(const SkRect& r, const PaintFlags& paint) override {
|
| AddPaintImage(r, paint);
|
| }
|
|
|
| - void onDrawPath(const SkPath& path, const SkPaint& paint) override {
|
| + void onDrawPath(const SkPath& path, const PaintFlags& paint) override {
|
| AddPaintImage(path.getBounds(), paint);
|
| }
|
|
|
| - void onDrawOval(const SkRect& r, const SkPaint& paint) override {
|
| + void onDrawOval(const SkRect& r, const PaintFlags& paint) override {
|
| AddPaintImage(r, paint);
|
| }
|
|
|
| @@ -129,33 +130,33 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| SkScalar start_angle,
|
| SkScalar sweep_angle,
|
| bool use_center,
|
| - const SkPaint& paint) override {
|
| + const PaintFlags& paint) override {
|
| AddPaintImage(r, paint);
|
| }
|
|
|
| - void onDrawRRect(const SkRRect& rr, const SkPaint& paint) override {
|
| + void onDrawRRect(const SkRRect& rr, const PaintFlags& paint) override {
|
| AddPaintImage(rr.rect(), paint);
|
| }
|
|
|
| SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override {
|
| saved_paints_.push_back(*rec.fPaint);
|
| - return SkNWayCanvas::getSaveLayerStrategy(rec);
|
| + return PaintCanvasNoDraw::getSaveLayerStrategy(rec);
|
| }
|
|
|
| void willSave() override {
|
| - saved_paints_.push_back(SkPaint());
|
| - return SkNWayCanvas::willSave();
|
| + saved_paints_.push_back(PaintFlags());
|
| + return PaintCanvasNoDraw::willSave();
|
| }
|
|
|
| void willRestore() override {
|
| DCHECK_GT(saved_paints_.size(), 0u);
|
| saved_paints_.pop_back();
|
| - SkNWayCanvas::willRestore();
|
| + PaintCanvasNoDraw::willRestore();
|
| }
|
|
|
| private:
|
| bool ComputePaintBounds(const SkRect& rect,
|
| - const SkPaint* current_paint,
|
| + const PaintFlags* current_paint,
|
| SkRect* paint_bounds) {
|
| *paint_bounds = rect;
|
| if (current_paint) {
|
| @@ -177,7 +178,7 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| const SkRect& src_rect,
|
| const SkRect& rect,
|
| const SkMatrix& matrix,
|
| - const SkPaint* paint) {
|
| + const PaintFlags* paint) {
|
| if (!image->isLazyGenerated())
|
| return;
|
|
|
| @@ -203,10 +204,10 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| SafeClampPaintRectToSize(paint_rect, canvas_size_)));
|
| }
|
|
|
| - // Currently this function only handles extracting images from SkImageShaders
|
| - // embedded in SkPaints. Other embedded image cases, such as SkPictures,
|
| + // Currently this function only handles extracting images from PaintShaders
|
| + // embedded in PaintFlags. Other embedded image cases, such as PaintRecords,
|
| // are not yet handled.
|
| - void AddPaintImage(const SkRect& rect, const SkPaint& paint) {
|
| + void AddPaintImage(const SkRect& rect, const PaintFlags& paint) {
|
| SkShader* shader = paint.getShader();
|
| if (shader) {
|
| SkMatrix matrix;
|
| @@ -226,7 +227,7 @@ class DiscardableImagesMetadataCanvas : public SkNWayCanvas {
|
| std::vector<std::pair<DrawImage, gfx::Rect>>* image_set_;
|
| const SkRect canvas_bounds_;
|
| const gfx::Size canvas_size_;
|
| - std::vector<SkPaint> saved_paints_;
|
| + std::vector<PaintFlags> saved_paints_;
|
| };
|
|
|
| } // namespace
|
| @@ -235,7 +236,7 @@ DiscardableImageMap::DiscardableImageMap() {}
|
|
|
| DiscardableImageMap::~DiscardableImageMap() {}
|
|
|
| -std::unique_ptr<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata(
|
| +std::unique_ptr<PaintCanvas> DiscardableImageMap::BeginGeneratingMetadata(
|
| const gfx::Size& bounds) {
|
| DCHECK(all_images_.empty());
|
| return base::MakeUnique<DiscardableImagesMetadataCanvas>(
|
|
|