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 #include "GrUtils.h" |
16 #endif | 17 #endif |
17 | 18 |
18 static SkData* fileToData(const char path[]) { | 19 static SkData* fileToData(const char path[]) { |
19 SkFILEStream stream(path); | 20 SkFILEStream stream(path); |
20 if (!stream.isValid()) { | 21 if (!stream.isValid()) { |
21 return SkData::NewEmpty(); | 22 return SkData::NewEmpty(); |
22 } | 23 } |
23 size_t size = stream.getLength(); | 24 size_t size = stream.getLength(); |
24 void* mem = sk_malloc_throw(size); | 25 void* mem = sk_malloc_throw(size); |
25 stream.read(mem, size); | 26 stream.read(mem, size); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 sk_bzero(fBuffer, fBufferSize); | 180 sk_bzero(fBuffer, fBufferSize); |
180 | 181 |
181 SkImageInfo info = { | 182 SkImageInfo info = { |
182 W, H, kPMColor_SkColorType, kPremul_SkAlphaType | 183 W, H, kPMColor_SkColorType, kPremul_SkAlphaType |
183 }; | 184 }; |
184 SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer,
RB)); | 185 SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer,
RB)); |
185 SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info)); | 186 SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info)); |
186 SkAutoTUnref<SkSurface> surf2(SkSurface::NewPicture(info.fWidth, info.fH
eight)); | 187 SkAutoTUnref<SkSurface> surf2(SkSurface::NewPicture(info.fWidth, info.fH
eight)); |
187 SkAutoTUnref<SkSurface> surf3(SkSurface::NewPicture(info.fWidth, info.fH
eight)); | 188 SkAutoTUnref<SkSurface> surf3(SkSurface::NewPicture(info.fWidth, info.fH
eight)); |
188 #if SK_SUPPORT_GPU | 189 #if SK_SUPPORT_GPU |
189 GrContext* ctx = GM::GetGr(canvas); | 190 GrContext* ctx = GrUtils::GetGr(canvas); |
190 | 191 |
191 SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0)); | 192 SkAutoTUnref<SkSurface> surf4(SkSurface::NewRenderTarget(ctx, info, 0)); |
192 #endif | 193 #endif |
193 | 194 |
194 test_surface(canvas, surf0, true); | 195 test_surface(canvas, surf0, true); |
195 canvas->translate(80, 0); | 196 canvas->translate(80, 0); |
196 test_surface(canvas, surf1, true); | 197 test_surface(canvas, surf1, true); |
197 canvas->translate(80, 0); | 198 canvas->translate(80, 0); |
198 test_surface(canvas, surf2, true); | 199 test_surface(canvas, surf2, true); |
199 canvas->translate(80, 0); | 200 canvas->translate(80, 0); |
(...skipping 11 matching lines...) Expand all Loading... |
211 } | 212 } |
212 | 213 |
213 private: | 214 private: |
214 typedef skiagm::GM INHERITED; | 215 typedef skiagm::GM INHERITED; |
215 }; | 216 }; |
216 | 217 |
217 ////////////////////////////////////////////////////////////////////////////// | 218 ////////////////////////////////////////////////////////////////////////////// |
218 | 219 |
219 static skiagm::GM* MyFactory(void*) { return new ImageGM; } | 220 static skiagm::GM* MyFactory(void*) { return new ImageGM; } |
220 static skiagm::GMRegistry reg(MyFactory); | 221 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |