OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkSurface.h" | 9 #include "SkSurface.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkStream.h" | 11 #include "SkStream.h" |
12 #include "SkData.h" | 12 #include "SkData.h" |
13 | 13 |
14 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
15 #include "GrContext.h" | 15 #include "GrContext.h" |
16 | |
17 namespace skiagm { | |
18 extern GrContext* GetGr(); | |
19 }; | |
20 #endif | 16 #endif |
21 | 17 |
22 static SkData* fileToData(const char path[]) { | 18 static SkData* fileToData(const char path[]) { |
23 SkFILEStream stream(path); | 19 SkFILEStream stream(path); |
24 if (!stream.isValid()) { | 20 if (!stream.isValid()) { |
25 return SkData::NewEmpty(); | 21 return SkData::NewEmpty(); |
26 } | 22 } |
27 size_t size = stream.getLength(); | 23 size_t size = stream.getLength(); |
28 void* mem = sk_malloc_throw(size); | 24 void* mem = sk_malloc_throw(size); |
29 stream.read(mem, size); | 25 stream.read(mem, size); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 182 |
187 info.fWidth = W; | 183 info.fWidth = W; |
188 info.fHeight = H; | 184 info.fHeight = H; |
189 info.fColorType = SkImage::kPMColor_ColorType; | 185 info.fColorType = SkImage::kPMColor_ColorType; |
190 info.fAlphaType = SkImage::kPremul_AlphaType; | 186 info.fAlphaType = SkImage::kPremul_AlphaType; |
191 SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer,
RB)); | 187 SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer,
RB)); |
192 SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info)); | 188 SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info)); |
193 SkAutoTUnref<SkSurface> surf2(SkSurface::NewPicture(info.fWidth, info.fH
eight)); | 189 SkAutoTUnref<SkSurface> surf2(SkSurface::NewPicture(info.fWidth, info.fH
eight)); |
194 SkAutoTUnref<SkSurface> surf3(SkSurface::NewPicture(info.fWidth, info.fH
eight)); | 190 SkAutoTUnref<SkSurface> surf3(SkSurface::NewPicture(info.fWidth, info.fH
eight)); |
195 #if SK_SUPPORT_GPU | 191 #if SK_SUPPORT_GPU |
196 GrContext* ctx = skiagm::GetGr(); | 192 GrContext* ctx = GM::GetGr(canvas); |
197 | 193 |
198 SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0)); | 194 SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0)); |
199 #endif | 195 #endif |
200 | 196 |
201 test_surface(canvas, surf0, true); | 197 test_surface(canvas, surf0, true); |
202 canvas->translate(80, 0); | 198 canvas->translate(80, 0); |
203 test_surface(canvas, surf1, true); | 199 test_surface(canvas, surf1, true); |
204 canvas->translate(80, 0); | 200 canvas->translate(80, 0); |
205 test_surface(canvas, surf2, true); | 201 test_surface(canvas, surf2, true); |
206 canvas->translate(80, 0); | 202 canvas->translate(80, 0); |
(...skipping 11 matching lines...) Expand all Loading... |
218 } | 214 } |
219 | 215 |
220 private: | 216 private: |
221 typedef skiagm::GM INHERITED; | 217 typedef skiagm::GM INHERITED; |
222 }; | 218 }; |
223 | 219 |
224 ////////////////////////////////////////////////////////////////////////////// | 220 ////////////////////////////////////////////////////////////////////////////// |
225 | 221 |
226 static skiagm::GM* MyFactory(void*) { return new ImageGM; } | 222 static skiagm::GM* MyFactory(void*) { return new ImageGM; } |
227 static skiagm::GMRegistry reg(MyFactory); | 223 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |