| 1 |
/* |
| 2 |
* Copyright 2022 Google LLC |
| 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 |
#include "src/gpu/ganesh/GrImageInfo.h" |
| 9 |
|
| 10 |
#include "include/core/SkColorSpace.h" |
| 11 |
#include "include/core/SkImageInfo.h" |
| 12 |
|
| 13 |
#include <utility> |
| 14 |
|
| 15 |
GrImageInfo::GrImageInfo() = default; |
| 16 |
|
| 17 |
GrImageInfo::GrImageInfo(const SkImageInfo& info) |
| 18 |
: fColorInfo(info.colorInfo()), fDimensions(info.dimensions()) {} |
| 19 |
|
| 20 |
GrImageInfo::GrImageInfo(GrColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs, int w, int h) |
| 21 |
: fColorInfo(ct, at, std::move(cs)), fDimensions{w,h} {} |
| 22 |
|
| 23 |
GrImageInfo::GrImageInfo(GrColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs, |
| 24 |
const SkISize& dimensions) |
| 25 |
: fColorInfo(ct, at, std::move(cs)), fDimensions(dimensions) {} |
| 26 |
|
| 27 |
GrImageInfo::GrImageInfo(const GrColorInfo& info, const SkISize& dimensions) |
| 28 |
: fColorInfo(info), fDimensions(dimensions) {} |
| 29 |
|
| 30 |
GrImageInfo::GrImageInfo(GrColorInfo&& info, const SkISize& dimensions) |
| 31 |
: fColorInfo(std::move(info)), fDimensions(dimensions) {} |
| 32 |
|
| 33 |
GrImageInfo::GrImageInfo(const GrImageInfo&) = default; |
| 34 |
GrImageInfo::GrImageInfo(GrImageInfo&&) = default; |
| 35 |
GrImageInfo& GrImageInfo::operator=(const GrImageInfo&) = default; |
| 36 |
GrImageInfo& GrImageInfo::operator=(GrImageInfo&&) = default; |
| 37 |
|
| 38 |
GrImageInfo GrImageInfo::makeColorType(GrColorType ct) const { |
| 39 |
return {this->colorInfo().makeColorType(ct), this->dimensions()}; |
| 40 |
} |
| 41 |
|
| 42 |
GrImageInfo GrImageInfo::makeAlphaType(SkAlphaType at) const { |
| 43 |
return {this->colorType(), at, this->refColorSpace(), this->width(), this->height()}; |
| 44 |
} |
| 45 |
|
| 46 |
GrImageInfo GrImageInfo::makeColorSpace(sk_sp<SkColorSpace> cs) const { |
| 47 |
return {this->colorType(), this->alphaType(), std::move(cs), this->width(), this->height()}; |
| 48 |
} |
| 49 |
|
| 50 |
GrImageInfo GrImageInfo::makeDimensions(SkISize dimensions) const { |
| 51 |
return {this->colorType(), this->alphaType(), this->refColorSpace(), dimensions}; |
| 52 |
} |
| 53 |
|
| 54 |
GrImageInfo GrImageInfo::makeWH(int width, int height) const { |
| 55 |
return {this->colorType(), this->alphaType(), this->refColorSpace(), width, height}; |
| 56 |
} |
| 57 |
|
| 58 |
sk_sp<SkColorSpace> GrImageInfo::refColorSpace() const { return fColorInfo.refColorSpace(); } |