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

Side by Side Diff: ui/gfx/color_space.cc

Issue 2752523006: cc: Use SkCreateColorSpaceXformCanvas for color transforms (Closed)
Patch Set: Allow to link Created 3 years, 9 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
« cc/playback/raster_source.h ('K') | « ui/gfx/color_space.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/color_space.h" 5 #include "ui/gfx/color_space.h"
6 6
7 #include <map> 7 #include <map>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 // Use the parametric transfer function if no other option is available. 411 // Use the parametric transfer function if no other option is available.
412 SkColorSpaceTransferFn fn; 412 SkColorSpaceTransferFn fn;
413 if (!GetTransferFunction(&fn)) { 413 if (!GetTransferFunction(&fn)) {
414 DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace"; 414 DLOG(ERROR) << "Failed to parameterize transfer function for SkColorSpace";
415 return nullptr; 415 return nullptr;
416 } 416 }
417 return SkColorSpace::MakeRGB(fn, to_xyz_d50); 417 return SkColorSpace::MakeRGB(fn, to_xyz_d50);
418 } 418 }
419 419
420 sk_sp<SkColorSpace> ColorSpace::ToNonlinearBlendedSkColorSpace() const {
421 if (!IsValid()) {
422 DLOG(ERROR) << "Cannot create SkColorSpace for invalid space.";
423 return nullptr;
424 }
425 if (matrix_ != MatrixID::RGB) {
426 DLOG(ERROR) << "Not creating non-RGB SkColorSpace";
427 return nullptr;
428 }
429 if (range_ != RangeID::FULL) {
430 DLOG(ERROR) << "Not creating non-full-range SkColorSpace";
431 return nullptr;
432 }
433
434 SkMatrix44 primaries;
435 GetPrimaryMatrix(&primaries);
436 SkColorSpaceTransferFn tr_fn;
437 if (!GetTransferFunction(&tr_fn)) {
438 DLOG(ERROR) << "Not creating non-parametric nonlinear-blended SkColorSpace";
439 return nullptr;
440 }
441 return SkColorSpace::MakeRGB(tr_fn, primaries,
442 SkColorSpace::kNonLinearBlending_ColorSpaceFlag);
443 }
444
445 bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const { 420 bool ColorSpace::GetICCProfile(ICCProfile* icc_profile) const {
446 if (!IsValid()) { 421 if (!IsValid()) {
447 DLOG(ERROR) << "Cannot fetch ICCProfile for invalid space."; 422 DLOG(ERROR) << "Cannot fetch ICCProfile for invalid space.";
448 return false; 423 return false;
449 } 424 }
450 if (matrix_ != MatrixID::RGB) { 425 if (matrix_ != MatrixID::RGB) {
451 DLOG(ERROR) << "Not creating non-RGB ICCProfile"; 426 DLOG(ERROR) << "Not creating non-RGB ICCProfile";
452 return false; 427 return false;
453 } 428 }
454 if (range_ != RangeID::FULL) { 429 if (range_ != RangeID::FULL) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); 805 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f);
831 break; 806 break;
832 } 807 }
833 } 808 }
834 809
835 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { 810 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) {
836 return out << color_space.ToString(); 811 return out << color_space.ToString();
837 } 812 }
838 813
839 } // namespace gfx 814 } // namespace gfx
OLDNEW
« cc/playback/raster_source.h ('K') | « ui/gfx/color_space.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698