| 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" | 
| 11 #include "Resources.h" | 11 #include "Resources.h" | 
| 12 #include "SampleCode.h" | 12 #include "SampleCode.h" | 
| 13 #include "SkAnimTimer.h" | 13 #include "SkAnimTimer.h" | 
| 14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" | 
| 15 #include "SkCommandLineFlags.h" | 15 #include "SkCommandLineFlags.h" | 
| 16 #include "SkData.h" | 16 #include "SkData.h" | 
| 17 #include "SkDocument.h" | 17 #include "SkDocument.h" | 
| 18 #include "SkGraphics.h" | 18 #include "SkGraphics.h" | 
|  | 19 #include "SkImage_Base.h" | 
| 19 #include "SkImageEncoder.h" | 20 #include "SkImageEncoder.h" | 
| 20 #include "SkOSFile.h" | 21 #include "SkOSFile.h" | 
| 21 #include "SkPaint.h" | 22 #include "SkPaint.h" | 
| 22 #include "SkPaintFilterCanvas.h" | 23 #include "SkPaintFilterCanvas.h" | 
| 23 #include "SkPicture.h" | 24 #include "SkPicture.h" | 
| 24 #include "SkPictureRecorder.h" | 25 #include "SkPictureRecorder.h" | 
| 25 #include "SkPM4fPriv.h" | 26 #include "SkPM4fPriv.h" | 
| 26 #include "SkStream.h" | 27 #include "SkStream.h" | 
| 27 #include "SkSurface.h" | 28 #include "SkSurface.h" | 
| 28 #include "SkTemplates.h" | 29 #include "SkTemplates.h" | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 171 | 172 | 
| 172 class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager { | 173 class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager { | 
| 173 public: | 174 public: | 
| 174 | 175 | 
| 175     DefaultDeviceManager() { | 176     DefaultDeviceManager() { | 
| 176 #if SK_SUPPORT_GPU | 177 #if SK_SUPPORT_GPU | 
| 177         fCurContext = nullptr; | 178         fCurContext = nullptr; | 
| 178         fCurIntf = nullptr; | 179         fCurIntf = nullptr; | 
| 179         fCurRenderTarget = nullptr; | 180         fCurRenderTarget = nullptr; | 
| 180         fMSAASampleCount = 0; | 181         fMSAASampleCount = 0; | 
|  | 182         fDeepColor = false; | 
|  | 183         fActualColorBits = 0; | 
| 181 #endif | 184 #endif | 
| 182         fBackend = kNone_BackEndType; | 185         fBackend = kNone_BackEndType; | 
| 183     } | 186     } | 
| 184 | 187 | 
| 185     virtual ~DefaultDeviceManager() { | 188     virtual ~DefaultDeviceManager() { | 
| 186 #if SK_SUPPORT_GPU | 189 #if SK_SUPPORT_GPU | 
| 187         SkSafeUnref(fCurContext); | 190         SkSafeUnref(fCurContext); | 
| 188         SkSafeUnref(fCurIntf); | 191         SkSafeUnref(fCurIntf); | 
| 189         SkSafeUnref(fCurRenderTarget); | 192         SkSafeUnref(fCurRenderTarget); | 
| 190 #endif | 193 #endif | 
| 191     } | 194     } | 
| 192 | 195 | 
| 193     void setUpBackend(SampleWindow* win, int msaaSampleCount) override { | 196     void setUpBackend(SampleWindow* win, int msaaSampleCount, bool deepColor) ov
      erride { | 
| 194         SkASSERT(kNone_BackEndType == fBackend); | 197         SkASSERT(kNone_BackEndType == fBackend); | 
| 195 | 198 | 
| 196         fBackend = kNone_BackEndType; | 199         fBackend = kNone_BackEndType; | 
| 197 | 200 | 
| 198 #if SK_SUPPORT_GPU | 201 #if SK_SUPPORT_GPU | 
| 199         switch (win->getDeviceType()) { | 202         switch (win->getDeviceType()) { | 
| 200             case kRaster_DeviceType:    // fallthrough | 203             case kRaster_DeviceType:    // fallthrough | 
| 201             case kGPU_DeviceType: | 204             case kGPU_DeviceType: | 
| 202                 // all these guys use the native backend | 205                 // all these guys use the native backend | 
| 203                 fBackend = kNativeGL_BackEndType; | 206                 fBackend = kNativeGL_BackEndType; | 
| 204                 break; | 207                 break; | 
| 205 #if SK_ANGLE | 208 #if SK_ANGLE | 
| 206             case kANGLE_DeviceType: | 209             case kANGLE_DeviceType: | 
| 207                 // ANGLE is really the only odd man out | 210                 // ANGLE is really the only odd man out | 
| 208                 fBackend = kANGLE_BackEndType; | 211                 fBackend = kANGLE_BackEndType; | 
| 209                 break; | 212                 break; | 
| 210 #endif // SK_ANGLE | 213 #endif // SK_ANGLE | 
| 211 #if SK_COMMAND_BUFFER | 214 #if SK_COMMAND_BUFFER | 
| 212             case kCommandBuffer_DeviceType: | 215             case kCommandBuffer_DeviceType: | 
| 213                 // Command buffer is really the only other odd man out :D | 216                 // Command buffer is really the only other odd man out :D | 
| 214                 fBackend = kCommandBuffer_BackEndType; | 217                 fBackend = kCommandBuffer_BackEndType; | 
| 215                 break; | 218                 break; | 
| 216 #endif // SK_COMMAND_BUFFER | 219 #endif // SK_COMMAND_BUFFER | 
| 217             default: | 220             default: | 
| 218                 SkASSERT(false); | 221                 SkASSERT(false); | 
| 219                 break; | 222                 break; | 
| 220         } | 223         } | 
| 221         AttachmentInfo attachmentInfo; | 224         AttachmentInfo attachmentInfo; | 
| 222         bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo); | 225         bool result = win->attach(fBackend, msaaSampleCount, deepColor, &attachm
      entInfo); | 
| 223         if (!result) { | 226         if (!result) { | 
| 224             SkDebugf("Failed to initialize GL"); | 227             SkDebugf("Failed to initialize GL"); | 
| 225             return; | 228             return; | 
| 226         } | 229         } | 
| 227         fMSAASampleCount = msaaSampleCount; | 230         fMSAASampleCount = msaaSampleCount; | 
|  | 231         fDeepColor = deepColor; | 
|  | 232         // Assume that we have at least 24-bit output, for backends that don't s
      upply this data | 
|  | 233         fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24); | 
| 228 | 234 | 
| 229         SkASSERT(nullptr == fCurIntf); | 235         SkASSERT(nullptr == fCurIntf); | 
| 230         SkAutoTUnref<const GrGLInterface> glInterface; | 236         SkAutoTUnref<const GrGLInterface> glInterface; | 
| 231         switch (win->getDeviceType()) { | 237         switch (win->getDeviceType()) { | 
| 232             case kRaster_DeviceType:    // fallthrough | 238             case kRaster_DeviceType:    // fallthrough | 
| 233             case kGPU_DeviceType: | 239             case kGPU_DeviceType: | 
| 234                 // all these guys use the native interface | 240                 // all these guys use the native interface | 
| 235                 glInterface.reset(GrGLCreateNativeInterface()); | 241                 glInterface.reset(GrGLCreateNativeInterface()); | 
| 236                 break; | 242                 break; | 
| 237 #if SK_ANGLE | 243 #if SK_ANGLE | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 287         fCurRenderTarget = nullptr; | 293         fCurRenderTarget = nullptr; | 
| 288 #endif | 294 #endif | 
| 289         win->release(); | 295         win->release(); | 
| 290         fBackend = kNone_BackEndType; | 296         fBackend = kNone_BackEndType; | 
| 291     } | 297     } | 
| 292 | 298 | 
| 293     SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) 
      override { | 299     SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) 
      override { | 
| 294 #if SK_SUPPORT_GPU | 300 #if SK_SUPPORT_GPU | 
| 295         if (IsGpuDeviceType(dType) && fCurContext) { | 301         if (IsGpuDeviceType(dType) && fCurContext) { | 
| 296             SkSurfaceProps props(win->getSurfaceProps()); | 302             SkSurfaceProps props(win->getSurfaceProps()); | 
| 297             if (kRGBA_F16_SkColorType == win->info().colorType()) { | 303             if (kRGBA_F16_SkColorType == win->info().colorType() || fActualColor
      Bits > 24) { | 
| 298                 // Need to make an off-screen F16 surface - the current render t
      arget is | 304                 // If we're rendering to F16, we need an off-screen surface - th
      e current render | 
| 299                 // (probably) the wrong format. | 305                 // target is most likely the wrong format. | 
|  | 306                 // | 
|  | 307                 // If we're using a deep (10-bit or higher) surface, we probably
       need an off-screen | 
|  | 308                 // surface. 10-bit, in particular, has strange gamma behavior. | 
| 300                 return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo,
       win->info(), | 309                 return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo,
       win->info(), | 
| 301                                                    fMSAASampleCount, &props).rel
      ease(); | 310                                                    fMSAASampleCount, &props).rel
      ease(); | 
| 302             } else { | 311             } else { | 
| 303                 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &prop
      s).release(); | 312                 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &prop
      s).release(); | 
| 304             } | 313             } | 
| 305         } | 314         } | 
| 306 #endif | 315 #endif | 
| 307         return nullptr; | 316         return nullptr; | 
| 308     } | 317     } | 
| 309 | 318 | 
| 310     void publishCanvas(SampleWindow::DeviceType dType, | 319     void publishCanvas(SampleWindow::DeviceType dType, | 
| 311                        SkCanvas* canvas, SampleWindow* win) override { | 320                        SkCanvas* canvas, SampleWindow* win) override { | 
| 312 #if SK_SUPPORT_GPU | 321 #if SK_SUPPORT_GPU | 
| 313         if (fCurContext) { | 322         if (fCurContext) { | 
| 314             // in case we have queued drawing calls | 323             // in case we have queued drawing calls | 
| 315             fCurContext->flush(); | 324             fCurContext->flush(); | 
|  | 325         } | 
| 316 | 326 | 
| 317             if (!IsGpuDeviceType(dType)) { | 327         if (!IsGpuDeviceType(dType) || | 
| 318                 // need to send the raster bits to the (gpu) window | 328             kRGBA_F16_SkColorType == win->info().colorType() || | 
| 319                 const SkBitmap& bm = win->getBitmap(); | 329             fActualColorBits > 24) { | 
| 320                 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), | 330             // We made/have an off-screen surface. Get the contents as an SkImag
      e: | 
| 321                                              SkImageInfo2GrPixelConfig(bm.colorT
      ype(), | 331             SkBitmap bm; | 
| 322                                                                        bm.alphaT
      ype(), | 332             bm.allocPixels(win->info()); | 
| 323                                                                        bm.profil
      eType(), | 333             canvas->readPixels(&bm, 0, 0); | 
| 324                                                                        *fCurCont
      ext->caps()), | 334             SkPixmap pm; | 
| 325                                              bm.getPixels(), | 335             bm.peekPixels(&pm); | 
| 326                                              bm.rowBytes(), | 336             sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fCurContext, pm, | 
| 327                                              GrContext::kFlushWrites_PixelOp); | 337                                                                 SkBudgeted::kNo)
      ); | 
| 328             } else if (kRGBA_F16_SkColorType == win->info().colorType()) { | 338             GrTexture* texture = as_IB(image)->peekTexture(); | 
| 329                 SkBitmap bm; | 339             SkASSERT(texture); | 
| 330                 bm.allocPixels(win->info()); | 340 | 
| 331                 canvas->readPixels(&bm, 0, 0); | 341             // With ten-bit output, we need to manually apply the gamma of the o
      utput device | 
| 332                 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), | 342             // (unless we're in non-gamma correct mode, in which case our data i
      s already | 
