Index: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
index a1adcce004f065ad73110d3e77733144419bfd66..d1814934929f549f513a6f171004faaaefa7b354 100644 |
--- a/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp |
@@ -67,18 +67,14 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, |
{ |
TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "index", static_cast<int>(m_frameIndex)); |
- // Implementation doesn't support scaling yet so make sure we're not given a different size. |
- if (info.width() != getInfo().width() || info.height() != getInfo().height()) |
- return false; |
- |
if (info.colorType() != getInfo().colorType()) { |
- // ImageFrame may have changed the owning SkBitmap to kOpaque_SkAlphaType after sniffing the encoded data, so if we see a request |
- // for opaque, that is ok even if our initial alphatype was not opaque. |
- return false; |
+ // So far, only one implemented is RGB565 |
+ if (info.colorType() != kRGB_565_SkColorType) |
+ return false; |
} |
PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); |
- bool decoded = m_frameGenerator->decodeAndScale(getInfo(), m_frameIndex, pixels, rowBytes); |
+ bool decoded = m_frameGenerator->decodeAndScale(info, m_frameIndex, pixels, rowBytes); |
PlatformInstrumentation::didDecodeLazyPixelRef(); |
return decoded; |
@@ -125,5 +121,22 @@ SkImageGenerator* DecodingImageGenerator::create(SkData* data) |
return new DecodingImageGenerator(frame, info, 0); |
} |
+SkImageGenerator::Result DecodingImageGenerator::onCanDecodeAndScale(const SkColorType targetType, |
+ const SkScalar scale, SkISize* availableSize, SkISize* lowerSize) |
+{ |
+ SkColorType readC = targetType; |
+ float desired = SkScalarToFloat(scale); |
+ float read = desired; |
+ float lower = 0; |
+ m_frameGenerator->getAvailableDecodeAndScale(&readC, &read, &lower); |
+ if (availableSize) |
+ availableSize->set(static_cast<int>(ceil(getInfo().width() * read)), static_cast<int>(ceil(getInfo().height() * read))); |
+ if (lowerSize) |
+ lowerSize->set(static_cast<int>(ceil(getInfo().width() * lower)), static_cast<int>(ceil(getInfo().height() * lower))); |
+ |
+ return static_cast<SkImageGenerator::Result>(((desired != 1.0f && read != 1.0f) ? SkImageGenerator::kScale : SkImageGenerator::kNotAvailable) |
+ | ((readC == targetType) ? SkImageGenerator::kDecode : SkImageGenerator::kNotAvailable)); |
+} |
+ |
} // namespace blink |