Chromium Code Reviews| Index: Source/platform/graphics/BitmapImage.cpp |
| diff --git a/Source/platform/graphics/BitmapImage.cpp b/Source/platform/graphics/BitmapImage.cpp |
| index a62674ff7b0948e2aed2663ce68f7c4b957c0408..76e97f2d6204255b9b491334678f97a716dda586 100644 |
| --- a/Source/platform/graphics/BitmapImage.cpp |
| +++ b/Source/platform/graphics/BitmapImage.cpp |
| @@ -30,6 +30,7 @@ |
| #include "platform/Timer.h" |
| #include "platform/TraceEvent.h" |
| #include "platform/geometry/FloatRect.h" |
| +#include "platform/graphics/ColorSpaceFilter.h" |
| #include "platform/graphics/GraphicsContextStateSaver.h" |
| #include "platform/graphics/ImageObserver.h" |
| #include "platform/graphics/skia/NativeImageSkia.h" |
| @@ -244,16 +245,6 @@ bool BitmapImage::dataChanged(bool allDataReceived) |
| return isSizeAvailable(); |
| } |
| -bool BitmapImage::isAllDataReceived() const |
| -{ |
| - return m_allDataReceived; |
| -} |
| - |
| -bool BitmapImage::hasColorProfile() const |
| -{ |
| - return m_source.hasColorProfile(); |
| -} |
| - |
| String BitmapImage::filenameExtension() const |
| { |
| return m_source.filenameExtension(); |
| @@ -271,13 +262,13 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const Fl |
| // causing flicker and wasting CPU. |
| startAnimation(); |
| - RefPtr<NativeImageSkia> bm = nativeImageForCurrentFrame(); |
| - if (!bm) |
| + RefPtr<NativeImageSkia> bitmap = nativeImageForCurrentFrame(); |
| + if (!bitmap) |
| return; // It's too early and we don't have an image yet. |
| FloatRect normDstRect = adjustForNegativeSize(dstRect); |
| FloatRect normSrcRect = adjustForNegativeSize(srcRect); |
| - normSrcRect.intersect(FloatRect(0, 0, bm->bitmap().width(), bm->bitmap().height())); |
| + normSrcRect.intersect(FloatRect(0, 0, bitmap->bitmap().width(), bitmap->bitmap().height())); |
| if (normSrcRect.isEmpty() || normDstRect.isEmpty()) |
| return; // Nothing to draw. |
| @@ -303,12 +294,62 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const Fl |
| } |
| } |
| - bm->draw(ctxt, normSrcRect, normDstRect, WebCoreCompositeToSkiaComposite(compositeOp, blendMode)); |
| + // Tagged images (those that have a color profile) are drawn color-correct on supported platforms. |
| + |
| + if (RefPtr<ColorSpaceProfile> source = colorProfile()) { |
| + RefPtr<ColorSpaceProfile> screen = screenColorProfile(currentScreenId()); |
| + |
| + RefPtr<SkColorFilter> colorTransform = createColorSpaceFilter(source.get(), screen.get()); |
|
sugoi1
2014/08/29 18:51:11
Note: If you put "RefPtr<SkColorFilter> colorTrans
Noel Gordon
2014/09/01 16:48:39
Yeah possible. I wrote it this way because colorPr
|
| + bitmap->draw(ctxt, normSrcRect, normDstRect, WebCoreCompositeToSkiaComposite(compositeOp, blendMode), colorTransform); |
| + |
| + if (ImageObserver* observer = imageObserver()) |
| + observer->didDraw(this); |
| + |
| + return; |
| + } |
| + |
| + // FIXME: untagged images should be drawn from sRGB color space, per CSS2.1 onwards, a change that |
| + // would also require that all CSS content, including <canvas>, be drawn from sRGB space to match, |
| + // and the same for plugins (Flash, NaCl), which don't define their color space at all. |
| + |
| + bitmap->draw(ctxt, normSrcRect, normDstRect, WebCoreCompositeToSkiaComposite(compositeOp, blendMode)); |
| if (ImageObserver* observer = imageObserver()) |
| observer->didDraw(this); |
| } |
| +void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const FloatSize& scale, |
| + const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& destRect, blink::WebBlendMode blendMode, const IntSize& repeatSpacing) |
| +{ |
| + TRACE_EVENT0("skia", "Image::drawPattern"); |
| + |
| + RefPtr<NativeImageSkia> bitmap = nativeImageForCurrentFrame(); |
| + if (!bitmap) |
| + return; |
| + |
| + // Tagged images (those that have a color profile) are drawn color-correct on supported platforms. |
| + |
| + if (RefPtr<ColorSpaceProfile> source = colorProfile()) { |
| + RefPtr<ColorSpaceProfile> screen = screenColorProfile(currentScreenId()); |
| + |
| + RefPtr<SkColorFilter> colorTransform = createColorSpaceFilter(source.get(), screen.get()); |
|
sugoi1
2014/08/29 18:51:11
Same here
|
| + bitmap->drawPattern(ctxt, adjustForNegativeSize(srcRect), scale, phase, compositeOp, destRect, blendMode, repeatSpacing, colorTransform); |
| + |
| + return; |
| + } |
| + |
| + // FIXME: untagged images should be drawn from sRGB color space, per CSS2.1 onwards, a change that |
| + // would also require that all CSS content, including <canvas>, be drawn from sRGB space to match, |
| + // and the same for plugins (Flash, NaCl), which don't define their color space at all. |
| + |
| + bitmap->drawPattern(ctxt, adjustForNegativeSize(srcRect), scale, phase, compositeOp, destRect, blendMode, repeatSpacing); |
| +} |
| + |
| +void BitmapImage::resetDecoder() |
| +{ |
| + m_source.resetDecoder(); |
| +} |
| + |
| size_t BitmapImage::frameCount() |
| { |
| if (!m_haveFrameCount) { |