| 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 "SampleApp.h" | 8 #include "SampleApp.h" | 
| 9 | 9 | 
| 10 #include "OverView.h" | 10 #include "OverView.h" | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 181 | 181 | 
| 182         fBackend = kNone_BackEndType; | 182         fBackend = kNone_BackEndType; | 
| 183 | 183 | 
| 184 #if SK_SUPPORT_GPU | 184 #if SK_SUPPORT_GPU | 
| 185         switch (win->getDeviceType()) { | 185         switch (win->getDeviceType()) { | 
| 186             case kRaster_DeviceType: | 186             case kRaster_DeviceType: | 
| 187                 // fallthrough | 187                 // fallthrough | 
| 188             case kPicture_DeviceType: | 188             case kPicture_DeviceType: | 
| 189                 // fallthrough | 189                 // fallthrough | 
| 190             case kGPU_DeviceType: | 190             case kGPU_DeviceType: | 
| 191                 // fallthrough |  | 
| 192             case kNullGPU_DeviceType: |  | 
| 193                 // all these guys use the native backend | 191                 // all these guys use the native backend | 
| 194                 fBackend = kNativeGL_BackEndType; | 192                 fBackend = kNativeGL_BackEndType; | 
| 195                 break; | 193                 break; | 
| 196 #if SK_ANGLE | 194 #if SK_ANGLE | 
| 197             case kANGLE_DeviceType: | 195             case kANGLE_DeviceType: | 
| 198                 // ANGLE is really the only odd man out | 196                 // ANGLE is really the only odd man out | 
| 199                 fBackend = kANGLE_BackEndType; | 197                 fBackend = kANGLE_BackEndType; | 
| 200                 break; | 198                 break; | 
| 201 #endif // SK_ANGLE | 199 #endif // SK_ANGLE | 
| 202             default: | 200             default: | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 220                 // fallthrough | 218                 // fallthrough | 
| 221             case kGPU_DeviceType: | 219             case kGPU_DeviceType: | 
| 222                 // all these guys use the native interface | 220                 // all these guys use the native interface | 
| 223                 glInterface.reset(GrGLCreateNativeInterface()); | 221                 glInterface.reset(GrGLCreateNativeInterface()); | 
| 224                 break; | 222                 break; | 
| 225 #if SK_ANGLE | 223 #if SK_ANGLE | 
| 226             case kANGLE_DeviceType: | 224             case kANGLE_DeviceType: | 
| 227                 glInterface.reset(GrGLCreateANGLEInterface()); | 225                 glInterface.reset(GrGLCreateANGLEInterface()); | 
| 228                 break; | 226                 break; | 
| 229 #endif // SK_ANGLE | 227 #endif // SK_ANGLE | 
| 230             case kNullGPU_DeviceType: |  | 
| 231                 glInterface.reset(GrGLCreateNullInterface()); |  | 
| 232                 break; |  | 
| 233             default: | 228             default: | 
| 234                 SkASSERT(false); | 229                 SkASSERT(false); | 
| 235                 break; | 230                 break; | 
| 236         } | 231         } | 
| 237 | 232 | 
| 238         // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t
      ype that is skipped | 233         // Currently SampleApp does not use NVPR. TODO: Provide an NVPR device t
      ype that is skipped | 
