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

Side by Side Diff: src/core/SkColorSpace.cpp

Issue 2098583002: SkMatrix44 clarifications and clean-ups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/codec/SkPngCodec.cpp ('k') | src/core/SkMatrix44.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 2016 Google Inc. 2 * Copyright 2016 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 "SkColorSpace.h" 8 #include "SkColorSpace.h"
9 #include "SkColorSpace_Base.h" 9 #include "SkColorSpace_Base.h"
10 #include "SkEndian.h" 10 #include "SkEndian.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) { 135 sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
136 static SkOnce sRGBOnce; 136 static SkOnce sRGBOnce;
137 static SkColorSpace* sRGB; 137 static SkColorSpace* sRGB;
138 static SkOnce adobeRGBOnce; 138 static SkOnce adobeRGBOnce;
139 static SkColorSpace* adobeRGB; 139 static SkColorSpace* adobeRGB;
140 140
141 switch (named) { 141 switch (named) {
142 case kSRGB_Named: { 142 case kSRGB_Named: {
143 sRGBOnce([] { 143 sRGBOnce([] {
144 SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); 144 SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
145 srgbToxyzD50.set3x3ColMajorf(gSRGB_toXYZD50); 145 srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50);
146 sRGB = new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50, kSR GB_Named); 146 sRGB = new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50, kSR GB_Named);
147 }); 147 });
148 return sk_ref_sp(sRGB); 148 return sk_ref_sp(sRGB);
149 } 149 }
150 case kAdobeRGB_Named: { 150 case kAdobeRGB_Named: {
151 adobeRGBOnce([] { 151 adobeRGBOnce([] {
152 SkMatrix44 adobergbToxyzD50(SkMatrix44::kUninitialized_Construct or); 152 SkMatrix44 adobergbToxyzD50(SkMatrix44::kUninitialized_Construct or);
153 adobergbToxyzD50.set3x3ColMajorf(gAdobeRGB_toXYZD50); 153 adobergbToxyzD50.set3x3RowMajorf(gAdobeRGB_toXYZD50);
154 adobeRGB = new SkColorSpace_Base(k2Dot2Curve_GammaNamed, adoberg bToxyzD50, 154 adobeRGB = new SkColorSpace_Base(k2Dot2Curve_GammaNamed, adoberg bToxyzD50,
155 kAdobeRGB_Named); 155 kAdobeRGB_Named);
156 }); 156 });
157 return sk_ref_sp(adobeRGB); 157 return sk_ref_sp(adobeRGB);
158 } 158 }
159 default: 159 default:
160 break; 160 break;
161 } 161 }
162 return nullptr; 162 return nullptr;
163 } 163 }
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 const ICCTag* b = ICCTag::Find(tags.get(), tagCount, kTAG_bXYZ); 890 const ICCTag* b = ICCTag::Find(tags.get(), tagCount, kTAG_bXYZ);
891 if (r && g && b) { 891 if (r && g && b) {
892 float toXYZ[9]; 892 float toXYZ[9];
893 if (!load_xyz(&toXYZ[0], r->addr((const uint8_t*) base), r->fLen gth) || 893 if (!load_xyz(&toXYZ[0], r->addr((const uint8_t*) base), r->fLen gth) ||
894 !load_xyz(&toXYZ[3], g->addr((const uint8_t*) base), g->fLen gth) || 894 !load_xyz(&toXYZ[3], g->addr((const uint8_t*) base), g->fLen gth) ||
895 !load_xyz(&toXYZ[6], b->addr((const uint8_t*) base), b->fLen gth)) 895 !load_xyz(&toXYZ[6], b->addr((const uint8_t*) base), b->fLen gth))
896 { 896 {
897 return_null("Need valid rgb tags for XYZ space"); 897 return_null("Need valid rgb tags for XYZ space");
898 } 898 }
899 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); 899 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
900 mat.set3x3ColMajorf(toXYZ); 900 mat.set3x3RowMajorf(toXYZ);
901 901
902 // It is not uncommon to see missing or empty gamma tags. This indicates 902 // It is not uncommon to see missing or empty gamma tags. This indicates
903 // that we should use unit gamma. 903 // that we should use unit gamma.
904 SkGammaCurve curves[3]; 904 SkGammaCurve curves[3];
905 r = ICCTag::Find(tags.get(), tagCount, kTAG_rTRC); 905 r = ICCTag::Find(tags.get(), tagCount, kTAG_rTRC);
906 g = ICCTag::Find(tags.get(), tagCount, kTAG_gTRC); 906 g = ICCTag::Find(tags.get(), tagCount, kTAG_gTRC);
907 b = ICCTag::Find(tags.get(), tagCount, kTAG_bTRC); 907 b = ICCTag::Find(tags.get(), tagCount, kTAG_bTRC);
908 if (!r || !load_gammas(&curves[0], 1, r->addr((const uint8_t*) b ase), r->fLength)) 908 if (!r || !load_gammas(&curves[0], 1, r->addr((const uint8_t*) b ase), r->fLength))
909 { 909 {
910 SkColorSpacePrintf("Failed to read R gamma tag.\n"); 910 SkColorSpacePrintf("Failed to read R gamma tag.\n");
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 1350
1351 uint32_t profileSize = *((uint32_t*) data); 1351 uint32_t profileSize = *((uint32_t*) data);
1352 data = SkTAddOffset<const void>(data, sizeof(uint32_t)); 1352 data = SkTAddOffset<const void>(data, sizeof(uint32_t));
1353 length -= sizeof(uint32_t); 1353 length -= sizeof(uint32_t);
1354 if (length < profileSize) { 1354 if (length < profileSize) {
1355 return nullptr; 1355 return nullptr;
1356 } 1356 }
1357 1357
1358 return NewICC(data, profileSize); 1358 return NewICC(data, profileSize);
1359 } 1359 }
OLDNEW
« no previous file with comments | « src/codec/SkPngCodec.cpp ('k') | src/core/SkMatrix44.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698