OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "BenchTimer.h" | 10 #include "BenchTimer.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return false; | 192 return false; |
193 } | 193 } |
194 | 194 |
195 enum Backend { | 195 enum Backend { |
196 kNonRendering_Backend, | 196 kNonRendering_Backend, |
197 kRaster_Backend, | 197 kRaster_Backend, |
198 kGPU_Backend, | 198 kGPU_Backend, |
199 kPDF_Backend, | 199 kPDF_Backend, |
200 }; | 200 }; |
201 | 201 |
202 static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size, | 202 static SkBaseDevice* make_device(SkBitmap::Config config, const SkIPoint& size, |
203 Backend backend, int sampleCount, GrContext* contex
t) { | 203 Backend backend, int sampleCount, GrContext* co
ntext) { |
204 SkDevice* device = NULL; | 204 SkBaseDevice* device = NULL; |
205 SkBitmap bitmap; | 205 SkBitmap bitmap; |
206 bitmap.setConfig(config, size.fX, size.fY); | 206 bitmap.setConfig(config, size.fX, size.fY); |
207 | 207 |
208 switch (backend) { | 208 switch (backend) { |
209 case kRaster_Backend: | 209 case kRaster_Backend: |
210 bitmap.allocPixels(); | 210 bitmap.allocPixels(); |
211 erase(bitmap); | 211 erase(bitmap); |
212 device = SkNEW_ARGS(SkDevice, (bitmap)); | 212 device = SkNEW_ARGS(SkBitmapDevice, (bitmap)); |
213 break; | 213 break; |
214 #if SK_SUPPORT_GPU | 214 #if SK_SUPPORT_GPU |
215 case kGPU_Backend: { | 215 case kGPU_Backend: { |
216 GrTextureDesc desc; | 216 GrTextureDesc desc; |
217 desc.fConfig = kSkia8888_GrPixelConfig; | 217 desc.fConfig = kSkia8888_GrPixelConfig; |
218 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 218 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
219 desc.fWidth = size.fX; | 219 desc.fWidth = size.fX; |
220 desc.fHeight = size.fY; | 220 desc.fHeight = size.fY; |
221 desc.fSampleCnt = sampleCount; | 221 desc.fSampleCnt = sampleCount; |
222 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc,
NULL, 0)); | 222 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc,
NULL, 0)); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 #if SK_SUPPORT_GPU | 773 #if SK_SUPPORT_GPU |
774 SkGLContextHelper* glContext = NULL; | 774 SkGLContextHelper* glContext = NULL; |
775 if (kGPU_Backend == backend) { | 775 if (kGPU_Backend == backend) { |
776 context = gContextFactory.get(gConfigs[configIndex].fContextType
); | 776 context = gContextFactory.get(gConfigs[configIndex].fContextType
); |
777 if (NULL == context) { | 777 if (NULL == context) { |
778 continue; | 778 continue; |
779 } | 779 } |
780 glContext = gContextFactory.getGLContext(gConfigs[configIndex].f
ContextType); | 780 glContext = gContextFactory.getGLContext(gConfigs[configIndex].f
ContextType); |
781 } | 781 } |
782 #endif | 782 #endif |
783 SkDevice* device = NULL; | 783 SkBaseDevice* device = NULL; |
784 SkCanvas* canvas = NULL; | 784 SkCanvas* canvas = NULL; |
785 SkPicture pictureRecordFrom; | 785 SkPicture pictureRecordFrom; |
786 SkPicture pictureRecordTo; | 786 SkPicture pictureRecordTo; |
787 | 787 |
788 if (kNonRendering_Backend != backend) { | 788 if (kNonRendering_Backend != backend) { |
789 device = make_device(outConfig, dim, backend, sampleCount, conte
xt); | 789 device = make_device(outConfig, dim, backend, sampleCount, conte
xt); |
790 if (NULL == device) { | 790 if (NULL == device) { |
791 SkString error; | 791 SkString error; |
792 error.printf("Device creation failure for config %s. Will sk
ip.\n", configName); | 792 error.printf("Device creation failure for config %s. Will sk
ip.\n", configName); |
793 logger.logError(error.c_str()); | 793 logger.logError(error.c_str()); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 } | 970 } |
971 | 971 |
972 return 0; | 972 return 0; |
973 } | 973 } |
974 | 974 |
975 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 975 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
976 int main(int argc, char * const argv[]) { | 976 int main(int argc, char * const argv[]) { |
977 return tool_main(argc, (char**) argv); | 977 return tool_main(argc, (char**) argv); |
978 } | 978 } |
979 #endif | 979 #endif |
OLD | NEW |