| 239         // when the driver doesn't support NVPR. | 234         // when the driver doesn't support NVPR. | 
| 240         fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get()); | 235         fCurIntf = GrGLInterfaceRemoveNVPR(glInterface.get()); | 
| 241 | 236 | 
| 242         SkASSERT(NULL == fCurContext); | 237         SkASSERT(NULL == fCurContext); | 
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 673 } | 668 } | 
| 674 | 669 | 
| 675 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType
       ct) { | 670 static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType
       ct) { | 
| 676     static const SampleWindow::DeviceType gCT[] = { | 671     static const SampleWindow::DeviceType gCT[] = { | 
| 677         SampleWindow::kPicture_DeviceType, | 672         SampleWindow::kPicture_DeviceType, | 
| 678 #if SK_SUPPORT_GPU | 673 #if SK_SUPPORT_GPU | 
| 679         SampleWindow::kGPU_DeviceType, | 674         SampleWindow::kGPU_DeviceType, | 
| 680 #if SK_ANGLE | 675 #if SK_ANGLE | 
| 681         SampleWindow::kANGLE_DeviceType, | 676         SampleWindow::kANGLE_DeviceType, | 
| 682 #endif // SK_ANGLE | 677 #endif // SK_ANGLE | 
| 683         SampleWindow::kRaster_DeviceType, // skip the null gpu device in normal 
      cycling |  | 
| 684 #endif // SK_SUPPORT_GPU | 678 #endif // SK_SUPPORT_GPU | 
| 685         SampleWindow::kRaster_DeviceType | 679         SampleWindow::kRaster_DeviceType | 
| 686     }; | 680     }; | 
| 687     SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, array
      _size_mismatch); | 681     SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, array
      _size_mismatch); | 
| 688     return gCT[ct]; | 682     return gCT[ct]; | 
| 689 } | 683 } | 
| 690 | 684 | 
| 691 static SkString getSampleTitle(const SkViewFactory* sampleFactory) { | 685 static SkString getSampleTitle(const SkViewFactory* sampleFactory) { | 
| 692     SkView* view = (*sampleFactory)(); | 686     SkView* view = (*sampleFactory)(); | 
| 693     SkString title; | 687     SkString title; | 
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1251         } | 1245         } | 
| 1252         name.append(".pdf"); | 1246         name.append(".pdf"); | 
| 1253 #ifdef SK_BUILD_FOR_ANDROID | 1247 #ifdef SK_BUILD_FOR_ANDROID | 
| 1254         name.prepend("/sdcard/"); | 1248         name.prepend("/sdcard/"); | 
| 1255 #endif | 1249 #endif | 
| 1256         fPDFDocument.reset(SkDocument::CreatePDF(name.c_str())); | 1250         fPDFDocument.reset(SkDocument::CreatePDF(name.c_str())); | 
| 1257         canvas = fPDFDocument->beginPage(this->width(), this->height()); | 1251         canvas = fPDFDocument->beginPage(this->width(), this->height()); | 
| 1258     } else if (kPicture_DeviceType == fDeviceType) { | 1252     } else if (kPicture_DeviceType == fDeviceType) { | 
| 1259         canvas = fRecorder.beginRecording(9999, 9999, NULL, 0); | 1253         canvas = fRecorder.beginRecording(9999, 9999, NULL, 0); | 
| 1260     } else { | 1254     } else { | 
| 1261 #if SK_SUPPORT_GPU | 1255         canvas = this->INHERITED::beforeChildren(canvas); | 
| 1262         if (kNullGPU_DeviceType != fDeviceType) |  | 
| 1263 #endif |  | 
| 1264         { |  | 
| 1265             canvas = this->INHERITED::beforeChildren(canvas); |  | 
| 1266         } |  | 
| 1267     } | 1256     } | 
| 1268 | 1257 | 
| 1269     if (fUseClip) { | 1258     if (fUseClip) { | 
| 1270         canvas->drawColor(0xFFFF88FF); | 1259         canvas->drawColor(0xFFFF88FF); | 
| 1271         canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true); | 1260         canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true); | 
| 1272     } | 1261     } | 
| 1273 | 1262 | 
| 1274     return canvas; | 1263     return canvas; | 
| 1275 } | 1264 } | 
| 1276 #include "SkMultiPictureDraw.h" | 1265 #include "SkMultiPictureDraw.h" | 
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1717             fRotate = !fRotate; | 1706             fRotate = !fRotate; | 
| 1718             this->inval(NULL); | 1707             this->inval(NULL); | 
| 1719             this->updateTitle(); | 1708             this->updateTitle(); | 
| 1720             return true; | 1709             return true; | 
| 1721         case 'k': | 1710         case 'k': | 
| 1722             fPerspAnim = !fPerspAnim; | 1711             fPerspAnim = !fPerspAnim; | 
| 1723             this->inval(NULL); | 1712             this->inval(NULL); | 
| 1724             this->updateTitle(); | 1713             this->updateTitle(); | 
| 1725             return true; | 1714             return true; | 
| 1726 #if SK_SUPPORT_GPU | 1715 #if SK_SUPPORT_GPU | 
| 1727         case '\\': |  | 
| 1728             this->setDeviceType(kNullGPU_DeviceType); |  | 
| 1729             this->inval(NULL); |  | 
| 1730             this->updateTitle(); |  | 
| 1731             return true; |  | 
| 1732         case 'p': | 1716         case 'p': | 
| 1733             { | 1717             { | 
| 1734                 GrContext* grContext = this->getGrContext(); | 1718                 GrContext* grContext = this->getGrContext(); | 
| 1735                 if (grContext) { | 1719                 if (grContext) { | 
| 1736                     size_t cacheBytes; | 1720                     size_t cacheBytes; | 
| 1737                     grContext->getResourceCacheUsage(NULL, &cacheBytes); | 1721                     grContext->getResourceCacheUsage(NULL, &cacheBytes); | 
| 1738                     grContext->freeGpuResources(); | 1722                     grContext->freeGpuResources(); | 
| 1739                     SkDebugf("Purged %d bytes from the GPU resource cache.\n", c
      acheBytes); | 1723                     SkDebugf("Purged %d bytes from the GPU resource cache.\n", c
      acheBytes); | 
| 1740                 } | 1724                 } | 
| 1741             } | 1725             } | 
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1954 } | 1938 } | 
| 1955 | 1939 | 
| 1956 static const char* gDeviceTypePrefix[] = { | 1940 static const char* gDeviceTypePrefix[] = { | 
| 1957     "raster: ", | 1941     "raster: ", | 
| 1958     "picture: ", | 1942     "picture: ", | 
| 1959 #if SK_SUPPORT_GPU | 1943 #if SK_SUPPORT_GPU | 
| 1960     "opengl: ", | 1944     "opengl: ", | 
| 1961 #if SK_ANGLE | 1945 #if SK_ANGLE | 
| 1962     "angle: ", | 1946     "angle: ", | 
| 1963 #endif // SK_ANGLE | 1947 #endif // SK_ANGLE | 
| 1964     "null-gl: " |  | 
| 1965 #endif // SK_SUPPORT_GPU | 1948 #endif // SK_SUPPORT_GPU | 
| 1966 }; | 1949 }; | 
| 1967 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceType
      Cnt, | 1950 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceType
      Cnt, | 
