diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-28 12:19:02 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-28 12:19:02 +0000 |
commit | 97af1a64ae6bdddd346d8babfd9f188279dd6644 (patch) | |
tree | 00ed8f9919b9f2623b4d08e33ef61f80018d6eb4 /gm | |
parent | 91ee3a11ed476f4f08e1e4ae183002c56349ec19 (diff) |
Add caching of the snapshot image form a surface
Notify the surface when the canvas draws into it, so it can invalidate the
cached image, and (if needed) perform a copy-on-write on the surface if it
was being shared with the image.
Review URL: https://codereview.appspot.com/6441115
git-svn-id: http://skia.googlecode.com/svn/trunk@5306 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/image.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gm/image.cpp b/gm/image.cpp index 4ee90a4fc6..21286db731 100644 --- a/gm/image.cpp +++ b/gm/image.cpp @@ -11,6 +11,8 @@ #include "SkStream.h" #include "SkData.h" +extern GrContext* GetGr(); + static SkData* fileToData(const char path[]) { SkFILEStream stream(path); if (!stream.isValid()) { @@ -57,9 +59,18 @@ static void test_surface(SkCanvas* canvas, SkSurface* surf) { drawContents(surf, SK_ColorRED); SkImage* imgR = surf->newImageShapshot(); + if (true) { + SkImage* imgR2 = surf->newImageShapshot(); + SkASSERT(imgR == imgR2); + imgR2->unref(); + } + drawContents(surf, SK_ColorGREEN); SkImage* imgG = surf->newImageShapshot(); + // since we've drawn after we snapped imgR, imgG will be a different obj + SkASSERT(imgR != imgG); + drawContents(surf, SK_ColorBLUE); SkPaint paint; @@ -130,6 +141,10 @@ protected: test_surface(canvas, surf2); } + virtual uint32_t onGetFlags() const SK_OVERRIDE { + return GM::kSkipPicture_Flag; + } + private: typedef skiagm::GM INHERITED; }; |