Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Unified Diff: cc/paint/record_paint_canvas.h

Issue 2768143002: Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: Remove unneeded expectation Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/paint/record_paint_canvas.h
diff --git a/cc/paint/skia_paint_canvas.h b/cc/paint/record_paint_canvas.h
similarity index 80%
copy from cc/paint/skia_paint_canvas.h
copy to cc/paint/record_paint_canvas.h
index 669ca9b3e0b71ef7c44b7b73ca0565be3c7112b7..e39697ce82f44ab06930cc7aac6082babee22d4b 100644
--- a/cc/paint/skia_paint_canvas.h
+++ b/cc/paint/record_paint_canvas.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CC_PAINT_SKIA_PAINT_CANVAS_H_
-#define CC_PAINT_SKIA_PAINT_CANVAS_H_
+#ifndef CC_PAINT_RECORD_PAINT_CANVAS_H_
+#define CC_PAINT_RECORD_PAINT_CANVAS_H_
#include <memory>
@@ -14,24 +14,17 @@
#include "cc/paint/paint_canvas.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_record.h"
-#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/utils/SkNoDrawCanvas.h"
namespace cc {
+class PaintOpBuffer;
class PaintFlags;
-// A PaintCanvas derived class that passes PaintCanvas APIs through to
-// an SkCanvas. This is more efficient than recording to a PaintRecord
-// and then playing back to an SkCanvas.
-class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas {
+class CC_PAINT_EXPORT RecordPaintCanvas final : public PaintCanvas {
public:
- explicit SkiaPaintCanvas(SkCanvas* canvas);
- explicit SkiaPaintCanvas(const SkBitmap& bitmap);
- explicit SkiaPaintCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
- explicit SkiaPaintCanvas(SkiaPaintCanvas&& other);
- ~SkiaPaintCanvas() override;
-
- SkiaPaintCanvas& operator=(SkiaPaintCanvas&& other) = default;
+ explicit RecordPaintCanvas(PaintOpBuffer* buffer, const SkRect& cull_rect);
+ ~RecordPaintCanvas() override;
SkMetaData& getMetaData() override;
SkImageInfo imageInfo() const override;
@@ -46,7 +39,7 @@ class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas {
int y) override;
int save() override;
int saveLayer(const SkRect* bounds, const PaintFlags* flags) override;
- int saveLayerAlpha(const SkRect* bounds, U8CPU alpha) override;
+ int saveLayerAlpha(const SkRect* bounds, uint8_t alpha) override;
void restore() override;
int getSaveCount() const override;
@@ -57,11 +50,9 @@ class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas {
void concat(const SkMatrix& matrix) override;
void setMatrix(const SkMatrix& matrix) override;
- void clipRect(const SkRect& rect, SkClipOp op, bool do_anti_alias) override;
- void clipRRect(const SkRRect& rrect,
- SkClipOp op,
- bool do_anti_alias) override;
- void clipPath(const SkPath& path, SkClipOp op, bool do_anti_alias) override;
+ void clipRect(const SkRect& rect, SkClipOp op, bool antialias) override;
+ void clipRRect(const SkRRect& rrect, SkClipOp op, bool antialias) override;
+ void clipPath(const SkPath& path, SkClipOp op, bool antialias) override;
bool quickReject(const SkRect& rect) const override;
bool quickReject(const SkPath& path) const override;
SkRect getLocalClipBounds() const override;
@@ -154,12 +145,16 @@ class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas {
using PaintCanvas::drawPicture;
private:
- SkCanvas* canvas_;
- std::unique_ptr<SkCanvas> owned_;
-
- DISALLOW_COPY_AND_ASSIGN(SkiaPaintCanvas);
+ PaintOpBuffer* buffer_;
+
+ // TODO(enne): Although RecordPaintCanvas is mostly a write-only interface
+ // where paint commands are stored, occasionally users of PaintCanvas want
+ // to ask stateful questions mid-stream of clip and transform state.
+ // To avoid duplicating all this code (for now?), just forward to an SkCanvas
+ // that's not backed by anything but can answer these questions.
+ SkNoDrawCanvas canvas_;
};
} // namespace cc
-#endif // CC_PAINT_SKIA_PAINT_CANVAS_H_
+#endif // CC_PAINT_RECORD_PAINT_CANVAS_H_

Powered by Google App Engine
This is Rietveld 408576698