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 | |
1370 void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, | 1356 void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, |
1371 float sx, float sy, float sw, float sh, | 1357 float sx, float sy, float sw, float sh, |
1372 float dx, float dy, float dw, float dh, ExceptionState& exceptionState) | 1358 float dx, float dy, float dw, float dh, ExceptionState& exceptionState) |
1373 { | 1359 { |
1374 if (!drawingCanvas()) | 1360 if (!drawingCanvas()) |
1375 return; | 1361 return; |
1376 | 1362 |
1377 RefPtr<Image> image; | 1363 RefPtr<Image> image; |
1378 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; | 1364 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; |
1379 if (!imageSource->isVideoElement()) { | 1365 if (!imageSource->isVideoElement()) { |
(...skipping 15 matching lines...) Expand all Loading... |
1395 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); | 1381 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); |
1396 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); | 1382 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); |
1397 | 1383 |
1398 clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->elementSize()), &s
rcRect, &dstRect); | 1384 clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->elementSize()), &s
rcRect, &dstRect); |
1399 | 1385 |
1400 imageSource->adjustDrawRects(&srcRect, &dstRect); | 1386 imageSource->adjustDrawRects(&srcRect, &dstRect); |
1401 | 1387 |
1402 if (srcRect.isEmpty()) | 1388 if (srcRect.isEmpty()) |
1403 return; | 1389 return; |
1404 | 1390 |
1405 if (shouldDisableDeferral(imageSource)) | 1391 // FIXME: crbug.com/521001 |
| 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()) |
1406 canvas()->disableDeferral(); | 1397 canvas()->disableDeferral(); |
1407 | 1398 |
1408 validateStateStack(); | 1399 validateStateStack(); |
1409 | 1400 |
1410 draw( | 1401 draw( |
1411 [this, &imageSource, &image, &srcRect, dstRect](SkCanvas* c, const SkPai
nt* paint) // draw lambda | 1402 [this, &imageSource, &image, &srcRect, dstRect](SkCanvas* c, const SkPai
nt* paint) // draw lambda |
1412 { | 1403 { |
1413 drawImageInternal(c, imageSource, image.get(), srcRect, dstRect, pai
nt); | 1404 drawImageInternal(c, imageSource, image.get(), srcRect, dstRect, pai
nt); |
1414 }, | 1405 }, |
1415 [this, &dstRect](const SkIRect& clipBounds) // overdraw test lambda | 1406 [this, &dstRect](const SkIRect& clipBounds) // overdraw test lambda |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) | 2311 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) |
2321 return; | 2312 return; |
2322 if (alpha < 0xFF) | 2313 if (alpha < 0xFF) |
2323 return; | 2314 return; |
2324 } | 2315 } |
2325 | 2316 |
2326 canvas()->buffer()->willOverwriteCanvas(); | 2317 canvas()->buffer()->willOverwriteCanvas(); |
2327 } | 2318 } |
2328 | 2319 |
2329 } // namespace blink | 2320 } // namespace blink |
OLD | NEW |