summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-09-12 10:27:50 +0100
committerTorne (Richard Coles) <torne@google.com>2013-09-12 10:27:50 +0100
commit425017857b2c8efbc272d8a977d5c009ac6f7ec4 (patch)
treed3aa0c50c4c4b08d550b7b95061b12545c948d2a
parentb06ac0b52028d657c8480eaa7f4c551009a8130c (diff)
parent5229287cbea7f663f0d50c0b69c1000ca0549b79 (diff)
downloadinclude-kitkat-cts-dev.tar.gz
This commit was generated by merge_to_master.py. Change-Id: I9a93eb0d6166cd1157d3e94172cea8bb27a83a42
-rw-r--r--core/SkWriter32.h4
-rw-r--r--utils/SkCanvasStateUtils.h76
-rw-r--r--utils/SkNWayCanvas.h9
3 files changed, 85 insertions, 4 deletions
diff --git a/core/SkWriter32.h b/core/SkWriter32.h
index 82cf346..b07c080 100644
--- a/core/SkWriter32.h
+++ b/core/SkWriter32.h
@@ -114,6 +114,10 @@ public:
*(SkRect*)this->reserve(sizeof(rect)) = rect;
}
+ void writeIRect(const SkIRect& rect) {
+ *(SkIRect*)this->reserve(sizeof(rect)) = rect;
+ }
+
void writeRRect(const SkRRect& rrect) {
rrect.writeToMemory(this->reserve(SkRRect::kSizeInMemory));
}
diff --git a/utils/SkCanvasStateUtils.h b/utils/SkCanvasStateUtils.h
new file mode 100644
index 0000000..f8266c9
--- /dev/null
+++ b/utils/SkCanvasStateUtils.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCanvasStateUtils_DEFINED
+#define SkCanvasStateUtils_DEFINED
+
+#include "SkCanvas.h"
+
+class SkCanvasState;
+
+/**
+ * A set of functions that are useful for copying an SkCanvas across a library
+ * boundary where the Skia libraries on either side of the boundary may not be
+ * version identical. The expected usage is outline below...
+ *
+ * Lib Boundary
+ * CaptureCanvasState(...) |||
+ * SkCanvas --> SkCanvasState |||
+ * ||| CreateFromCanvasState(...)
+ * ||| SkCanvasState --> SkCanvas`
+ * ||| Draw into SkCanvas`
+ * ||| Unref SkCanvas`
+ * ReleaseCanvasState(...) |||
+ *
+ */
+namespace SkCanvasStateUtils {
+ /**
+ * Captures the current state of the canvas into an opaque ptr that is safe
+ * to pass between different instances of Skia (which may or may not be the
+ * same version). The function will return NULL in the event that one of the
+ * following conditions are true.
+ * 1) the canvas device type is not supported (currently only raster is supported)
+ * 2) the canvas clip type is not supported (currently only non-AA clips are supported)
+ *
+ * It is recommended that the original canvas also not be used until all
+ * canvases that have been created using its captured state have been dereferenced.
+ *
+ * Finally, it is important to note that any draw filters attached to the
+ * canvas are NOT currently captured.
+ *
+ * @param canvas The canvas you wish to capture the current state of.
+ * @return NULL or an opaque ptr that can be passed to CreateFromCanvasState
+ * to reconstruct the canvas. The caller is responsible for calling
+ * ReleaseCanvasState to free the memory associated with this state.
+ */
+ SK_API SkCanvasState* CaptureCanvasState(SkCanvas* canvas);
+
+ /**
+ * Create a new SkCanvas from the captured state of another SkCanvas. The
+ * function will return NULL in the event that one of the
+ * following conditions are true.
+ * 1) the captured state is in an unrecognized format
+ * 2) the captured canvas device type is not supported
+ *
+ * @param canvas The canvas you wish to capture the current state of.
+ * @return NULL or an SkCanvas* whose devices and matrix/clip state are
+ * identical to the captured canvas. The caller is responsible for
+ * calling unref on the SkCanvas.
+ */
+ SK_API SkCanvas* CreateFromCanvasState(const SkCanvasState* state);
+
+ /**
+ * Free the memory associated with the captured canvas state. The state
+ * should not be released until all SkCanvas objects created using that
+ * state have been dereferenced.
+ *
+ * @param state The captured state you wish to dispose of.
+ */
+ SK_API void ReleaseCanvasState(SkCanvasState* state);
+};
+
+#endif
diff --git a/utils/SkNWayCanvas.h b/utils/SkNWayCanvas.h
index 5669cd0..de78f8a 100644
--- a/utils/SkNWayCanvas.h
+++ b/utils/SkNWayCanvas.h
@@ -16,9 +16,9 @@ public:
SkNWayCanvas(int width, int height);
virtual ~SkNWayCanvas();
- void addCanvas(SkCanvas*);
- void removeCanvas(SkCanvas*);
- void removeAll();
+ virtual void addCanvas(SkCanvas*);
+ virtual void removeCanvas(SkCanvas*);
+ virtual void removeAll();
///////////////////////////////////////////////////////////////////////////
// These are forwarded to the N canvases we're referencing
@@ -78,11 +78,12 @@ public:
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
virtual void endCommentGroup() SK_OVERRIDE;
-private:
+protected:
SkTDArray<SkCanvas*> fList;
class Iter;
+private:
typedef SkCanvas INHERITED;
};