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

Unified Diff: cc/paint/paint_surface.h

Issue 2690583002: Make cc/paint have concrete types (Closed)
Patch Set: PaintRecord as typedef, fixup playback calls Created 3 years, 9 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_shader.h ('k') | cc/paint/paint_surface.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/paint/paint_surface.h
diff --git a/cc/paint/paint_surface.h b/cc/paint/paint_surface.h
index 34165bf16ed70e74bd47550cc18e707eaef97488..471901732aab3fb200855256587ee0b1c9327fb1 100644
--- a/cc/paint/paint_surface.h
+++ b/cc/paint/paint_surface.h
@@ -5,10 +5,55 @@
#ifndef CC_PAINT_PAINT_SURFACE_H_
#define CC_PAINT_PAINT_SURFACE_H_
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+#include "base/optional.h"
+#include "cc/paint/paint_canvas.h"
+#include "cc/paint/paint_export.h"
#include "third_party/skia/include/core/SkSurface.h"
namespace cc {
-using PaintSurface = SkSurface;
-}
+
+class CC_PAINT_EXPORT PaintSurface : public SkRefCntBase {
+ public:
+ explicit PaintSurface(sk_sp<SkSurface> surface);
+ ~PaintSurface() override;
+
+ // TODO(enne): this interface matches SkSurface for simplicity.
+ // However, this should really be changed to make the SkSurface ctor
+ // public and have that be the only constructor. This will also
+ // clean up a bunch of code where there's an SkSurface and a PaintCanvas,
+ // such as for canvas in Blink.
+ static sk_sp<PaintSurface> MakeRaster(const SkImageInfo& info,
+ const SkSurfaceProps* props = nullptr) {
+ sk_sp<SkSurface> s = SkSurface::MakeRaster(info, props);
+ return sk_make_sp<PaintSurface>(std::move(s));
+ }
+ static sk_sp<PaintSurface> MakeRasterN32Premul(
+ int width,
+ int height,
+ const SkSurfaceProps* props = nullptr) {
+ sk_sp<SkSurface> s = SkSurface::MakeRasterN32Premul(width, height, props);
+ return sk_make_sp<PaintSurface>(std::move(s));
+ }
+
+ int width() const { return surface_->width(); }
+ int height() const { return surface_->height(); }
+ uint32_t generationID() { return surface_->generationID(); }
+
+ PaintCanvas* getCanvas() {
+ if (!canvas_.has_value())
+ canvas_.emplace(surface_->getCanvas());
+ return &canvas_.value();
+ }
+
+ private:
+ const sk_sp<SkSurface> surface_;
+ base::Optional<PaintCanvas> canvas_;
+
+ DISALLOW_COPY_AND_ASSIGN(PaintSurface);
+};
+
+} // namespace cc
#endif // CC_PAINT_PAINT_SURFACE_H_
« no previous file with comments | « cc/paint/paint_shader.h ('k') | cc/paint/paint_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698