Index: gm/surface.cpp |
diff --git a/gm/surface.cpp b/gm/surface.cpp |
index dbcced2cbfabf4d4282fd64c85d270279cbaf383..d17c1e98dc4b2e938e509efe1a9808c5fc823c3b 100644 |
--- a/gm/surface.cpp |
+++ b/gm/surface.cpp |
@@ -105,5 +105,46 @@ protected: |
private: |
typedef GM INHERITED; |
}; |
- |
DEF_GM( return new SurfacePropsGM ) |
+ |
+ |
+class NewSurfaceGM : public skiagm::GM { |
+public: |
+ NewSurfaceGM() {} |
+ |
+protected: |
+ SkString onShortName() SK_OVERRIDE { |
+ return SkString("surfacenew"); |
+ } |
+ |
+ virtual SkISize onISize() SK_OVERRIDE { |
+ return SkISize::Make(300, 140); |
+ } |
+ |
+ static void drawInto(SkCanvas* canvas) { |
+ canvas->drawColor(SK_ColorRED); |
+ } |
+ |
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
+ SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
+ SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
+ |
+ SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props)); |
reed2
2014/11/20 01:50:58
Should just pass NULL for this props. Then we can
reed1
2014/11/20 19:00:18
Done.
|
+ if (!surf.get()) return; |
reed2
2014/11/20 01:56:54
need to call newraster, or disable pictures during
reed1
2014/11/20 19:00:19
Done.
|
+ drawInto(surf->getCanvas()); |
+ |
+ SkAutoTUnref<SkImage> image(surf->newImageSnapshot()); |
+ canvas->drawImage(image, 10, 10, NULL); |
+ |
+ SkAutoTUnref<SkSurface> surf2(image->newSurface(info, props)); |
+ drawInto(surf2->getCanvas()); |
+ |
+ SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot()); |
+ canvas->drawImage(image2, 10 + image->width() + 10, 10, NULL); |
+ } |
+ |
+private: |
+ typedef GM INHERITED; |
+}; |
+DEF_GM( return new NewSurfaceGM ) |
+ |