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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 return false; | 186 return false; |
187 } | 187 } |
188 | 188 |
189 enum Backend { | 189 enum Backend { |
190 kNonRendering_Backend, | 190 kNonRendering_Backend, |
191 kRaster_Backend, | 191 kRaster_Backend, |
192 kGPU_Backend, | 192 kGPU_Backend, |
193 kPDF_Backend, | 193 kPDF_Backend, |
194 }; | 194 }; |
195 | 195 |
196 static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size, | 196 static SkBaseDevice* make_device(SkBitmap::Config config, const SkIPoint& size, |
197 Backend backend, int sampleCount, GrContext* contex
t) { | 197 Backend backend, int sampleCount, GrContext* co
ntext) { |
198 SkDevice* device = NULL; | 198 SkBaseDevice* device = NULL; |
199 SkBitmap bitmap; | 199 SkBitmap bitmap; |
200 bitmap.setConfig(config, size.fX, size.fY); | 200 bitmap.setConfig(config, size.fX, size.fY); |
201 | 201 |
202 switch (backend) { | 202 switch (backend) { |
203 case kRaster_Backend: | 203 case kRaster_Backend: |
204 bitmap.allocPixels(); | 204 bitmap.allocPixels(); |
205 erase(bitmap); | 205 erase(bitmap); |
206 device = SkNEW_ARGS(SkDevice, (bitmap)); | 206 device = SkNEW_ARGS(SkBitmapDevice, (bitmap)); |
207 break; | 207 break; |
208 #if SK_SUPPORT_GPU | 208 #if SK_SUPPORT_GPU |
209 case kGPU_Backend: { | 209 case kGPU_Backend: { |
210 GrTextureDesc desc; | 210 GrTextureDesc desc; |
211 desc.fConfig = kSkia8888_GrPixelConfig; | 211 desc.fConfig = kSkia8888_GrPixelConfig; |
212 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 212 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
213 desc.fWidth = size.fX; | 213 desc.fWidth = size.fX; |
214 desc.fHeight = size.fY; | 214 desc.fHeight = size.fY; |
215 desc.fSampleCnt = sampleCount; | 215 desc.fSampleCnt = sampleCount; |
216 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc,
NULL, 0)); | 216 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc,
NULL, 0)); |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 #if SK_SUPPORT_GPU | 769 #if SK_SUPPORT_GPU |
770 SkGLContextHelper* glContext = NULL; | 770 SkGLContextHelper* glContext = NULL; |
771 if (kGPU_Backend == backend) { | 771 if (kGPU_Backend == backend) { |
772 context = gContextFactory.get(gConfigs[configIndex].fContextType
); | 772 context = gContextFactory.get(gConfigs[configIndex].fContextType
); |
773 if (NULL == context) { | 773 if (NULL == context) { |
774 continue; | 774 continue; |
775 } | 775 } |
776 glContext = gContextFactory.getGLContext(gConfigs[configIndex].f
ContextType); | 776 glContext = gContextFactory.getGLContext(gConfigs[configIndex].f
ContextType); |
777 } | 777 } |
778 #endif | 778 #endif |
779 SkDevice* device = NULL; | 779 SkBaseDevice* device = NULL; |
780 SkCanvas* canvas = NULL; | 780 SkCanvas* canvas = NULL; |
781 SkPicture pictureRecordFrom; | 781 SkPicture pictureRecordFrom; |
782 SkPicture pictureRecordTo; | 782 SkPicture pictureRecordTo; |
783 | 783 |
784 if (kNonRendering_Backend != backend) { | 784 if (kNonRendering_Backend != backend) { |
785 device = make_device(outConfig, dim, backend, sampleCount, conte
xt); | 785 device = make_device(outConfig, dim, backend, sampleCount, conte
xt); |
786 if (NULL == device) { | 786 if (NULL == device) { |
787 SkString error; | 787 SkString error; |
788 error.printf("Device creation failure for config %s. Will sk
ip.\n", configName); | 788 error.printf("Device creation failure for config %s. Will sk
ip.\n", configName); |
789 logger.logError(error.c_str()); | 789 logger.logError(error.c_str()); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 966 } |
967 | 967 |
968 return 0; | 968 return 0; |
969 } | 969 } |
970 | 970 |
971 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 971 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
972 int main(int argc, char * const argv[]) { | 972 int main(int argc, char * const argv[]) { |
973 return tool_main(argc, (char**) argv); | 973 return tool_main(argc, (char**) argv); |
974 } | 974 } |
975 #endif | 975 #endif |
OLD | NEW |