| 1968                   array_size_mismatch); | 1951                   array_size_mismatch); | 
| 1969 | 1952 | 
| 1970 static const char* trystate_str(SkOSMenu::TriState state, | 1953 static const char* trystate_str(SkOSMenu::TriState state, | 
| 1971                                 const char trueStr[], const char falseStr[]) { | 1954                                 const char trueStr[], const char falseStr[]) { | 
| 1972     if (SkOSMenu::kOnState == state) { | 1955     if (SkOSMenu::kOnState == state) { | 
| 1973         return trueStr; | 1956         return trueStr; | 
| 1974     } else if (SkOSMenu::kOffState == state) { | 1957     } else if (SkOSMenu::kOffState == state) { | 
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2389     setenv("ANDROID_ROOT", "/android/device/data", 0); | 2372     setenv("ANDROID_ROOT", "/android/device/data", 0); | 
| 2390 #endif | 2373 #endif | 
| 2391     SkGraphics::Init(); | 2374     SkGraphics::Init(); | 
| 2392     SkEvent::Init(); | 2375     SkEvent::Init(); | 
| 2393 } | 2376 } | 
| 2394 | 2377 | 
| 2395 void application_term() { | 2378 void application_term() { | 
| 2396     SkEvent::Term(); | 2379     SkEvent::Term(); | 
| 2397     SkGraphics::Term(); | 2380     SkGraphics::Term(); | 
| 2398 } | 2381 } | 
| OLD | NEW | 
|---|