| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/StaticBitmapImage.h" | 6 #include "platform/graphics/StaticBitmapImage.h" |
| 7 | 7 |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/ImageObserver.h" | 9 #include "platform/graphics/ImageObserver.h" |
| 10 #include "platform/graphics/skia/NativeImageSkia.h" | 10 #include "platform/graphics/skia/NativeImageSkia.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 IntSize StaticBitmapImage::size() const | 30 IntSize StaticBitmapImage::size() const |
| 31 { | 31 { |
| 32 return IntSize(m_image->width(), m_image->height()); | 32 return IntSize(m_image->width(), m_image->height()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool StaticBitmapImage::currentFrameKnownToBeOpaque() | 35 bool StaticBitmapImage::currentFrameKnownToBeOpaque() |
| 36 { | 36 { |
| 37 return m_image->isOpaque(); | 37 return m_image->isOpaque(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void StaticBitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, con
st FloatRect& srcRect, CompositeOperator compositeOp, WebBlendMode blendMode, Re
spectImageOrientationEnum) | 40 void StaticBitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, con
st FloatRect& srcRect, SkXfermode::Mode compositeOp, RespectImageOrientationEnum
) |
| 41 { | 41 { |
| 42 FloatRect normDstRect = adjustForNegativeSize(dstRect); | 42 FloatRect normDstRect = adjustForNegativeSize(dstRect); |
| 43 FloatRect normSrcRect = adjustForNegativeSize(srcRect); | 43 FloatRect normSrcRect = adjustForNegativeSize(srcRect); |
| 44 | 44 |
| 45 normSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height())); | 45 normSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height())); |
| 46 | 46 |
| 47 if (normSrcRect.isEmpty() || normDstRect.isEmpty()) | 47 if (normSrcRect.isEmpty() || normDstRect.isEmpty()) |
| 48 return; // Nothing to draw. | 48 return; // Nothing to draw. |
| 49 | 49 |
| 50 ASSERT(normSrcRect.width() <= m_image->width() && normSrcRect.height() <= m_
image->height()); | 50 ASSERT(normSrcRect.width() <= m_image->width() && normSrcRect.height() <= m_
image->height()); |
| 51 | 51 |
| 52 { | 52 { |
| 53 SkCanvas* canvas = ctx->canvas(); | 53 SkCanvas* canvas = ctx->canvas(); |
| 54 | 54 |
| 55 SkPaint paint; | 55 SkPaint paint; |
| 56 int initialSaveCount = ctx->preparePaintForDrawRectToRect(&paint, srcRec
t, dstRect, compositeOp, blendMode, !currentFrameKnownToBeOpaque()); | 56 int initialSaveCount = ctx->preparePaintForDrawRectToRect(&paint, srcRec
t, dstRect, compositeOp, !currentFrameKnownToBeOpaque()); |
| 57 | 57 |
| 58 SkRect srcSkRect = WebCoreFloatRectToSKRect(normSrcRect); | 58 SkRect srcSkRect = WebCoreFloatRectToSKRect(normSrcRect); |
| 59 SkRect dstSkRect = WebCoreFloatRectToSKRect(normDstRect); | 59 SkRect dstSkRect = WebCoreFloatRectToSKRect(normDstRect); |
| 60 | 60 |
| 61 canvas->drawImageRect(m_image.get(), &srcSkRect, dstSkRect, &paint); | 61 canvas->drawImageRect(m_image.get(), &srcSkRect, dstSkRect, &paint); |
| 62 canvas->restoreToCount(initialSaveCount); | 62 canvas->restoreToCount(initialSaveCount); |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (ImageObserver* observer = imageObserver()) | 65 if (ImageObserver* observer = imageObserver()) |
| 66 observer->didDraw(this); | 66 observer->didDraw(this); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace blink | 69 } // namespace blink |
| OLD | NEW |