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

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: Fix bad assert 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
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
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 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 if (isInvalEvent(evt)) { 1526 if (isInvalEvent(evt)) {
1526 this->inval(nullptr); 1527 this->inval(nullptr);
1527 return true; 1528 return true;
1528 } 1529 }
1529 int selected = -1; 1530 int selected = -1;
1530 if (SkOSMenu::FindListIndex(evt, "Device Type", &selected)) { 1531 if (SkOSMenu::FindListIndex(evt, "Device Type", &selected)) {
1531 this->setDeviceType((DeviceType)selected); 1532 this->setDeviceType((DeviceType)selected);
1532 return true; 1533 return true;
1533 } 1534 }
1534 if (SkOSMenu::FindListIndex(evt, "ColorType", &selected)) { 1535 if (SkOSMenu::FindListIndex(evt, "ColorType", &selected)) {
1535 this->setDeviceColorType(gConfig[selected].fColorType, gConfig[selected] .fProfileType); 1536 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
1537 this->setDeviceColorType(gConfig[selected].fColorType,
1538 gConfig[selected].fSRGB ? srgbColorSpace : null ptr);
1536 return true; 1539 return true;
1537 } 1540 }
1538 if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) { 1541 if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) {
1539 this->toggleSlideshow(); 1542 this->toggleSlideshow();
1540 return true; 1543 return true;
1541 } 1544 }
1542 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) || 1545 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) ||
1543 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) || 1546 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) ||
1544 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) || 1547 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) ||
1545 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || 1548 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) ||
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 return; 1743 return;
1741 1744
1742 fDevManager->tearDownBackend(this); 1745 fDevManager->tearDownBackend(this);
1743 fDeviceType = type; 1746 fDeviceType = type;
1744 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); 1747 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor);
1745 1748
1746 this->updateTitle(); 1749 this->updateTitle();
1747 this->inval(nullptr); 1750 this->inval(nullptr);
1748 } 1751 }
1749 1752
1750 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { 1753 void SampleWindow::setDeviceColorType(SkColorType ct, sk_sp<SkColorSpace> cs) {
1751 this->setColorType(ct, pt); 1754 this->setColorType(ct, std::move(cs));
1752 1755
1753 fDevManager->tearDownBackend(this); 1756 fDevManager->tearDownBackend(this);
1754 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor); 1757 fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor);
1755 1758
1756 this->updateTitle(); 1759 this->updateTitle();
1757 this->inval(nullptr); 1760 this->inval(nullptr);
1758 } 1761 }
1759 1762
1760 void SampleWindow::toggleSlideshow() { 1763 void SampleWindow::toggleSlideshow() {
1761 fAnimating = !fAnimating; 1764 fAnimating = !fAnimating;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 #ifdef SK_BUILD_FOR_MAC 2245 #ifdef SK_BUILD_FOR_MAC
2243 setenv("ANDROID_ROOT", "/android/device/data", 0); 2246 setenv("ANDROID_ROOT", "/android/device/data", 0);
2244 #endif 2247 #endif
2245 SkGraphics::Init(); 2248 SkGraphics::Init();
2246 SkEvent::Init(); 2249 SkEvent::Init();
2247 } 2250 }
2248 2251
2249 void application_term() { 2252 void application_term() {
2250 SkEvent::Term(); 2253 SkEvent::Term();
2251 } 2254 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698