Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: Source/core/frame/ImageBitmap.cpp

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(HTMLCanvasElement*, Excep tionState&, CanvasImageSourceUsage usage, bool* isVolatile) const
204 {
205 if (isVolatile)
206 *isVolatile = false;
207 return bitmapImage();
203 } 208 }
209
210 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const
211 {
212 FloatRect intersectRect = intersection(m_bitmapRect, *srcRect);
213 FloatRect newSrcRect = intersectRect;
214 newSrcRect.move(m_bitmapOffset - m_bitmapRect.location());
215 FloatRect newDstRect(FloatPoint(intersectRect.location() - srcRect->location ()), m_bitmapRect.size());
216 newDstRect.scale(dstRect->width() / srcRect->width() * intersectRect.width() / m_bitmapRect.width(),
217 dstRect->height() / srcRect->height() * intersectRect.height() / m_bitma pRect.height());
218 newDstRect.moveBy(dstRect->location());
219 *srcRect = newSrcRect;
220 *dstRect = newDstRect;
221 }
222
223 FloatSize ImageBitmap::sourceSize() const
224 {
225 return FloatSize(width(), height());
226 }
227
228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698