| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "core/frame/ImageBitmap.h" | 6 #include "core/frame/ImageBitmap.h" |
| 7 | 7 |
| 8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
| 9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
| 10 #include "core/html/ImageData.h" | 10 #include "core/html/ImageData.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 PassRefPtr<Image> ImageBitmap::bitmapImage() const | 195 PassRefPtr<Image> ImageBitmap::bitmapImage() const |
| 196 { | 196 { |
| 197 ASSERT((m_imageElement || m_bitmap || !m_bitmapRect.width() || !m_bitmapRect
.height()) && (!m_imageElement || !m_bitmap)); | 197 ASSERT((m_imageElement || m_bitmap || !m_bitmapRect.width() || !m_bitmapRect
.height()) && (!m_imageElement || !m_bitmap)); |
| 198 if (m_imageElement) | 198 if (m_imageElement) |
| 199 return m_imageElement->cachedImage()->image(); | 199 return m_imageElement->cachedImage()->image(); |
| 200 return m_bitmap; | 200 return m_bitmap; |
| 201 } | 201 } |
| 202 | 202 |
| 203 PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas(SourceImageMode, SourceIm
ageStatus* status) const |
| 204 { |
| 205 *status = NormalSourceImageStatus; |
| 206 return bitmapImage(); |
| 203 } | 207 } |
| 208 |
| 209 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const |
| 210 { |
| 211 FloatRect intersectRect = intersection(m_bitmapRect, *srcRect); |
| 212 FloatRect newSrcRect = intersectRect; |
| 213 newSrcRect.move(m_bitmapOffset - m_bitmapRect.location()); |
| 214 FloatRect newDstRect(FloatPoint(intersectRect.location() - srcRect->location
()), m_bitmapRect.size()); |
| 215 newDstRect.scale(dstRect->width() / srcRect->width() * intersectRect.width()
/ m_bitmapRect.width(), |
| 216 dstRect->height() / srcRect->height() * intersectRect.height() / m_bitma
pRect.height()); |
| 217 newDstRect.moveBy(dstRect->location()); |
| 218 *srcRect = newSrcRect; |
| 219 *dstRect = newDstRect; |
| 220 } |
| 221 |
| 222 FloatSize ImageBitmap::sourceSize() const |
| 223 { |
| 224 return FloatSize(width(), height()); |
| 225 } |
| 226 |
| 227 } |
| OLD | NEW |