| 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 imageData = ImageData::create(m_size); | 634 imageData = ImageData::create(m_size); |
| 635 | 635 |
| 636 if ((!m_context || !imageData) && !placeholderFrame()) | 636 if ((!m_context || !imageData) && !placeholderFrame()) |
| 637 return imageData; | 637 return imageData; |
| 638 | 638 |
| 639 DCHECK((m_context && m_context->is2d()) || placeholderFrame()); | 639 DCHECK((m_context && m_context->is2d()) || placeholderFrame()); |
| 640 sk_sp<SkImage> snapshot; | 640 sk_sp<SkImage> snapshot; |
| 641 if (hasImageBuffer()) { | 641 if (hasImageBuffer()) { |
| 642 snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason); | 642 snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason); |
| 643 } else if (placeholderFrame()) { | 643 } else if (placeholderFrame()) { |
| 644 DCHECK(placeholderFrame()->originClean()); |
| 644 // TODO(ccameron): Canvas should produce sRGB images. | 645 // TODO(ccameron): Canvas should produce sRGB images. |
| 645 // https://crbug.com/672299 | 646 // https://crbug.com/672299 |
| 646 snapshot = placeholderFrame()->imageForCurrentFrame( | 647 snapshot = placeholderFrame()->imageForCurrentFrame( |
| 647 ColorBehavior::transformToGlobalTarget()); | 648 ColorBehavior::transformToGlobalTarget()); |
| 648 } | 649 } |
| 649 | 650 |
| 650 if (snapshot) { | 651 if (snapshot) { |
| 651 SkImageInfo imageInfo = SkImageInfo::Make( | 652 SkImageInfo imageInfo = SkImageInfo::Make( |
| 652 width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); | 653 width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); |
| 653 snapshot->readPixels(imageInfo, imageData->data()->data(), | 654 snapshot->readPixels(imageInfo, imageData->data()->data(), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 } | 776 } |
| 776 | 777 |
| 777 SecurityOrigin* HTMLCanvasElement::getSecurityOrigin() const { | 778 SecurityOrigin* HTMLCanvasElement::getSecurityOrigin() const { |
| 778 return document().getSecurityOrigin(); | 779 return document().getSecurityOrigin(); |
| 779 } | 780 } |
| 780 | 781 |
| 781 bool HTMLCanvasElement::originClean() const { | 782 bool HTMLCanvasElement::originClean() const { |
| 782 if (document().settings() && | 783 if (document().settings() && |
| 783 document().settings()->disableReadingFromCanvas()) | 784 document().settings()->disableReadingFromCanvas()) |
| 784 return false; | 785 return false; |
| 786 if (placeholderFrame()) |
| 787 return placeholderFrame()->originClean(); |
| 785 return m_originClean; | 788 return m_originClean; |
| 786 } | 789 } |
| 787 | 790 |
| 788 bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const { | 791 bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const { |
| 789 if (m_context && !m_context->is2d()) | 792 if (m_context && !m_context->is2d()) |
| 790 return false; | 793 return false; |
| 791 | 794 |
| 792 if (RuntimeEnabledFeatures::forceDisplayList2dCanvasEnabled()) | 795 if (RuntimeEnabledFeatures::forceDisplayList2dCanvasEnabled()) |
| 793 return false; | 796 return false; |
| 794 | 797 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 mojom::blink::OffscreenCanvasSurfacePtr service; | 1401 mojom::blink::OffscreenCanvasSurfacePtr service; |
| 1399 Platform::current()->interfaceProvider()->getInterface( | 1402 Platform::current()->interfaceProvider()->getInterface( |
| 1400 mojo::GetProxy(&service)); | 1403 mojo::GetProxy(&service)); |
| 1401 m_surfaceLayerBridge = | 1404 m_surfaceLayerBridge = |
| 1402 WTF::wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); | 1405 WTF::wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); |
| 1403 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), | 1406 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), |
| 1404 this->height()); | 1407 this->height()); |
| 1405 } | 1408 } |
| 1406 | 1409 |
| 1407 } // namespace blink | 1410 } // namespace blink |
| OLD | NEW |