1 /* 2 * Copyright 2017 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrColorSpaceInfo_DEFINED 9 #define GrColorSpaceInfo_DEFINED 10 11 #include "GrColorSpaceXform.h" 12 #include "GrTypes.h" 13 #include "SkColorSpace.h" 14 #include "SkRefCnt.h" 15 16 /** Describes the color space properties of a surface context. */ 17 class GrColorSpaceInfo { 18 public: 19 GrColorSpaceInfo(sk_sp<SkColorSpace>, GrPixelConfig); 20 21 bool isGammaCorrect() const { return static_cast<bool>(fColorSpace); } 22 23 SkColorSpace* colorSpace() const { return fColorSpace.get(); } 24 sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; } 25 26 GrColorSpaceXform* colorSpaceXformFromSRGB() const; 27 sk_sp<GrColorSpaceXform> refColorSpaceXformFromSRGB() const { 28 return sk_ref_sp(this->colorSpaceXformFromSRGB()); 29 } 30 31 // TODO: Remove or replace with SkColorType 32 GrPixelConfig config() const { return fConfig; } 33 34 private: 35 sk_sp<SkColorSpace> fColorSpace; 36 mutable sk_sp<GrColorSpaceXform> fColorXformFromSRGB; 37 GrPixelConfig fConfig; 38 mutable bool fInitializedColorSpaceXformFromSRGB; 39 }; 40 41 #endif 42