| 333                                               SkImageInfo2GrPixelConfig(bm.info(
      ), | 343             // fake-sRGB, like we're expected to put in the 10-bit buffer): | 
| 334                                                                         *fCurCon
      text->caps()), | 344             bool doGamma = (fActualColorBits == 30) && SkImageInfoIsGammaCorrect
      (win->info()); | 
| 335                                               bm.getPixels(), | 345             fCurContext->applyGamma(fCurRenderTarget, texture, doGamma ? 1.0f / 
      2.2f : 1.0f); | 
| 336                                               bm.rowBytes(), |  | 
| 337                                               GrContext::kFlushWrites_PixelOp); |  | 
| 338             } |  | 
| 339         } | 346         } | 
| 340 #endif | 347 #endif | 
| 341 | 348 | 
| 342         win->present(); | 349         win->present(); | 
| 343     } | 350     } | 
| 344 | 351 | 
| 345     void windowSizeChanged(SampleWindow* win) override { | 352     void windowSizeChanged(SampleWindow* win) override { | 
| 346 #if SK_SUPPORT_GPU | 353 #if SK_SUPPORT_GPU | 
| 347         if (fCurContext) { | 354         if (fCurContext) { | 
| 348             AttachmentInfo attachmentInfo; | 355             AttachmentInfo attachmentInfo; | 
| 349             win->attach(fBackend, fMSAASampleCount, &attachmentInfo); | 356             win->attach(fBackend, fMSAASampleCount, fDeepColor, &attachmentInfo)
      ; | 
| 350             SkSafeUnref(fCurRenderTarget); | 357             SkSafeUnref(fCurRenderTarget); | 
|  | 358             fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24); | 
| 351             fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC
      ontext); | 359             fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC
      ontext); | 
| 352         } | 360         } | 
| 353 #endif | 361 #endif | 
| 354     } | 362     } | 
| 355 | 363 | 
| 356     GrContext* getGrContext() override { | 364     GrContext* getGrContext() override { | 
| 357 #if SK_SUPPORT_GPU | 365 #if SK_SUPPORT_GPU | 
| 358         return fCurContext; | 366         return fCurContext; | 
| 359 #else | 367 #else | 
| 360         return nullptr; | 368         return nullptr; | 
| 361 #endif | 369 #endif | 
| 362     } | 370     } | 
| 363 | 371 | 
| 364     GrRenderTarget* getGrRenderTarget() override { | 372     GrRenderTarget* getGrRenderTarget() override { | 
| 365 #if SK_SUPPORT_GPU | 373 #if SK_SUPPORT_GPU | 
| 366         return fCurRenderTarget; | 374         return fCurRenderTarget; | 
| 367 #else | 375 #else | 
| 368         return nullptr; | 376         return nullptr; | 
| 369 #endif | 377 #endif | 
| 370     } | 378     } | 
| 371 | 379 | 
|  | 380     int getColorBits() override { | 
|  | 381 #if SK_SUPPORT_GPU | 
|  | 382         return fActualColorBits; | 
|  | 383 #else | 
|  | 384         return 24; | 
|  | 385 #endif | 
|  | 386     } | 
|  | 387 | 
| 372 private: | 388 private: | 
| 373 | 389 | 
| 374 #if SK_SUPPORT_GPU | 390 #if SK_SUPPORT_GPU | 
| 375     GrContext*              fCurContext; | 391     GrContext*              fCurContext; | 
| 376     const GrGLInterface*    fCurIntf; | 392     const GrGLInterface*    fCurIntf; | 
| 377     GrRenderTarget*         fCurRenderTarget; | 393     GrRenderTarget*         fCurRenderTarget; | 
| 378     int fMSAASampleCount; | 394     int fMSAASampleCount; | 
|  | 395     bool fDeepColor; | 
|  | 396     int fActualColorBits; | 
| 379 #endif | 397 #endif | 
| 380 | 398 | 
| 381     SkOSWindow::SkBackEndTypes fBackend; | 399     SkOSWindow::SkBackEndTypes fBackend; | 
| 382 | 400 | 
| 383     typedef SampleWindow::DeviceManager INHERITED; | 401     typedef SampleWindow::DeviceManager INHERITED; | 
| 384 }; | 402 }; | 
| 385 | 403 | 
| 386 /////////////// | 404 /////////////// | 
| 387 static const char view_inval_msg[] = "view-inval-msg"; | 405 static const char view_inval_msg[] = "view-inval-msg"; | 
| 388 | 406 | 
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 766             newCount += 1; | 784             newCount += 1; | 
| 767         } | 785         } | 
| 768     } | 786     } | 
| 769     if (newCount) { | 787     if (newCount) { | 
| 770         factories.setCount(newCount); | 788         factories.setCount(newCount); | 
| 771     } | 789     } | 
| 772 } | 790 } | 
| 773 | 791 | 
| 774 DEFINE_string(slide, "", "Start on this sample."); | 792 DEFINE_string(slide, "", "Start on this sample."); | 
| 775 DEFINE_int32(msaa, 0, "Request multisampling with this count."); | 793 DEFINE_int32(msaa, 0, "Request multisampling with this count."); | 
|  | 794 DEFINE_bool(deepColor, false, "Request deep color (10-bit/channel or more) displ
      ay buffer."); | 
| 776 DEFINE_string(pictureDir, "", "Read pictures from here."); | 795 DEFINE_string(pictureDir, "", "Read pictures from here."); | 
| 777 DEFINE_string(picture, "", "Path to single picture."); | 796 DEFINE_string(picture, "", "Path to single picture."); | 
| 778 DEFINE_string(sequence, "", "Path to file containing the desired samples/gms to 
      show."); | 797 DEFINE_string(sequence, "", "Path to file containing the desired samples/gms to 
      show."); | 
| 779 DEFINE_bool(sort, false, "Sort samples by title."); | 798 DEFINE_bool(sort, false, "Sort samples by title."); | 
| 780 DEFINE_bool(list, false, "List samples?"); | 799 DEFINE_bool(list, false, "List samples?"); | 
| 781 DEFINE_bool(gpu, false, "Start up with gpu?"); | 800 DEFINE_bool(gpu, false, "Start up with gpu?"); | 
| 782 DEFINE_bool(redraw, false, "Force continuous redrawing, for profiling or debuggi
      ng tools."); | 801 DEFINE_bool(redraw, false, "Force continuous redrawing, for profiling or debuggi
      ng tools."); | 
| 783 DEFINE_string(key, "", "");  // dummy to enable gm tests that have platform-spec
      ific names | 802 DEFINE_string(key, "", "");  // dummy to enable gm tests that have platform-spec
      ific names | 
| 784 #ifdef SAMPLE_PDF_FILE_VIEWER | 803 #ifdef SAMPLE_PDF_FILE_VIEWER | 
| 785 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files."); | 804 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files."); | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 854 | 873 | 
| 855     if (!FLAGS_slide.isEmpty()) { | 874     if (!FLAGS_slide.isEmpty()) { | 
| 856         fCurrIndex = findByTitle(FLAGS_slide[0]); | 875         fCurrIndex = findByTitle(FLAGS_slide[0]); | 
| 857         if (fCurrIndex < 0) { | 876         if (fCurrIndex < 0) { | 
| 858             fprintf(stderr, "Unknown sample \"%s\"\n", FLAGS_slide[0]); | 877             fprintf(stderr, "Unknown sample \"%s\"\n", FLAGS_slide[0]); | 
| 859             listTitles(); | 878             listTitles(); | 
| 860         } | 879         } | 
| 861     } | 880     } | 
| 862 | 881 | 
| 863     fMSAASampleCount = FLAGS_msaa; | 882     fMSAASampleCount = FLAGS_msaa; | 
|  | 883     fDeepColor = FLAGS_deepColor; | 
| 864 | 884 | 
| 865     if (FLAGS_list) { | 885     if (FLAGS_list) { | 
| 866         listTitles(); | 886         listTitles(); | 
| 867     } | 887     } | 
| 868 | 888 | 
| 869     if (fCurrIndex < 0) { | 889     if (fCurrIndex < 0) { | 
| 870         SkString title; | 890         SkString title; | 
| 871         if (readTitleFromPrefs(&title)) { | 891         if (readTitleFromPrefs(&title)) { | 
| 872             fCurrIndex = findByTitle(title.c_str()); | 892             fCurrIndex = findByTitle(title.c_str()); | 
| 873         } | 893         } | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1016     this->setClipToBounds(false); | 1036     this->setClipToBounds(false); | 
| 1017 | 1037 | 
| 1018     this->loadView((*fSamples[fCurrIndex])()); | 1038     this->loadView((*fSamples[fCurrIndex])()); | 
| 1019 | 1039 | 
| 1020     if (nullptr == devManager) { | 1040     if (nullptr == devManager) { | 
| 1021         fDevManager = new DefaultDeviceManager(); | 1041         fDevManager = new DefaultDeviceManager(); | 
| 1022     } else { | 1042     } else { | 
| 1023         devManager->ref(); | 1043         devManager->ref(); | 
| 1024         fDevManager = devManager; | 1044         fDevManager = devManager; | 
| 1025     } | 1045     } | 
| 1026     fDevManager->setUpBackend(this, fMSAASampleCount); | 1046     fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); | 
| 1027 | 1047 | 
| 1028     // If another constructor set our dimensions, ensure that our | 1048     // If another constructor set our dimensions, ensure that our | 
| 1029     // onSizeChange gets called. | 1049     // onSizeChange gets called. | 
| 1030     if (this->height() && this->width()) { | 1050     if (this->height() && this->width()) { | 
| 1031         this->onSizeChange(); | 1051         this->onSizeChange(); | 
| 1032     } | 1052     } | 
| 1033 | 1053 | 
| 1034     // can't call this synchronously, since it may require a subclass to | 1054     // can't call this synchronously, since it may require a subclass to | 
| 1035     // to implement, or the caller may need us to have returned from the | 1055     // to implement, or the caller may need us to have returned from the | 
| 1036     // constructor first. Hence we post an event to ourselves. | 1056     // constructor first. Hence we post an event to ourselves. | 
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1840     } | 1860     } | 
| 1841     return this->INHERITED::onHandleChar(uni); | 1861     return this->INHERITED::onHandleChar(uni); | 
| 1842 } | 1862 } | 
| 1843 | 1863 | 
| 1844 void SampleWindow::setDeviceType(DeviceType type) { | 1864 void SampleWindow::setDeviceType(DeviceType type) { | 
| 1845     if (type == fDeviceType) | 1865     if (type == fDeviceType) | 
| 1846         return; | 1866         return; | 
| 1847 | 1867 | 
| 1848     fDevManager->tearDownBackend(this); | 1868     fDevManager->tearDownBackend(this); | 
| 1849     fDeviceType = type; | 1869     fDeviceType = type; | 
| 1850     fDevManager->setUpBackend(this, fMSAASampleCount); | 1870     fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); | 
| 1851 | 1871 | 
| 1852     this->updateTitle(); | 1872     this->updateTitle(); | 
| 1853     this->inval(nullptr); | 1873     this->inval(nullptr); | 
| 1854 } | 1874 } | 
| 1855 | 1875 | 
| 1856 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { | 1876 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { | 
| 1857     this->setColorType(ct, pt); | 1877     this->setColorType(ct, pt); | 
| 1858 | 1878 | 
| 1859     fDevManager->tearDownBackend(this); | 1879     fDevManager->tearDownBackend(this); | 
| 1860     fDevManager->setUpBackend(this, fMSAASampleCount); | 1880     fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); | 
| 1861 | 1881 | 
| 1862     this->updateTitle(); | 1882     this->updateTitle(); | 
| 1863     this->inval(nullptr); | 1883     this->inval(nullptr); | 
| 1864 } | 1884 } | 
| 1865 | 1885 | 
| 1866 void SampleWindow::toggleSlideshow() { | 1886 void SampleWindow::toggleSlideshow() { | 
| 1867     fAnimating = !fAnimating; | 1887     fAnimating = !fAnimating; | 
| 1868     this->postAnimatingEvent(); | 1888     this->postAnimatingEvent(); | 
| 1869     this->updateTitle(); | 1889     this->updateTitle(); | 
| 1870 } | 1890 } | 
| 1871 | 1891 | 
| 1872 void SampleWindow::toggleRendering() { | 1892 void SampleWindow::toggleRendering() { | 
| 1873     this->setDeviceType(cycle_devicetype(fDeviceType)); | 1893     this->setDeviceType(cycle_devicetype(fDeviceType)); | 
| 1874     this->updateTitle(); | 1894     this->updateTitle(); | 
| 1875     this->inval(nullptr); | 1895     this->inval(nullptr); | 
| 1876 } | 1896 } | 
| 1877 | 1897 | 
| 1878 void SampleWindow::toggleFPS() { | 1898 void SampleWindow::toggleFPS() { | 
| 1879     fMeasureFPS = !fMeasureFPS; | 1899     fMeasureFPS = !fMeasureFPS; | 
| 1880     this->updateTitle(); | 1900     this->updateTitle(); | 
| 1881     this->inval(nullptr); | 1901     this->inval(nullptr); | 
| 1882 } | 1902 } | 
| 1883 | 1903 | 
| 1884 void SampleWindow::toggleDistanceFieldFonts() { | 1904 void SampleWindow::toggleDistanceFieldFonts() { | 
| 1885     // reset backend | 1905     // reset backend | 
| 1886     fDevManager->tearDownBackend(this); | 1906     fDevManager->tearDownBackend(this); | 
| 1887     fDevManager->setUpBackend(this, fMSAASampleCount); | 1907     fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); | 
| 1888 | 1908 | 
| 1889     SkSurfaceProps props = this->getSurfaceProps(); | 1909     SkSurfaceProps props = this->getSurfaceProps(); | 
| 1890     uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDeviceIndependentFonts_
      Flag; | 1910     uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDeviceIndependentFonts_
      Flag; | 
| 1891     this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); | 1911     this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); | 
| 1892 | 1912 | 
| 1893     this->updateTitle(); | 1913     this->updateTitle(); | 
| 1894     this->inval(nullptr); | 1914     this->inval(nullptr); | 
| 1895 } | 1915 } | 
| 1896 | 1916 | 
| 1897 void SampleWindow::setPixelGeometry(int pixelGeometryIndex) { | 1917 void SampleWindow::setPixelGeometry(int pixelGeometryIndex) { | 
| 1898     // reset backend | 1918     // reset backend | 
| 1899     fDevManager->tearDownBackend(this); | 1919     fDevManager->tearDownBackend(this); | 
| 1900     fDevManager->setUpBackend(this, fMSAASampleCount); | 1920     fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); | 
| 1901 | 1921 | 
| 1902     const SkSurfaceProps& oldProps = this->getSurfaceProps(); | 1922     const SkSurfaceProps& oldProps = this->getSurfaceProps(); | 
| 1903     SkSurfaceProps newProps(oldProps.flags(), SkSurfaceProps::kLegacyFontHost_In
      itType); | 1923     SkSurfaceProps newProps(oldProps.flags(), SkSurfaceProps::kLegacyFontHost_In
      itType); | 
| 1904     if (pixelGeometryIndex > 0) { | 1924     if (pixelGeometryIndex > 0) { | 
| 1905         newProps = SkSurfaceProps(oldProps.flags(), | 1925         newProps = SkSurfaceProps(oldProps.flags(), | 
| 1906                                   gPixelGeometryStates[pixelGeometryIndex].pixel
      Geometry); | 1926                                   gPixelGeometryStates[pixelGeometryIndex].pixel
      Geometry); | 
| 1907     } | 1927     } | 
| 1908     this->setSurfaceProps(newProps); | 1928     this->setSurfaceProps(newProps); | 
| 1909 | 1929 | 
| 1910     this->updateTitle(); | 1930     this->updateTitle(); | 
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2155         fDevManager && | 2175         fDevManager && | 
| 2156         fDevManager->getGrRenderTarget() && | 2176         fDevManager->getGrRenderTarget() && | 
| 2157         fDevManager->getGrRenderTarget()->numColorSamples() > 0) { | 2177         fDevManager->getGrRenderTarget()->numColorSamples() > 0) { | 
| 2158         title.appendf(" [MSAA: %d]", | 2178         title.appendf(" [MSAA: %d]", | 
| 2159                        fDevManager->getGrRenderTarget()->numColorSamples()); | 2179                        fDevManager->getGrRenderTarget()->numColorSamples()); | 
| 2160     } | 2180     } | 
| 2161 #endif | 2181 #endif | 
| 2162 | 2182 | 
| 2163     title.appendf(" %s", find_config_name(this->info())); | 2183     title.appendf(" %s", find_config_name(this->info())); | 
| 2164 | 2184 | 
|  | 2185     if (fDevManager && fDevManager->getColorBits() > 24) { | 
|  | 2186         title.appendf(" %d bpc", fDevManager->getColorBits()); | 
|  | 2187     } | 
|  | 2188 | 
| 2165     if (gTreatSkColorAsSRGB) { | 2189     if (gTreatSkColorAsSRGB) { | 
| 2166         title.append(" sRGB"); | 2190         title.append(" sRGB"); | 
| 2167     } | 2191     } | 
| 2168 | 2192 | 
| 2169     this->setTitle(title.c_str()); | 2193     this->setTitle(title.c_str()); | 
| 2170 } | 2194 } | 
| 2171 | 2195 | 
| 2172 void SampleWindow::onSizeChange() { | 2196 void SampleWindow::onSizeChange() { | 
| 2173     this->INHERITED::onSizeChange(); | 2197     this->INHERITED::onSizeChange(); | 
| 2174 | 2198 | 
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2401 #ifdef SK_BUILD_FOR_MAC | 2425 #ifdef SK_BUILD_FOR_MAC | 
| 2402     setenv("ANDROID_ROOT", "/android/device/data", 0); | 2426     setenv("ANDROID_ROOT", "/android/device/data", 0); | 
| 2403 #endif | 2427 #endif | 
| 2404     SkGraphics::Init(); | 2428     SkGraphics::Init(); | 
| 2405     SkEvent::Init(); | 2429     SkEvent::Init(); | 
| 2406 } | 2430 } | 
| 2407 | 2431 | 
| 2408 void application_term() { | 2432 void application_term() { | 
| 2409     SkEvent::Term(); | 2433     SkEvent::Term(); | 
| 2410 } | 2434 } | 
| OLD | NEW | 
|---|