Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: samplecode/SampleApp.cpp

Issue 2069173002: Lots of progress switching to SkColorSpace rather than SkColorProfileType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use new shared sRGB similarity function Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
41 # include "SkGr.h" 41 # include "SkGr.h"
42 # if SK_ANGLE 42 # if SK_ANGLE
43 # include "gl/angle/GLTestContext_angle.h" 43 # include "gl/angle/GLTestContext_angle.h"
44 # endif 44 # endif
45 #else 45 #else
46 class GrContext; 46 class GrContext;
47 #endif 47 #endif
48 48
49 const struct { 49 const struct {
50 SkColorType fColorType; 50 SkColorType fColorType;
51 SkColorProfileType fProfileType; 51 bool fSRGB;
Brian Osman 2016/06/16 15:15:06 Not using sk_sp<SkColorSpace> here to avoid static
msarett 2016/06/16 15:56:04 Acknowledged.
52 const char* fName; 52 const char* fName;
53 } gConfig[] = { 53 } gConfig[] = {
54 { kN32_SkColorType, kLinear_SkColorProfileType, "L32" }, 54 { kN32_SkColorType, false, "L32" },
55 { kN32_SkColorType, kSRGB_SkColorProfileType, "S32" }, 55 { kN32_SkColorType, true, "S32" },
56 { kRGBA_F16_SkColorType, kLinear_SkColorProfileType, "F16" }, 56 { kRGBA_F16_SkColorType, false, "F16" },
57 }; 57 };
58 58
59 static const char* find_config_name(const SkImageInfo& info) { 59 static const char* find_config_name(const SkImageInfo& info) {
60 for (const auto& config : gConfig) { 60 for (const auto& config : gConfig) {
61 if (config.fColorType == info.colorType() && config.fProfileType == info .profileType()) { 61 if (config.fColorType == info.colorType() &&
62 config.fSRGB == (info.colorSpace() != nullptr)) {
62 return config.fName; 63 return config.fName;
63 } 64 }
64 } 65 }
65 return "???"; 66 return "???";
66 } 67 }
67 68
68 // Should be 3x + 1 69 // Should be 3x + 1
69 #define kMaxFatBitsScale 28 70 #define kMaxFatBitsScale 28
70 71
71 extern SampleView* CreateSamplePictFileView(const char filename[]); 72 extern SampleView* CreateSamplePictFileView(const char filename[]);
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 if (isInvalEvent(evt)) { 1629 if (isInvalEvent(evt)) {
1629 this->inval(nullptr); 1630 this->inval(nullptr);
1630 return true; 1631 return true;
1631 } 1632 }
1632 int selected = -1; 1633 int selected = -1;
1633 if (SkOSMenu::FindListIndex(evt, "Device Type", &selected)) { 1634 if (SkOSMenu::FindListIndex(evt, "Device Type", &selected)) {
1634 this->setDeviceType((DeviceType)selected); 1635 this->setDeviceType((DeviceType)selected);
1635 return true; 1636 return true;
1636 } 1637 }
1637 if (SkOSMenu::FindListIndex(evt, "ColorType", &selected)) { 1638 if (SkOSMenu::FindListIndex(evt, "ColorType", &selected)) {
1638 this->setDeviceColorType(gConfig[selected].fColorType, gConfig[selected] .fProfileType); 1639 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
1640 this->setDeviceColorType(gConfig[selected].fColorType,
1641 gConfig[selected].fSRGB ? srgbColorSpace : null ptr);
1639 return true; 1642 return true;
1640 } 1643 }
1641 if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) { 1644 if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) {
1642 this->toggleSlideshow(); 1645 this->toggleSlideshow();
1643 return true; 1646 return true;
1644 } 1647 }
1645 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) || 1648 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) ||
1646 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) || 1649 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) ||
1647 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) || 1650 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) ||
1648 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || 1651 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) ||
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 return; 1846 return;
1844 1847
1845 fDevManager->tearDownBackend(this); 1848 fDevManager->tearDownBackend(this);
1846 fDeviceType = type; 1849 fDeviceType = type;
1847 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); 1850 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor);
1848 1851
1849 this->updateTitle(); 1852 this->updateTitle();
1850 this->inval(nullptr); 1853 this->inval(nullptr);
1851 } 1854 }
1852 1855
1853 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { 1856 void SampleWindow::setDeviceColorType(SkColorType ct, sk_sp<SkColorSpace> cs) {
1854 this->setColorType(ct, pt); 1857 this->setColorType(ct, std::move(cs));
1855 1858
1856 fDevManager->tearDownBackend(this); 1859 fDevManager->tearDownBackend(this);
1857 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); 1860 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor);
1858 1861
1859 this->updateTitle(); 1862 this->updateTitle();
1860 this->inval(nullptr); 1863 this->inval(nullptr);
1861 } 1864 }
1862 1865
1863 void SampleWindow::toggleSlideshow() { 1866 void SampleWindow::toggleSlideshow() {
1864 fAnimating = !fAnimating; 1867 fAnimating = !fAnimating;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 #ifdef SK_BUILD_FOR_MAC 2402 #ifdef SK_BUILD_FOR_MAC
2400 setenv("ANDROID_ROOT", "/android/device/data", 0); 2403 setenv("ANDROID_ROOT", "/android/device/data", 0);
2401 #endif 2404 #endif
2402 SkGraphics::Init(); 2405 SkGraphics::Init();
2403 SkEvent::Init(); 2406 SkEvent::Init();
2404 } 2407 }
2405 2408
2406 void application_term() { 2409 void application_term() {
2407 SkEvent::Term(); 2410 SkEvent::Term();
2408 } 2411 }
OLDNEW
« example/HelloWorld.cpp ('K') | « samplecode/SampleApp.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698