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

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

Issue 1307143005: Make 2D canvas smarter about chosing whether or not to use GPU acceleration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: migrated to chromium repo Created 5 years, 3 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect) 85 ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect)
86 : m_imageElement(nullptr) 86 : m_imageElement(nullptr)
87 , m_cropRect(cropRect) 87 , m_cropRect(cropRect)
88 , m_bitmapOffset(IntPoint()) 88 , m_bitmapOffset(IntPoint())
89 { 89 {
90 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size()) ); 90 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvas->size()) );
91 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size()); 91 m_bitmapRect = IntRect(IntPoint(std::max(0, -cropRect.x()), std::max(0, -cro pRect.y())), srcRect.size());
92 ASSERT(canvas->isPaintable()); 92 ASSERT(canvas->isPaintable());
93 m_bitmap = cropImage(canvas->copiedImage(BackBuffer), cropRect); 93 m_bitmap = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration), cr opRect);
94 } 94 }
95 95
96 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect) 96 ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
97 : m_imageElement(nullptr) 97 : m_imageElement(nullptr)
98 , m_cropRect(cropRect) 98 , m_cropRect(cropRect)
99 , m_bitmapOffset(IntPoint()) 99 , m_bitmapOffset(IntPoint())
100 { 100 {
101 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size())); 101 IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
102 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size()); 102 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(data->size());
103 if (!buffer) 103 if (!buffer)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 PassRefPtr<Image> ImageBitmap::bitmapImage() const 192 PassRefPtr<Image> ImageBitmap::bitmapImage() const
193 { 193 {
194 ASSERT((m_imageElement || m_bitmap || !m_bitmapRect.width() || !m_bitmapRect .height()) && (!m_imageElement || !m_bitmap)); 194 ASSERT((m_imageElement || m_bitmap || !m_bitmapRect.width() || !m_bitmapRect .height()) && (!m_imageElement || !m_bitmap));
195 if (m_imageElement) 195 if (m_imageElement)
196 return m_imageElement->cachedImage()->image(); 196 return m_imageElement->cachedImage()->image();
197 return m_bitmap; 197 return m_bitmap;
198 } 198 }
199 199
200 PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas(SourceImageStatus* status ) const 200 PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas(SourceImageStatus* status , AccelerationHint) const
201 { 201 {
202 *status = NormalSourceImageStatus; 202 *status = NormalSourceImageStatus;
203 return bitmapImage(); 203 return bitmapImage();
204 } 204 }
205 205
206 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const 206 void ImageBitmap::adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const
207 { 207 {
208 FloatRect intersectRect = intersection(m_bitmapRect, *srcRect); 208 FloatRect intersectRect = intersection(m_bitmapRect, *srcRect);
209 FloatRect newSrcRect = intersectRect; 209 FloatRect newSrcRect = intersectRect;
210 newSrcRect.move(m_bitmapOffset - m_bitmapRect.location()); 210 newSrcRect.move(m_bitmapOffset - m_bitmapRect.location());
(...skipping 10 matching lines...) Expand all
221 return FloatSize(width(), height()); 221 return FloatSize(width(), height());
222 } 222 }
223 223
224 DEFINE_TRACE(ImageBitmap) 224 DEFINE_TRACE(ImageBitmap)
225 { 225 {
226 visitor->trace(m_imageElement); 226 visitor->trace(m_imageElement);
227 ImageLoaderClient::trace(visitor); 227 ImageLoaderClient::trace(visitor);
228 } 228 }
229 229
230 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698