Add SkColorType getter on SkImage.
Bug: skia: Change-Id: I131fb5f7faf3f54e0eb6d31b800d224e6d4963ce Reviewed-on: https://skia-review.googlesource.com/114464 Reviewed-by: Cary Clark <caryclark@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
a421112ac4
commit
56008aac75
@ -1070,6 +1070,24 @@ or was parsed from encoded data.
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
#Method SkColorType colorType() const
|
||||
#In Property
|
||||
#Line # returns Color_Type ##
|
||||
|
||||
Returns Color_Type if known; otherwise, returns kUnknown_SkColorType.
|
||||
|
||||
#Return Color_Type of Image ##
|
||||
|
||||
#Example
|
||||
// incomplete
|
||||
##
|
||||
|
||||
#SeeAlso SkImageInfo::colorType
|
||||
|
||||
#Method ##
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
#Method SkColorSpace* colorSpace() const
|
||||
#In Property
|
||||
#Line # returns Color_Space ##
|
||||
|
@ -500,6 +500,12 @@ public:
|
||||
*/
|
||||
SkAlphaType alphaType() const;
|
||||
|
||||
/** Returns SkColorType if known; otherwise, returns kUnknown_SkColorType.
|
||||
|
||||
@return SkColorType of SkImage
|
||||
*/
|
||||
SkColorType colorType() const;
|
||||
|
||||
/** Returns SkColorSpace, the range of colors, associated with SkImage. The
|
||||
reference count of SkColorSpace is unchanged. The returned SkColorSpace is
|
||||
immutable.
|
||||
|
@ -74,6 +74,10 @@ bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingH
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkColorType SkImage::colorType() const {
|
||||
return as_IB(this)->onColorType();
|
||||
}
|
||||
|
||||
SkAlphaType SkImage::alphaType() const {
|
||||
return as_IB(this)->onAlphaType();
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
// Implementors: if you can not return the value, return an invalid ImageInfo with w=0 & h=0
|
||||
// & unknown color space.
|
||||
virtual SkImageInfo onImageInfo() const = 0;
|
||||
virtual SkColorType onColorType() const = 0;
|
||||
virtual SkAlphaType onAlphaType() const = 0;
|
||||
|
||||
virtual bool onPeekPixels(SkPixmap*) const { return false; }
|
||||
|
@ -60,11 +60,16 @@ SkImage_Gpu::~SkImage_Gpu() {
|
||||
}
|
||||
|
||||
SkImageInfo SkImage_Gpu::onImageInfo() const {
|
||||
return SkImageInfo::Make(fProxy->width(), fProxy->height(), this->onColorType(), fAlphaType,
|
||||
fColorSpace);
|
||||
}
|
||||
|
||||
SkColorType SkImage_Gpu::onColorType() const {
|
||||
SkColorType ct;
|
||||
if (!GrPixelConfigToColorType(fProxy->config(), &ct)) {
|
||||
ct = kUnknown_SkColorType;
|
||||
}
|
||||
return SkImageInfo::Make(fProxy->width(), fProxy->height(), ct, fAlphaType, fColorSpace);
|
||||
return ct;
|
||||
}
|
||||
|
||||
bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace*, CachingHint chint) const {
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
~SkImage_Gpu() override;
|
||||
|
||||
SkImageInfo onImageInfo() const override;
|
||||
SkColorType onColorType() const override;
|
||||
SkAlphaType onAlphaType() const override { return fAlphaType; }
|
||||
|
||||
bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override;
|
||||
|
@ -70,6 +70,9 @@ public:
|
||||
SkImageInfo onImageInfo() const override {
|
||||
return fInfo;
|
||||
}
|
||||
SkColorType onColorType() const override {
|
||||
return kUnknown_SkColorType;
|
||||
}
|
||||
SkAlphaType onAlphaType() const override {
|
||||
return fInfo.alphaType();
|
||||
}
|
||||
|
@ -77,6 +77,9 @@ public:
|
||||
SkImageInfo onImageInfo() const override {
|
||||
return fBitmap.info();
|
||||
}
|
||||
SkColorType onColorType() const override {
|
||||
return fBitmap.colorType();
|
||||
}
|
||||
SkAlphaType onAlphaType() const override {
|
||||
return fBitmap.alphaType();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user