aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-01 21:23:07 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-01 21:23:07 +0000
commit4866cc0afb7571309d9fdecb221d919f663054c0 (patch)
tree3696433e73defaa1a3d8ec92da58b9877ba7fc91 /include
parent898e7b568f535fc62a92acda3c22a68cb6e04dcc (diff)
Adding option to serialize mutable bitmaps in SkPicture
Diffstat (limited to 'include')
-rw-r--r--include/core/SkFlattenable.h15
-rw-r--r--include/core/SkPicture.h22
2 files changed, 31 insertions, 6 deletions
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index dc115fc331..253f5710e0 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -267,15 +267,20 @@ public:
SkFactorySet* setFactoryRecorder(SkFactorySet*);
enum Flags {
- kCrossProcess_Flag = 0x01,
+ kCrossProcess_Flag = 0x01,
/**
* Instructs the writer to inline Factory names as there are seen the
* first time (after that we store an index). The pipe code uses this.
*/
- kInlineFactoryNames_Flag = 0x02
+ kInlineFactoryNames_Flag = 0x02,
+ /**
+ * Instructs the writer to always serialize bitmap pixel data.
+ */
+ kForceFlattenBitmapPixels_Flag = 0x04
};
- Flags getFlags() const { return (Flags)fFlags; }
- void setFlags(Flags flags) { fFlags = flags; }
+
+ uint32_t getFlags() const { return fFlags; }
+ void setFlags(uint32_t flags) { fFlags = flags; }
bool isCrossProcess() const {
return SkToBool(fFlags & kCrossProcess_Flag);
@@ -285,7 +290,7 @@ public:
}
bool persistBitmapPixels() const {
- return (fFlags & kCrossProcess_Flag) != 0;
+ return (fFlags & (kCrossProcess_Flag | kForceFlattenBitmapPixels_Flag)) != 0;
}
bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 47a2b9578c..21a4fcc492 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -12,6 +12,7 @@
#include "SkRefCnt.h"
+class SkBitmap;
class SkCanvas;
class SkPicturePlayback;
class SkPictureRecord;
@@ -51,7 +52,16 @@ public:
clip-query calls will reflect the path's bounds, not the actual
path.
*/
- kUsePathBoundsForClip_RecordingFlag = 0x01
+ kUsePathBoundsForClip_RecordingFlag = 0x01,
+
+ /* When a draw operation is recorded that has a bitmap parameter, it
+ may be unsafe to defer rendering if source bitmap may be written to
+ between the time of recording and the time of executing the draw
+ operation. This flag specifies that SkPicture should serialize a
+ snapshot of any source bitmaps that reside in RAM and are not
+ marked as immutable, making the draw operation safe for deferral.
+ */
+ kFlattenMutableNonTexturePixelRefs_RecordingFlag = 0x02
};
/** Returns the canvas that records the drawing commands.
@@ -74,6 +84,16 @@ public:
is drawn.
*/
void endRecording();
+
+ /** Returns true if any draw commands have been recorded since the last
+ call to beginRecording.
+ */
+ bool hasRecorded() const;
+
+ /** Returns true if a snapshot of the specified bitmap will be flattened
+ whaen a draw operation using the bitmap is recorded.
+ */
+ bool willFlattenPixelsOnRecord(const SkBitmap&) const;
/** Replays the drawing commands on the specified canvas. This internally
calls endRecording() if that has not already been called.