OLD | NEW |
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, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 c->translate(dstRect.x(), dstRect.y()); | 1346 c->translate(dstRect.x(), dstRect.y()); |
1347 c->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.h
eight()); | 1347 c->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.h
eight()); |
1348 c->translate(-srcRect.x(), -srcRect.y()); | 1348 c->translate(-srcRect.x(), -srcRect.y()); |
1349 HTMLVideoElement* video = static_cast<HTMLVideoElement*>(imageSource); | 1349 HTMLVideoElement* video = static_cast<HTMLVideoElement*>(imageSource); |
1350 video->paintCurrentFrame(c, IntRect(IntPoint(), IntSize(video->videoWidt
h(), video->videoHeight())), &imagePaint); | 1350 video->paintCurrentFrame(c, IntRect(IntPoint(), IntSize(video->videoWidt
h(), video->videoHeight())), &imagePaint); |
1351 } | 1351 } |
1352 | 1352 |
1353 c->restoreToCount(initialSaveCount); | 1353 c->restoreToCount(initialSaveCount); |
1354 } | 1354 } |
1355 | 1355 |
| 1356 bool shouldDisableDeferral(CanvasImageSource* imageSource) |
| 1357 { |
| 1358 if (imageSource->isVideoElement()) |
| 1359 return true; |
| 1360 if (imageSource->isCanvasElement()) { |
| 1361 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(imageSource)
; |
| 1362 if (canvas->is3D()) |
| 1363 return true; |
| 1364 if (canvas->isAnimated2D()) |
| 1365 return true; |
| 1366 } |
| 1367 return false; |
| 1368 } |
| 1369 |
1356 void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, | 1370 void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, |
1357 float sx, float sy, float sw, float sh, | 1371 float sx, float sy, float sw, float sh, |
1358 float dx, float dy, float dw, float dh, ExceptionState& exceptionState) | 1372 float dx, float dy, float dw, float dh, ExceptionState& exceptionState) |
1359 { | 1373 { |
1360 if (!drawingCanvas()) | 1374 if (!drawingCanvas()) |
1361 return; | 1375 return; |
1362 | 1376 |
1363 RefPtr<Image> image; | 1377 RefPtr<Image> image; |
1364 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; | 1378 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; |
1365 if (!imageSource->isVideoElement()) { | 1379 if (!imageSource->isVideoElement()) { |
(...skipping 15 matching lines...) Expand all Loading... |
1381 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); | 1395 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); |
1382 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); | 1396 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); |
1383 | 1397 |
1384 clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->elementSize()), &s
rcRect, &dstRect); | 1398 clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->elementSize()), &s
rcRect, &dstRect); |
1385 | 1399 |
1386 imageSource->adjustDrawRects(&srcRect, &dstRect); | 1400 imageSource->adjustDrawRects(&srcRect, &dstRect); |
1387 | 1401 |
1388 if (srcRect.isEmpty()) | 1402 if (srcRect.isEmpty()) |
1389 return; | 1403 return; |
1390 | 1404 |
1391 // FIXME: crbug.com/521001 | 1405 if (shouldDisableDeferral(imageSource)) |
1392 // We make the destination canvas fall out of display list mode by forcing | |
1393 // immediate rendering. This is to prevent run-away memory consumption cause
d by SkSurface | |
1394 // copyOnWrite when the source canvas is animated and consumed at a rate hig
her than the | |
1395 // presentation frame rate of the destination canvas. | |
1396 if (imageSource->isVideoElement() || imageSource->isCanvasElement()) | |
1397 canvas()->disableDeferral(); | 1406 canvas()->disableDeferral(); |
1398 | 1407 |
1399 validateStateStack(); | 1408 validateStateStack(); |
1400 | 1409 |
1401 draw( | 1410 draw( |
1402 [this, &imageSource, &image, &srcRect, dstRect](SkCanvas* c, const SkPai
nt* paint) // draw lambda | 1411 [this, &imageSource, &image, &srcRect, dstRect](SkCanvas* c, const SkPai
nt* paint) // draw lambda |
1403 { | 1412 { |
1404 drawImageInternal(c, imageSource, image.get(), srcRect, dstRect, pai
nt); | 1413 drawImageInternal(c, imageSource, image.get(), srcRect, dstRect, pai
nt); |
1405 }, | 1414 }, |
1406 [this, &dstRect](const SkIRect& clipBounds) // overdraw test lambda | 1415 [this, &dstRect](const SkIRect& clipBounds) // overdraw test lambda |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) | 2320 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) |
2312 return; | 2321 return; |
2313 if (alpha < 0xFF) | 2322 if (alpha < 0xFF) |
2314 return; | 2323 return; |
2315 } | 2324 } |
2316 | 2325 |
2317 canvas()->buffer()->willOverwriteCanvas(); | 2326 canvas()->buffer()->willOverwriteCanvas(); |
2318 } | 2327 } |
2319 | 2328 |
2320 } // namespace blink | 2329 } // namespace blink |
OLD | NEW |