| 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 "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 { | 32 { |
| 33 return IntSize(m_image->width(), m_image->height()); | 33 return IntSize(m_image->width(), m_image->height()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool StaticBitmapImage::currentFrameKnownToBeOpaque() | 36 bool StaticBitmapImage::currentFrameKnownToBeOpaque() |
| 37 { | 37 { |
| 38 return m_image->isOpaque(); | 38 return m_image->isOpaque(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const Float
Rect& dstRect, | 41 void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const Float
Rect& dstRect, |
| 42 const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode cla
mpMode) | 42 const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode cla
mpMode, const KURL&) |
| 43 { | 43 { |
| 44 ASSERT(dstRect.width() >= 0 && dstRect.height() >= 0); | 44 ASSERT(dstRect.width() >= 0 && dstRect.height() >= 0); |
| 45 ASSERT(srcRect.width() >= 0 && srcRect.height() >= 0); | 45 ASSERT(srcRect.width() >= 0 && srcRect.height() >= 0); |
| 46 | 46 |
| 47 FloatRect adjustedSrcRect = srcRect; | 47 FloatRect adjustedSrcRect = srcRect; |
| 48 adjustedSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height(
))); | 48 adjustedSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height(
))); |
| 49 | 49 |
| 50 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty()) | 50 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty()) |
| 51 return; // Nothing to draw. | 51 return; // Nothing to draw. |
| 52 | 52 |
| 53 ASSERT(adjustedSrcRect.width() <= m_image->width() && adjustedSrcRect.height
() <= m_image->height()); | 53 ASSERT(adjustedSrcRect.width() <= m_image->width() && adjustedSrcRect.height
() <= m_image->height()); |
| 54 | 54 |
| 55 SkRect srcSkRect = adjustedSrcRect; | 55 SkRect srcSkRect = adjustedSrcRect; |
| 56 canvas->drawImageRect(m_image.get(), srcSkRect, dstRect, &paint, | 56 canvas->drawImageRect(m_image.get(), srcSkRect, dstRect, &paint, |
| 57 WebCoreClampingModeToSkiaRectConstraint(clampMode)); | 57 WebCoreClampingModeToSkiaRectConstraint(clampMode)); |
| 58 | 58 |
| 59 if (ImageObserver* observer = imageObserver()) | 59 if (ImageObserver* observer = imageObserver()) |
| 60 observer->didDraw(this); | 60 observer->didDraw(this); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |