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

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: applied last corrections Created 6 years, 9 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
« no previous file with comments | « Source/core/frame/ImageBitmap.h ('k') | Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(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 }
OLDNEW
« no previous file with comments | « Source/core/frame/ImageBitmap.h ('k') | Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698