| Index: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| index 5cd759c6dbf5937ca00aefae778bc9e647accec9..2cc6fe50aca1df31153f9b94cd090c4145a53fd1 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
|
| @@ -130,16 +130,19 @@ size_t BitmapImage::totalFrameBytes() {
|
| return totalBytes;
|
| }
|
|
|
| -sk_sp<SkImage> BitmapImage::decodeAndCacheFrame(size_t index) {
|
| +sk_sp<SkImage> BitmapImage::decodeAndCacheFrame(
|
| + size_t index,
|
| + sk_sp<SkColorSpace> targetColorSpace) {
|
| size_t numFrames = frameCount();
|
| if (m_frames.size() < numFrames)
|
| m_frames.grow(numFrames);
|
|
|
| // We are caching frame snapshots. This is OK even for partially decoded
|
| // frames, as they are cleared by dataChanged() when new data arrives.
|
| - sk_sp<SkImage> image = m_source.createFrameAtIndex(index);
|
| + sk_sp<SkImage> image = m_source.createFrameAtIndex(index, targetColorSpace);
|
| m_cachedFrame = image;
|
| m_cachedFrameIndex = index;
|
| + m_cachedFrameColorSpace = std::move(targetColorSpace);
|
|
|
| m_frames[index].m_orientation = m_source.orientationAtIndex(index);
|
| m_frames[index].m_haveMetadata = true;
|
| @@ -246,9 +249,21 @@ void BitmapImage::draw(
|
| const FloatRect& srcRect,
|
| RespectImageOrientationEnum shouldRespectImageOrientation,
|
| ImageClampingMode clampMode) {
|
| + drawInColorSpace(canvas, paint, dstRect, srcRect,
|
| + shouldRespectImageOrientation, clampMode, nullptr);
|
| +}
|
| +
|
| +void BitmapImage::drawInColorSpace(
|
| + SkCanvas* canvas,
|
| + const SkPaint& paint,
|
| + const FloatRect& dstRect,
|
| + const FloatRect& srcRect,
|
| + RespectImageOrientationEnum shouldRespectImageOrientation,
|
| + ImageClampingMode clampMode,
|
| + sk_sp<SkColorSpace> targetColorSpace) {
|
| TRACE_EVENT0("skia", "BitmapImage::draw");
|
|
|
| - sk_sp<SkImage> image = imageForCurrentFrame();
|
| + sk_sp<SkImage> image = frameAtIndex(currentFrame(), targetColorSpace);
|
| if (!image)
|
| return; // It's too early and we don't have an image yet.
|
|
|
| @@ -324,14 +339,22 @@ bool BitmapImage::isSizeAvailable() {
|
| return m_sizeAvailable;
|
| }
|
|
|
| -sk_sp<SkImage> BitmapImage::frameAtIndex(size_t index) {
|
| +sk_sp<SkImage> BitmapImage::frameAtIndex(size_t index,
|
| + sk_sp<SkColorSpace> targetColorSpace) {
|
| if (index >= frameCount())
|
| return nullptr;
|
|
|
| - if (index == m_cachedFrameIndex && m_cachedFrame)
|
| + // This should default to the global one with the mode off, otherwise
|
| + // default to sRGB.
|
| + if (!targetColorSpace)
|
| + targetColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
|
| +
|
| + if (index == m_cachedFrameIndex && m_cachedFrame &&
|
| + SkColorSpace::Equals(targetColorSpace.get(),
|
| + m_cachedFrameColorSpace.get()))
|
| return m_cachedFrame;
|
|
|
| - return decodeAndCacheFrame(index);
|
| + return decodeAndCacheFrame(index, targetColorSpace);
|
| }
|
|
|
| bool BitmapImage::frameIsCompleteAtIndex(size_t index) const {
|
|
|