Index: src/core/SkSpecialSurface.h |
diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4ff1d4eb5b3b0bc8d4b5c0428adccfea8c51b209 |
--- /dev/null |
+++ b/src/core/SkSpecialSurface.h |
@@ -0,0 +1,76 @@ |
+/* |
+ * Copyright 2016 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file |
+ */ |
+ |
+#ifndef SkSpecialSurface_DEFINED |
+#define SkSpecialSurface_DEFINED |
+ |
+#include "SkRefCnt.h" |
+#include "SkSurfaceProps.h" |
+ |
+class GrContext; |
+struct GrSurfaceDesc; |
+class SkCanvas; |
+struct SkImageInfo; |
+class SkSpecialImage; |
+ |
+/** |
+ * SkSpecialSurface is a restricted form of SkSurface solely for internal use. It differs |
+ * from SkSurface in that: |
+ * - it can be backed by GrTextures larger than [ fWidth, fHeight ] |
+ * - it can't be used for tiling |
+ * - it becomes inactive once a snapshot of it is taken (i.e., no copy-on-write) |
+ * - it has no generation ID |
+ */ |
+class SkSpecialSurface : public SkRefCnt { |
+public: |
+ const SkSurfaceProps& props() const { return fProps; } |
+ int width() const { return fWidth; } |
+ int height() const { return fHeight; } |
+ |
+ /** |
+ * Return a canvas that will draw into this surface. This will always |
+ * return the same canvas for a given surface, and is managed/owned by the |
+ * surface. |
+ * |
+ * The canvas will be invalid after 'newImageSnapshot' is called. |
+ */ |
+ SkCanvas* getCanvas(); |
+ |
+ /** |
+ * Returns an image of the current state of the surface pixels up to this |
+ * point. The canvas returned by 'getCanvas' becomes invalidated by this |
+ * call and no more drawing to this surface is allowed. |
+ */ |
+ SkSpecialImage* newImageSnapshot(); |
+ |
+ /** |
+ * Allocate a new GPU-backed SkSpecialSurface. If the requested surface cannot |
+ * be created, nullptr will be returned. |
+ */ |
+ static SkSpecialSurface* New(GrContext*, const GrSurfaceDesc&, const SkSurfaceProps* = nullptr); |
reed1
2016/01/14 13:52:55
I suggest we make the names back-end specific, jus
robertphillips
2016/01/14 19:58:55
Done.
|
+ |
+ /** |
+ * Return a new CPU-backed surface, with the memory for the pixels automatically |
+ * allocated. |
+ * |
+ * If the requested surface cannot be created, or the request is not a |
+ * supported configuration, nullptr will be returned. |
+ */ |
+ static SkSpecialSurface* New(const SkImageInfo&, const SkSurfaceProps* = nullptr); |
+ |
+protected: |
+ SkSpecialSurface(int width, int height, const SkSurfaceProps*); |
+ |
+private: |
+ const SkSurfaceProps fProps; |
+ const int fWidth; |
+ const int fHeight; |
+ |
+ typedef SkRefCnt INHERITED; |
+}; |
+ |
+#endif |