| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 | 513 |
| 514 if (listenerNeedsNewFrameCapture) { | 514 if (listenerNeedsNewFrameCapture) { |
| 515 SourceImageStatus status; | 515 SourceImageStatus status; |
| 516 RefPtr<Image> sourceImage = getSourceImageForCanvas( | 516 RefPtr<Image> sourceImage = getSourceImageForCanvas( |
| 517 &status, PreferNoAcceleration, SnapshotReasonCanvasListenerCapture, | 517 &status, PreferNoAcceleration, SnapshotReasonCanvasListenerCapture, |
| 518 FloatSize()); | 518 FloatSize()); |
| 519 if (status != NormalSourceImageStatus) | 519 if (status != NormalSourceImageStatus) |
| 520 return; | 520 return; |
| 521 // TODO(ccameron): Canvas should produce sRGB images. | 521 sk_sp<SkImage> image = sourceImage->imageForCurrentFrame(); |
| 522 // https://crbug.com/672299 | |
| 523 sk_sp<SkImage> image = sourceImage->imageForCurrentFrame( | |
| 524 ColorBehavior::transformToGlobalTarget()); | |
| 525 for (CanvasDrawListener* listener : m_listeners) { | 522 for (CanvasDrawListener* listener : m_listeners) { |
| 526 if (listener->needsNewFrame()) { | 523 if (listener->needsNewFrame()) { |
| 527 listener->sendNewFrame(image); | 524 listener->sendNewFrame(image); |
| 528 } | 525 } |
| 529 } | 526 } |
| 530 } | 527 } |
| 531 } | 528 } |
| 532 | 529 |
| 533 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) { | 530 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) { |
| 534 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and | 531 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 642 |
| 646 if ((!m_context || !imageData) && !placeholderFrame()) | 643 if ((!m_context || !imageData) && !placeholderFrame()) |
| 647 return imageData; | 644 return imageData; |
| 648 | 645 |
| 649 DCHECK((m_context && m_context->is2d()) || placeholderFrame()); | 646 DCHECK((m_context && m_context->is2d()) || placeholderFrame()); |
| 650 sk_sp<SkImage> snapshot; | 647 sk_sp<SkImage> snapshot; |
| 651 if (hasImageBuffer()) { | 648 if (hasImageBuffer()) { |
| 652 snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason); | 649 snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason); |
| 653 } else if (placeholderFrame()) { | 650 } else if (placeholderFrame()) { |
| 654 DCHECK(placeholderFrame()->originClean()); | 651 DCHECK(placeholderFrame()->originClean()); |
| 655 // TODO(ccameron): Canvas should produce sRGB images. | 652 snapshot = placeholderFrame()->imageForCurrentFrame(); |
| 656 // https://crbug.com/672299 | |
| 657 snapshot = placeholderFrame()->imageForCurrentFrame( | |
| 658 ColorBehavior::transformToGlobalTarget()); | |
| 659 } | 653 } |
| 660 | 654 |
| 661 if (snapshot) { | 655 if (snapshot) { |
| 662 SkImageInfo imageInfo = SkImageInfo::Make( | 656 SkImageInfo imageInfo = SkImageInfo::Make( |
| 663 width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); | 657 width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); |
| 664 snapshot->readPixels(imageInfo, imageData->data()->data(), | 658 snapshot->readPixels(imageInfo, imageData->data()->data(), |
| 665 imageInfo.minRowBytes(), 0, 0); | 659 imageInfo.minRowBytes(), 0, 0); |
| 666 } | 660 } |
| 667 | 661 |
| 668 return imageData; | 662 return imageData; |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 } else { | 1274 } else { |
| 1281 if (ExpensiveCanvasHeuristicParameters:: | 1275 if (ExpensiveCanvasHeuristicParameters:: |
| 1282 DisableAccelerationToAvoidReadbacks && | 1276 DisableAccelerationToAvoidReadbacks && |
| 1283 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled() && | 1277 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled() && |
| 1284 hint == PreferNoAcceleration && m_context->isAccelerated() && | 1278 hint == PreferNoAcceleration && m_context->isAccelerated() && |
| 1285 hasImageBuffer()) { | 1279 hasImageBuffer()) { |
| 1286 buffer()->disableAcceleration(); | 1280 buffer()->disableAcceleration(); |
| 1287 } | 1281 } |
| 1288 RefPtr<Image> image = renderingContext()->getImage(hint, reason); | 1282 RefPtr<Image> image = renderingContext()->getImage(hint, reason); |
| 1289 if (image) { | 1283 if (image) { |
| 1290 skImage = | 1284 skImage = image->imageForCurrentFrame(); |
| 1291 image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()); | |
| 1292 } else { | 1285 } else { |
| 1293 skImage = createTransparentSkImage(size()); | 1286 skImage = createTransparentSkImage(size()); |
| 1294 } | 1287 } |
| 1295 } | 1288 } |
| 1296 | 1289 |
| 1297 if (skImage) { | 1290 if (skImage) { |
| 1298 *status = NormalSourceImageStatus; | 1291 *status = NormalSourceImageStatus; |
| 1299 return StaticBitmapImage::create(std::move(skImage)); | 1292 return StaticBitmapImage::create(std::move(skImage)); |
| 1300 } | 1293 } |
| 1301 | 1294 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 // Creates a placeholder layer first before Surface is created. | 1449 // Creates a placeholder layer first before Surface is created. |
| 1457 m_surfaceLayerBridge->createSolidColorLayer(); | 1450 m_surfaceLayerBridge->createSolidColorLayer(); |
| 1458 } | 1451 } |
| 1459 } | 1452 } |
| 1460 | 1453 |
| 1461 void HTMLCanvasElement::OnWebLayerReplaced() { | 1454 void HTMLCanvasElement::OnWebLayerReplaced() { |
| 1462 setNeedsCompositingUpdate(); | 1455 setNeedsCompositingUpdate(); |
| 1463 } | 1456 } |
| 1464 | 1457 |
| 1465 } // namespace blink | 1458 } // namespace blink |
| OLD | NEW |