| 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 GrColorInfo_DEFINED |
| 9 |
#define GrColorInfo_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkAlphaType.h" |
| 12 |
#include "include/core/SkRefCnt.h" |
| 13 |
#include "include/private/gpu/ganesh/GrTypesPriv.h" |
| 14 |
#include "src/gpu/ganesh/GrColorSpaceXform.h" |
| 15 |
|
| 16 |
class SkColorInfo; |
| 17 |
class SkColorSpace; |
| 18 |
/** |
| 19 |
* All the info needed to interpret a color: Color type + alpha type + color space. Also caches |
| 20 |
* the GrColorSpaceXform from sRGB. */ |
| 21 |
class GrColorInfo { |
| 22 |
public: |
| 23 |
GrColorInfo(); |
| 24 |
GrColorInfo(const GrColorInfo&); |
| 25 |
GrColorInfo& operator=(const GrColorInfo&); |
| 26 |
GrColorInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>); |
| 27 |
/* implicit */ GrColorInfo(const SkColorInfo&); |
| 28 |
~GrColorInfo(); |
| 29 |
|
| 30 |
bool operator==(const GrColorInfo& that) const; |
| 31 |
bool operator!=(const GrColorInfo& that) const { return !(*this == that); } |
| 32 |
|
| 33 |
GrColorInfo makeColorType(GrColorType ct) const; |
| 34 |
|
| 35 |
bool isLinearlyBlended() const; |
| 36 |
|
| 37 |
SkColorSpace* colorSpace() const; |
| 38 |
sk_sp<SkColorSpace> refColorSpace() const; |
| 39 |
|
| 40 |
GrColorSpaceXform* colorSpaceXformFromSRGB() const { return fColorXformFromSRGB.get(); } |
| 41 |
sk_sp<GrColorSpaceXform> refColorSpaceXformFromSRGB() const { return fColorXformFromSRGB; } |
| 42 |
|
| 43 |
GrColorType colorType() const { return fColorType; } |
| 44 |
SkAlphaType alphaType() const { return fAlphaType; } |
| 45 |
|
| 46 |
bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fColorType); } |
| 47 |
|
| 48 |
bool isValid() const { |
| 49 |
return fColorType != GrColorType::kUnknown && fAlphaType != kUnknown_SkAlphaType; |
| 50 |
} |
| 51 |
|
| 52 |
private: |
| 53 |
sk_sp<SkColorSpace> fColorSpace; |
| 54 |
sk_sp<GrColorSpaceXform> fColorXformFromSRGB; |
| 55 |
GrColorType fColorType = GrColorType::kUnknown; |
| 56 |
SkAlphaType fAlphaType = kUnknown_SkAlphaType; |
| 57 |
}; |
| 58 |
|
| 59 |
#endif |