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 "SkColorSpace.h" | |
15 #include "SkCommandLineFlags.h" | 16 #include "SkCommandLineFlags.h" |
16 #include "SkData.h" | 17 #include "SkData.h" |
17 #include "SkDocument.h" | 18 #include "SkDocument.h" |
18 #include "SkGraphics.h" | 19 #include "SkGraphics.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" |
29 #include "SkTSort.h" | 30 #include "SkTSort.h" |
30 #include "SkTime.h" | 31 #include "SkTime.h" |
31 #include "SkTypeface.h" | 32 #include "SkTypeface.h" |
32 #include "SkWindow.h" | 33 #include "SkWindow.h" |
33 #include "sk_tool_utils.h" | 34 #include "sk_tool_utils.h" |
34 | 35 |
35 #if SK_SUPPORT_GPU | 36 #if SK_SUPPORT_GPU |
36 # include "gl/GrGLInterface.h" | 37 # include "gl/GrGLInterface.h" |
37 # include "gl/GrGLUtil.h" | 38 # include "gl/GrGLUtil.h" |
38 # include "GrRenderTarget.h" | 39 # include "GrRenderTarget.h" |
40 # include "effects/GrColorSpaceEffect.h" | |
39 # include "GrContext.h" | 41 # include "GrContext.h" |
42 # include "GrDrawContext.h" | |
40 # include "SkGr.h" | 43 # include "SkGr.h" |
41 # if SK_ANGLE | 44 # if SK_ANGLE |
42 # include "gl/angle/GLTestContext_angle.h" | 45 # include "gl/angle/GLTestContext_angle.h" |
43 # endif | 46 # endif |
44 #else | 47 #else |
45 class GrContext; | 48 class GrContext; |
46 #endif | 49 #endif |
47 | 50 |
48 const struct { | 51 const struct { |
49 SkColorType fColorType; | 52 SkColorType fColorType; |
(...skipping 121 matching lines...) Loading... | |
171 | 174 |
172 class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager { | 175 class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager { |
173 public: | 176 public: |
174 | 177 |
175 DefaultDeviceManager() { | 178 DefaultDeviceManager() { |
176 #if SK_SUPPORT_GPU | 179 #if SK_SUPPORT_GPU |
177 fCurContext = nullptr; | 180 fCurContext = nullptr; |
178 fCurIntf = nullptr; | 181 fCurIntf = nullptr; |
179 fCurRenderTarget = nullptr; | 182 fCurRenderTarget = nullptr; |
180 fMSAASampleCount = 0; | 183 fMSAASampleCount = 0; |
184 fTenBitColor = false; | |
181 #endif | 185 #endif |
182 fBackend = kNone_BackEndType; | 186 fBackend = kNone_BackEndType; |
183 } | 187 } |
184 | 188 |
185 virtual ~DefaultDeviceManager() { | 189 virtual ~DefaultDeviceManager() { |
186 #if SK_SUPPORT_GPU | 190 #if SK_SUPPORT_GPU |
187 SkSafeUnref(fCurContext); | 191 SkSafeUnref(fCurContext); |
188 SkSafeUnref(fCurIntf); | 192 SkSafeUnref(fCurIntf); |
189 SkSafeUnref(fCurRenderTarget); | 193 SkSafeUnref(fCurRenderTarget); |
190 #endif | 194 #endif |
191 } | 195 } |
192 | 196 |
193 void setUpBackend(SampleWindow* win, int msaaSampleCount) override { | 197 void setUpBackend(SampleWindow* win, int msaaSampleCount, bool tenBitColor) override { |
194 SkASSERT(kNone_BackEndType == fBackend); | 198 SkASSERT(kNone_BackEndType == fBackend); |
195 | 199 |
196 fBackend = kNone_BackEndType; | 200 fBackend = kNone_BackEndType; |
197 | 201 |
198 #if SK_SUPPORT_GPU | 202 #if SK_SUPPORT_GPU |
199 switch (win->getDeviceType()) { | 203 switch (win->getDeviceType()) { |
200 case kRaster_DeviceType: // fallthrough | 204 case kRaster_DeviceType: // fallthrough |
201 case kGPU_DeviceType: | 205 case kGPU_DeviceType: |
202 // all these guys use the native backend | 206 // all these guys use the native backend |
203 fBackend = kNativeGL_BackEndType; | 207 fBackend = kNativeGL_BackEndType; |
204 break; | 208 break; |
205 #if SK_ANGLE | 209 #if SK_ANGLE |
206 case kANGLE_DeviceType: | 210 case kANGLE_DeviceType: |
207 // ANGLE is really the only odd man out | 211 // ANGLE is really the only odd man out |
208 fBackend = kANGLE_BackEndType; | 212 fBackend = kANGLE_BackEndType; |
209 break; | 213 break; |
210 #endif // SK_ANGLE | 214 #endif // SK_ANGLE |
211 #if SK_COMMAND_BUFFER | 215 #if SK_COMMAND_BUFFER |
212 case kCommandBuffer_DeviceType: | 216 case kCommandBuffer_DeviceType: |
213 // Command buffer is really the only other odd man out :D | 217 // Command buffer is really the only other odd man out :D |
214 fBackend = kCommandBuffer_BackEndType; | 218 fBackend = kCommandBuffer_BackEndType; |
215 break; | 219 break; |
216 #endif // SK_COMMAND_BUFFER | 220 #endif // SK_COMMAND_BUFFER |
217 default: | 221 default: |
218 SkASSERT(false); | 222 SkASSERT(false); |
219 break; | 223 break; |
220 } | 224 } |
221 AttachmentInfo attachmentInfo; | 225 AttachmentInfo attachmentInfo; |
222 bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo); | 226 bool result = win->attach(fBackend, msaaSampleCount, tenBitColor, &attac hmentInfo); |
Brian Osman
2016/04/27 19:55:01
Seems like I should add fColorBits to AttachmentIn
| |
223 if (!result) { | 227 if (!result) { |
224 SkDebugf("Failed to initialize GL"); | 228 SkDebugf("Failed to initialize GL"); |
225 return; | 229 return; |
226 } | 230 } |
227 fMSAASampleCount = msaaSampleCount; | 231 fMSAASampleCount = msaaSampleCount; |
232 fTenBitColor = tenBitColor; | |
228 | 233 |
229 SkASSERT(nullptr == fCurIntf); | 234 SkASSERT(nullptr == fCurIntf); |
230 SkAutoTUnref<const GrGLInterface> glInterface; | 235 SkAutoTUnref<const GrGLInterface> glInterface; |
231 switch (win->getDeviceType()) { | 236 switch (win->getDeviceType()) { |
232 case kRaster_DeviceType: // fallthrough | 237 case kRaster_DeviceType: // fallthrough |
233 case kGPU_DeviceType: | 238 case kGPU_DeviceType: |
234 // all these guys use the native interface | 239 // all these guys use the native interface |
235 glInterface.reset(GrGLCreateNativeInterface()); | 240 glInterface.reset(GrGLCreateNativeInterface()); |
236 break; | 241 break; |
237 #if SK_ANGLE | 242 #if SK_ANGLE |
(...skipping 49 matching lines...) Loading... | |
287 fCurRenderTarget = nullptr; | 292 fCurRenderTarget = nullptr; |
288 #endif | 293 #endif |
289 win->release(); | 294 win->release(); |
290 fBackend = kNone_BackEndType; | 295 fBackend = kNone_BackEndType; |
291 } | 296 } |
292 | 297 |
293 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override { | 298 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override { |
294 #if SK_SUPPORT_GPU | 299 #if SK_SUPPORT_GPU |
295 if (IsGpuDeviceType(dType) && fCurContext) { | 300 if (IsGpuDeviceType(dType) && fCurContext) { |
296 SkSurfaceProps props(win->getSurfaceProps()); | 301 SkSurfaceProps props(win->getSurfaceProps()); |
297 if (kRGBA_F16_SkColorType == win->info().colorType()) { | 302 if (kRGBA_F16_SkColorType == win->info().colorType() || fTenBitColor ) { |
298 // Need to make an off-screen F16 surface - the current render t arget is | 303 // Need to make an off-screen F16 surface - the current render t arget is |
299 // (probably) the wrong format. | 304 // (probably) the wrong format. If we're using a 10-bit surface, we definitely |
305 // need an off-screen surface, because 10-bit behaves strangely wrt gamma. | |
300 return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo, win->info(), | 306 return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo, win->info(), |
301 fMSAASampleCount, &props).rel ease(); | 307 fMSAASampleCount, &props).rel ease(); |
302 } else { | 308 } else { |
303 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &prop s).release(); | 309 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &prop s).release(); |
304 } | 310 } |
305 } | 311 } |
306 #endif | 312 #endif |
307 return nullptr; | 313 return nullptr; |
308 } | 314 } |
309 | 315 |
310 void publishCanvas(SampleWindow::DeviceType dType, | 316 void publishCanvas(SampleWindow::DeviceType dType, |
311 SkCanvas* canvas, SampleWindow* win) override { | 317 SkCanvas* canvas, SampleWindow* win) override { |
312 #if SK_SUPPORT_GPU | 318 #if SK_SUPPORT_GPU |
313 if (fCurContext) { | 319 if (fCurContext) { |
314 // in case we have queued drawing calls | 320 // in case we have queued drawing calls |
315 fCurContext->flush(); | 321 fCurContext->flush(); |
316 | 322 |
317 if (!IsGpuDeviceType(dType)) { | 323 if (fTenBitColor) { |
324 SkBitmap bm; | |
325 bm.allocPixels(win->info()); | |
326 canvas->readPixels(&bm, 0, 0); | |
Brian Osman
2016/04/27 19:55:01
This is really ugly, but I couldn't find a way to
bsalomon
2016/04/27 20:28:24
My gut take is that this adds too much technical d
| |
327 if (SkImageInfoIsGammaCorrect(win->info())) { | |
328 // For now, assuming source and destination are both sRGB. | |
329 // TODO: Fetch destination space from device, or allow it to be specified | |
330 // on the command line, etc... | |
331 sk_sp<SkColorSpace> srgb(SkColorSpace::NewNamed(SkColorSpace ::kSRGB_Named)); | |
332 | |
333 fCurRenderTarget->writePixelsWithColorSpace( | |
334 0, 0, bm.width(), bm.height(), | |
335 SkImageInfo2GrPixelConfig(bm.info(), *fCurContext->caps( )), | |
336 srgb.get(), srgb.get(), bm.getPixels(), bm.rowBytes(), | |
337 GrContext::kManualDstGamma_ColorSpaceOpsFlag); | |
338 } else { | |
339 // We rendered to L32 (legacy mode). That matches the semant ics of the windowing | |
340 // system's 10-bit buffer (data is treated as sRGB, but not gamma-corrected on | |
341 // write). We can just do a writePixels, which is just a cop y of values. | |
342 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), | |
343 SkImageInfo2GrPixelConfig(bm.i nfo(), | |
344 *fCu rContext->caps()), | |
345 bm.getPixels(), | |
346 bm.rowBytes(), | |
347 GrContext::kFlushWrites_PixelO p); | |
348 } | |
349 } else if (!IsGpuDeviceType(dType)) { | |
318 // need to send the raster bits to the (gpu) window | 350 // need to send the raster bits to the (gpu) window |
319 const SkBitmap& bm = win->getBitmap(); | 351 const SkBitmap& bm = win->getBitmap(); |
320 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), | 352 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), |
321 SkImageInfo2GrPixelConfig(bm.colorT ype(), | 353 SkImageInfo2GrPixelConfig(bm.colorT ype(), |
322 bm.alphaT ype(), | 354 bm.alphaT ype(), |
323 bm.profil eType(), | 355 bm.profil eType(), |
324 *fCurCont ext->caps()), | 356 *fCurCont ext->caps()), |
325 bm.getPixels(), | 357 bm.getPixels(), |
326 bm.rowBytes(), | 358 bm.rowBytes(), |
327 GrContext::kFlushWrites_PixelOp); | 359 GrContext::kFlushWrites_PixelOp); |
(...skipping 11 matching lines...) Loading... | |
339 } | 371 } |
340 #endif | 372 #endif |
341 | 373 |
342 win->present(); | 374 win->present(); |
343 } | 375 } |
344 | 376 |
345 void windowSizeChanged(SampleWindow* win) override { | 377 void windowSizeChanged(SampleWindow* win) override { |
346 #if SK_SUPPORT_GPU | 378 #if SK_SUPPORT_GPU |
347 if (fCurContext) { | 379 if (fCurContext) { |
348 AttachmentInfo attachmentInfo; | 380 AttachmentInfo attachmentInfo; |
349 win->attach(fBackend, fMSAASampleCount, &attachmentInfo); | 381 win->attach(fBackend, fMSAASampleCount, fTenBitColor, &attachmentInf o); |
350 SkSafeUnref(fCurRenderTarget); | 382 SkSafeUnref(fCurRenderTarget); |
351 fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC ontext); | 383 fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC ontext); |
352 } | 384 } |
353 #endif | 385 #endif |
354 } | 386 } |
355 | 387 |
356 GrContext* getGrContext() override { | 388 GrContext* getGrContext() override { |
357 #if SK_SUPPORT_GPU | 389 #if SK_SUPPORT_GPU |
358 return fCurContext; | 390 return fCurContext; |
359 #else | 391 #else |
360 return nullptr; | 392 return nullptr; |
361 #endif | 393 #endif |
362 } | 394 } |
363 | 395 |
364 GrRenderTarget* getGrRenderTarget() override { | 396 GrRenderTarget* getGrRenderTarget() override { |
365 #if SK_SUPPORT_GPU | 397 #if SK_SUPPORT_GPU |
366 return fCurRenderTarget; | 398 return fCurRenderTarget; |
367 #else | 399 #else |
368 return nullptr; | 400 return nullptr; |
369 #endif | 401 #endif |
370 } | 402 } |
371 | 403 |
372 private: | 404 private: |
373 | 405 |
374 #if SK_SUPPORT_GPU | 406 #if SK_SUPPORT_GPU |
375 GrContext* fCurContext; | 407 GrContext* fCurContext; |
376 const GrGLInterface* fCurIntf; | 408 const GrGLInterface* fCurIntf; |
377 GrRenderTarget* fCurRenderTarget; | 409 GrRenderTarget* fCurRenderTarget; |
378 int fMSAASampleCount; | 410 int fMSAASampleCount; |
411 bool fTenBitColor; | |
379 #endif | 412 #endif |
380 | 413 |
381 SkOSWindow::SkBackEndTypes fBackend; | 414 SkOSWindow::SkBackEndTypes fBackend; |
382 | 415 |
383 typedef SampleWindow::DeviceManager INHERITED; | 416 typedef SampleWindow::DeviceManager INHERITED; |
384 }; | 417 }; |
385 | 418 |
386 /////////////// | 419 /////////////// |
387 static const char view_inval_msg[] = "view-inval-msg"; | 420 static const char view_inval_msg[] = "view-inval-msg"; |
388 | 421 |
(...skipping 377 matching lines...) Loading... | |
766 newCount += 1; | 799 newCount += 1; |
767 } | 800 } |
768 } | 801 } |
769 if (newCount) { | 802 if (newCount) { |
770 factories.setCount(newCount); | 803 factories.setCount(newCount); |
771 } | 804 } |
772 } | 805 } |
773 | 806 |
774 DEFINE_string(slide, "", "Start on this sample."); | 807 DEFINE_string(slide, "", "Start on this sample."); |
775 DEFINE_int32(msaa, 0, "Request multisampling with this count."); | 808 DEFINE_int32(msaa, 0, "Request multisampling with this count."); |
809 DEFINE_bool(tenBit, false, "Request 10-bit/channel display buffer."); | |
776 DEFINE_string(pictureDir, "", "Read pictures from here."); | 810 DEFINE_string(pictureDir, "", "Read pictures from here."); |
777 DEFINE_string(picture, "", "Path to single picture."); | 811 DEFINE_string(picture, "", "Path to single picture."); |
778 DEFINE_string(sequence, "", "Path to file containing the desired samples/gms to show."); | 812 DEFINE_string(sequence, "", "Path to file containing the desired samples/gms to show."); |
779 DEFINE_bool(sort, false, "Sort samples by title."); | 813 DEFINE_bool(sort, false, "Sort samples by title."); |
780 DEFINE_bool(list, false, "List samples?"); | 814 DEFINE_bool(list, false, "List samples?"); |
781 DEFINE_bool(gpu, false, "Start up with gpu?"); | 815 DEFINE_bool(gpu, false, "Start up with gpu?"); |
782 DEFINE_bool(redraw, false, "Force continuous redrawing, for profiling or debuggi ng tools."); | 816 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 | 817 DEFINE_string(key, "", ""); // dummy to enable gm tests that have platform-spec ific names |
784 #ifdef SAMPLE_PDF_FILE_VIEWER | 818 #ifdef SAMPLE_PDF_FILE_VIEWER |
785 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files."); | 819 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files."); |
(...skipping 68 matching lines...) Loading... | |
854 | 888 |
855 if (!FLAGS_slide.isEmpty()) { | 889 if (!FLAGS_slide.isEmpty()) { |
856 fCurrIndex = findByTitle(FLAGS_slide[0]); | 890 fCurrIndex = findByTitle(FLAGS_slide[0]); |
857 if (fCurrIndex < 0) { | 891 if (fCurrIndex < 0) { |
858 fprintf(stderr, "Unknown sample \"%s\"\n", FLAGS_slide[0]); | 892 fprintf(stderr, "Unknown sample \"%s\"\n", FLAGS_slide[0]); |
859 listTitles(); | 893 listTitles(); |
860 } | 894 } |
861 } | 895 } |
862 | 896 |
863 fMSAASampleCount = FLAGS_msaa; | 897 fMSAASampleCount = FLAGS_msaa; |
898 fTenBitColor = FLAGS_tenBit; | |
864 | 899 |
865 if (FLAGS_list) { | 900 if (FLAGS_list) { |
866 listTitles(); | 901 listTitles(); |
867 } | 902 } |
868 | 903 |
869 if (fCurrIndex < 0) { | 904 if (fCurrIndex < 0) { |
870 SkString title; | 905 SkString title; |
871 if (readTitleFromPrefs(&title)) { | 906 if (readTitleFromPrefs(&title)) { |
872 fCurrIndex = findByTitle(title.c_str()); | 907 fCurrIndex = findByTitle(title.c_str()); |
873 } | 908 } |
(...skipping 142 matching lines...) Loading... | |
1016 this->setClipToBounds(false); | 1051 this->setClipToBounds(false); |
1017 | 1052 |
1018 this->loadView((*fSamples[fCurrIndex])()); | 1053 this->loadView((*fSamples[fCurrIndex])()); |
1019 | 1054 |
1020 if (nullptr == devManager) { | 1055 if (nullptr == devManager) { |
1021 fDevManager = new DefaultDeviceManager(); | 1056 fDevManager = new DefaultDeviceManager(); |
1022 } else { | 1057 } else { |
1023 devManager->ref(); | 1058 devManager->ref(); |
1024 fDevManager = devManager; | 1059 fDevManager = devManager; |
1025 } | 1060 } |
1026 fDevManager->setUpBackend(this, fMSAASampleCount); | 1061 fDevManager->setUpBackend(this, fMSAASampleCount, fTenBitColor); |
1027 | 1062 |
1028 // If another constructor set our dimensions, ensure that our | 1063 // If another constructor set our dimensions, ensure that our |
1029 // onSizeChange gets called. | 1064 // onSizeChange gets called. |
1030 if (this->height() && this->width()) { | 1065 if (this->height() && this->width()) { |
1031 this->onSizeChange(); | 1066 this->onSizeChange(); |
1032 } | 1067 } |
1033 | 1068 |
1034 // can't call this synchronously, since it may require a subclass to | 1069 // 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 | 1070 // to implement, or the caller may need us to have returned from the |
1036 // constructor first. Hence we post an event to ourselves. | 1071 // constructor first. Hence we post an event to ourselves. |
(...skipping 803 matching lines...) Loading... | |
1840 } | 1875 } |
1841 return this->INHERITED::onHandleChar(uni); | 1876 return this->INHERITED::onHandleChar(uni); |
1842 } | 1877 } |
1843 | 1878 |
1844 void SampleWindow::setDeviceType(DeviceType type) { | 1879 void SampleWindow::setDeviceType(DeviceType type) { |
1845 if (type == fDeviceType) | 1880 if (type == fDeviceType) |
1846 return; | 1881 return; |
1847 | 1882 |
1848 fDevManager->tearDownBackend(this); | 1883 fDevManager->tearDownBackend(this); |
1849 fDeviceType = type; | 1884 fDeviceType = type; |
1850 fDevManager->setUpBackend(this, fMSAASampleCount); | 1885 fDevManager->setUpBackend(this, fMSAASampleCount, fTenBitColor); |
1851 | 1886 |
1852 this->updateTitle(); | 1887 this->updateTitle(); |
1853 this->inval(nullptr); | 1888 this->inval(nullptr); |
1854 } | 1889 } |
1855 | 1890 |
1856 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { | 1891 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { |
1857 this->setColorType(ct, pt); | 1892 this->setColorType(ct, pt); |
1858 | 1893 |
1859 fDevManager->tearDownBackend(this); | 1894 fDevManager->tearDownBackend(this); |
1860 fDevManager->setUpBackend(this, fMSAASampleCount); | 1895 fDevManager->setUpBackend(this, fMSAASampleCount, fTenBitColor); |
1861 | 1896 |
1862 this->updateTitle(); | 1897 this->updateTitle(); |
1863 this->inval(nullptr); | 1898 this->inval(nullptr); |
1864 } | 1899 } |
1865 | 1900 |
1866 void SampleWindow::toggleSlideshow() { | 1901 void SampleWindow::toggleSlideshow() { |
1867 fAnimating = !fAnimating; | 1902 fAnimating = !fAnimating; |
1868 this->postAnimatingEvent(); | 1903 this->postAnimatingEvent(); |
1869 this->updateTitle(); | 1904 this->updateTitle(); |
1870 } | 1905 } |
1871 | 1906 |
1872 void SampleWindow::toggleRendering() { | 1907 void SampleWindow::toggleRendering() { |
1873 this->setDeviceType(cycle_devicetype(fDeviceType)); | 1908 this->setDeviceType(cycle_devicetype(fDeviceType)); |
1874 this->updateTitle(); | 1909 this->updateTitle(); |
1875 this->inval(nullptr); | 1910 this->inval(nullptr); |
1876 } | 1911 } |
1877 | 1912 |
1878 void SampleWindow::toggleFPS() { | 1913 void SampleWindow::toggleFPS() { |
1879 fMeasureFPS = !fMeasureFPS; | 1914 fMeasureFPS = !fMeasureFPS; |
1880 this->updateTitle(); | 1915 this->updateTitle(); |
1881 this->inval(nullptr); | 1916 this->inval(nullptr); |
1882 } | 1917 } |
1883 | 1918 |
1884 void SampleWindow::toggleDistanceFieldFonts() { | 1919 void SampleWindow::toggleDistanceFieldFonts() { |
1885 // reset backend | 1920 // reset backend |
1886 fDevManager->tearDownBackend(this); | 1921 fDevManager->tearDownBackend(this); |
1887 fDevManager->setUpBackend(this, fMSAASampleCount); | 1922 fDevManager->setUpBackend(this, fMSAASampleCount, fTenBitColor); |
1888 | 1923 |
1889 SkSurfaceProps props = this->getSurfaceProps(); | 1924 SkSurfaceProps props = this->getSurfaceProps(); |
1890 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDeviceIndependentFonts_ Flag; | 1925 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDeviceIndependentFonts_ Flag; |
1891 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); | 1926 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); |
1892 | 1927 |
1893 this->updateTitle(); | 1928 this->updateTitle(); |
1894 this->inval(nullptr); | 1929 this->inval(nullptr); |
1895 } | 1930 } |
1896 | 1931 |
1897 void SampleWindow::setPixelGeometry(int pixelGeometryIndex) { | 1932 void SampleWindow::setPixelGeometry(int pixelGeometryIndex) { |
1898 // reset backend | 1933 // reset backend |
1899 fDevManager->tearDownBackend(this); | 1934 fDevManager->tearDownBackend(this); |
1900 fDevManager->setUpBackend(this, fMSAASampleCount); | 1935 fDevManager->setUpBackend(this, fMSAASampleCount, fTenBitColor); |
1901 | 1936 |
1902 const SkSurfaceProps& oldProps = this->getSurfaceProps(); | 1937 const SkSurfaceProps& oldProps = this->getSurfaceProps(); |
1903 SkSurfaceProps newProps(oldProps.flags(), SkSurfaceProps::kLegacyFontHost_In itType); | 1938 SkSurfaceProps newProps(oldProps.flags(), SkSurfaceProps::kLegacyFontHost_In itType); |
1904 if (pixelGeometryIndex > 0) { | 1939 if (pixelGeometryIndex > 0) { |
1905 newProps = SkSurfaceProps(oldProps.flags(), | 1940 newProps = SkSurfaceProps(oldProps.flags(), |
1906 gPixelGeometryStates[pixelGeometryIndex].pixel Geometry); | 1941 gPixelGeometryStates[pixelGeometryIndex].pixel Geometry); |
1907 } | 1942 } |
1908 this->setSurfaceProps(newProps); | 1943 this->setSurfaceProps(newProps); |
1909 | 1944 |
1910 this->updateTitle(); | 1945 this->updateTitle(); |
(...skipping 244 matching lines...) Loading... | |
2155 fDevManager && | 2190 fDevManager && |
2156 fDevManager->getGrRenderTarget() && | 2191 fDevManager->getGrRenderTarget() && |
2157 fDevManager->getGrRenderTarget()->numColorSamples() > 0) { | 2192 fDevManager->getGrRenderTarget()->numColorSamples() > 0) { |
2158 title.appendf(" [MSAA: %d]", | 2193 title.appendf(" [MSAA: %d]", |
2159 fDevManager->getGrRenderTarget()->numColorSamples()); | 2194 fDevManager->getGrRenderTarget()->numColorSamples()); |
2160 } | 2195 } |
2161 #endif | 2196 #endif |
2162 | 2197 |
2163 title.appendf(" %s", find_config_name(this->info())); | 2198 title.appendf(" %s", find_config_name(this->info())); |
2164 | 2199 |
2200 if (fTenBitColor) { | |
2201 title.append(" 10 bpc"); | |
2202 } | |
2203 | |
2165 if (gTreatSkColorAsSRGB) { | 2204 if (gTreatSkColorAsSRGB) { |
2166 title.append(" sRGB"); | 2205 title.append(" sRGB"); |
2167 } | 2206 } |
2168 | 2207 |
2169 this->setTitle(title.c_str()); | 2208 this->setTitle(title.c_str()); |
2170 } | 2209 } |
2171 | 2210 |
2172 void SampleWindow::onSizeChange() { | 2211 void SampleWindow::onSizeChange() { |
2173 this->INHERITED::onSizeChange(); | 2212 this->INHERITED::onSizeChange(); |
2174 | 2213 |
(...skipping 226 matching lines...) Loading... | |
2401 #ifdef SK_BUILD_FOR_MAC | 2440 #ifdef SK_BUILD_FOR_MAC |
2402 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2441 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2403 #endif | 2442 #endif |
2404 SkGraphics::Init(); | 2443 SkGraphics::Init(); |
2405 SkEvent::Init(); | 2444 SkEvent::Init(); |
2406 } | 2445 } |
2407 | 2446 |
2408 void application_term() { | 2447 void application_term() { |
2409 SkEvent::Term(); | 2448 SkEvent::Term(); |
2410 } | 2449 } |
OLD | NEW |