aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/SkImage_Reference.bmh18
-rw-r--r--include/core/SkImage.h6
-rw-r--r--src/image/SkImage.cpp4
-rw-r--r--src/image/SkImage_Base.h1
-rw-r--r--src/image/SkImage_Gpu.cpp7
-rw-r--r--src/image/SkImage_Gpu.h1
-rw-r--r--src/image/SkImage_Lazy.cpp3
-rw-r--r--src/image/SkImage_Raster.cpp3
8 files changed, 42 insertions, 1 deletions
diff --git a/docs/SkImage_Reference.bmh b/docs/SkImage_Reference.bmh
index d11fa1c35f..f45862af5f 100644
--- a/docs/SkImage_Reference.bmh
+++ b/docs/SkImage_Reference.bmh
@@ -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 ##
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 30637a6d34..d8612f01e9 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -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.
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 7b90d6e7ed..4eebef7eae 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -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();
}
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 903cd826be..b3bbbc4080 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -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; }
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 7c842f69c0..38f38c91ed 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -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 {
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 24a8c78869..3c536a4013 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -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;
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index 4adf4e8368..4c12b81a26 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -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();
}
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 3ed3a8aea4..688f71c673 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -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();
}