Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
| 10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 y += H; | 98 y += H; |
| 99 } | 99 } |
| 100 x += W; | 100 x += W; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 typedef GM INHERITED; | 106 typedef GM INHERITED; |
| 107 }; | 107 }; |
| 108 DEF_GM( return new SurfacePropsGM ) | |
| 108 | 109 |
| 109 DEF_GM( return new SurfacePropsGM ) | 110 |
| 111 class NewSurfaceGM : public skiagm::GM { | |
| 112 public: | |
| 113 NewSurfaceGM() {} | |
| 114 | |
| 115 protected: | |
| 116 SkString onShortName() SK_OVERRIDE { | |
| 117 return SkString("surfacenew"); | |
| 118 } | |
| 119 | |
| 120 virtual SkISize onISize() SK_OVERRIDE { | |
| 121 return SkISize::Make(300, 140); | |
| 122 } | |
| 123 | |
| 124 static void drawInto(SkCanvas* canvas) { | |
| 125 canvas->drawColor(SK_ColorRED); | |
| 126 } | |
| 127 | |
| 128 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | |
| 129 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | |
| 130 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | |
| 131 | |
| 132 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.
| |
| 133 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.
| |
| 134 drawInto(surf->getCanvas()); | |
| 135 | |
| 136 SkAutoTUnref<SkImage> image(surf->newImageSnapshot()); | |
| 137 canvas->drawImage(image, 10, 10, NULL); | |
| 138 | |
| 139 SkAutoTUnref<SkSurface> surf2(image->newSurface(info, props)); | |
| 140 drawInto(surf2->getCanvas()); | |
| 141 | |
| 142 SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot()); | |
| 143 canvas->drawImage(image2, 10 + image->width() + 10, 10, NULL); | |
| 144 } | |
| 145 | |
| 146 private: | |
| 147 typedef GM INHERITED; | |
| 148 }; | |
| 149 DEF_GM( return new NewSurfaceGM ) | |
| 150 | |
| OLD | NEW |