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

Unified Diff: cc/paint/record_paint_canvas.h

Issue 2768143002: Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: more const casting 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
« no previous file with comments | « cc/paint/paint_recorder.cc ('k') | cc/paint/record_paint_canvas.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 76%
copy from cc/paint/skia_paint_canvas.h
copy to cc/paint/record_paint_canvas.h
index 8e016f0db5159c5066023d3ad92c294fefad20a9..4677512a9b88ec26ac1ab713df85e9c075a4d37e 100644
--- a/cc/paint/skia_paint_canvas.h
+++ b/cc/paint/record_paint_canvas.h
@@ -2,36 +2,30 @@
// 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>
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/optional.h"
#include "build/build_config.h"
#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);
+ ~RecordPaintCanvas() override;
SkMetaData& getMetaData() override;
SkImageInfo imageInfo() const override;
@@ -40,7 +34,7 @@ class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas {
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;
@@ -51,11 +45,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;
@@ -144,12 +136,24 @@ class CC_PAINT_EXPORT SkiaPaintCanvas final : public PaintCanvas {
using PaintCanvas::drawPicture;
private:
- SkCanvas* canvas_;
- std::unique_ptr<SkCanvas> owned_;
-
- DISALLOW_COPY_AND_ASSIGN(SkiaPaintCanvas);
+ const SkNoDrawCanvas* GetCanvas() const;
+ SkNoDrawCanvas* GetCanvas();
+
+ 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.
+ //
+ // This is mutable so that const functions (e.g. quickReject) that may
+ // lazy initialize the canvas can still be const.
+ mutable base::Optional<SkNoDrawCanvas> canvas_;
+
+ DISALLOW_COPY_AND_ASSIGN(RecordPaintCanvas);
};
} // namespace cc
-#endif // CC_PAINT_SKIA_PAINT_CANVAS_H_
+#endif // CC_PAINT_RECORD_PAINT_CANVAS_H_
« no previous file with comments | « cc/paint/paint_recorder.cc ('k') | cc/paint/record_paint_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698