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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 19393004: Allow eviction of ImageBitmaps that are created from ImageElements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use CachedImage as the backing store for ImageBitmap. Implement O(1) decode cache. Created 7 years, 5 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 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
8 * Copyright (C) 2012 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012 Intel Corporation. All rights reserved.
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 FloatRect dstRect(dx, dy, dw, dh); 1253 FloatRect dstRect(dx, dy, dw, dh);
1254 1254
1255 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi nite(dstRect.width()) || !std::isfinite(dstRect.height()) 1255 if (!std::isfinite(dstRect.x()) || !std::isfinite(dstRect.y()) || !std::isfi nite(dstRect.width()) || !std::isfinite(dstRect.height())
1256 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i sfinite(srcRect.width()) || !std::isfinite(srcRect.height())) 1256 || !std::isfinite(srcRect.x()) || !std::isfinite(srcRect.y()) || !std::i sfinite(srcRect.width()) || !std::isfinite(srcRect.height()))
1257 return; 1257 return;
1258 1258
1259 if (!dstRect.width() || !dstRect.height()) 1259 if (!dstRect.width() || !dstRect.height())
1260 return; 1260 return;
1261 1261
1262 ASSERT(bitmap->height() && bitmap->width()); 1262 ASSERT(bitmap->height() && bitmap->width());
1263
1264 FloatRect normalizedSrcRect = normalizeRect(srcRect); 1263 FloatRect normalizedSrcRect = normalizeRect(srcRect);
1265 FloatRect normalizedDstRect = normalizeRect(dstRect); 1264 FloatRect normalizedDstRect = normalizeRect(dstRect);
1266 FloatRect actualDstRect(FloatPoint(bitmap->bitmapOffset()), bitmap->bitmapSi ze()); 1265 FloatRect actualDstRect(FloatPoint(bitmap->bitmapOffset()), bitmap->bitmapSi ze());
1267 actualDstRect.scale(normalizedDstRect.width() / bitmap->width(), normalizedD stRect.height() / bitmap->height()); 1266 actualDstRect.scale(normalizedDstRect.width() / bitmap->width(), normalizedD stRect.height() / bitmap->height());
1268 actualDstRect.moveBy(normalizedDstRect.location()); 1267 actualDstRect.moveBy(normalizedDstRect.location());
1269 1268
1270 FloatRect imageRect = FloatRect(FloatPoint(), bitmap->bitmapSize()); 1269 FloatRect imageRect = FloatRect(FloatPoint(), bitmap->bitmapSize());
1271 if (!srcRect.width() || !srcRect.height()) { 1270 if (!srcRect.width() || !srcRect.height()) {
1272 ec = IndexSizeError; 1271 ec = IndexSizeError;
1273 return; 1272 return;
1274 } 1273 }
1275 if (!imageRect.contains(normalizedSrcRect)) 1274 if (!imageRect.contains(normalizedSrcRect))
1276 return; 1275 return;
1276 RefPtr<Image> imageForRendering = bitmap->bitmapImage();
1277 1277
1278 Image* imageForRendering = bitmap->bitmapImage(); 1278 drawImageInternal(imageForRendering.get(), normalizedSrcRect, actualDstRect, state().m_globalComposite, state().m_globalBlend);
1279
1280 drawImageInternal(imageForRendering, normalizedSrcRect, actualDstRect, state ().m_globalComposite, state().m_globalBlend);
1281 } 1279 }
1282 1280
1283 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionCode& ec) 1281 void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionCode& ec)
1284 { 1282 {
1285 if (!image) { 1283 if (!image) {
1286 ec = TypeMismatchError; 1284 ec = TypeMismatchError;
1287 return; 1285 return;
1288 } 1286 }
1289 LayoutSize s = size(image); 1287 LayoutSize s = size(image);
1290 drawImage(image, x, y, s.width(), s.height(), ec); 1288 drawImage(image, x, y, s.width(), s.height(), ec);
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 } 2299 }
2302 2300
2303 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const 2301 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const
2304 { 2302 {
2305 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); 2303 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate();
2306 attributes->setAlpha(m_hasAlpha); 2304 attributes->setAlpha(m_hasAlpha);
2307 return attributes.release(); 2305 return attributes.release();
2308 } 2306 }
2309 2307
2310 } // namespace WebCore 2308 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698