Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/offscreencanvas/OffscreenCanvas.h" | 5 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 6 | 6 |
| 7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
| 8 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 8 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 9 #include "core/html/canvas/CanvasRenderingContext.h" | 9 #include "core/html/canvas/CanvasRenderingContext.h" |
| 10 #include "core/html/canvas/CanvasRenderingContextFactory.h" | 10 #include "core/html/canvas/CanvasRenderingContextFactory.h" |
| 11 #include "platform/graphics/ImageBuffer.h" | |
| 11 #include "wtf/MathExtras.h" | 12 #include "wtf/MathExtras.h" |
| 12 #include <memory> | 13 #include <memory> |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 OffscreenCanvas::OffscreenCanvas(const IntSize& size) | 17 OffscreenCanvas::OffscreenCanvas(const IntSize& size) |
| 17 : m_size(size) | 18 : m_size(size) |
| 18 , m_originClean(true) | 19 , m_originClean(true) |
| 19 { | 20 { |
| 20 } | 21 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 ASSERT(type < CanvasRenderingContext::ContextTypeCount); | 103 ASSERT(type < CanvasRenderingContext::ContextTypeCount); |
| 103 ASSERT(!renderingContextFactories()[type]); | 104 ASSERT(!renderingContextFactories()[type]); |
| 104 renderingContextFactories()[type] = std::move(renderingContextFactory); | 105 renderingContextFactories()[type] = std::move(renderingContextFactory); |
| 105 } | 106 } |
| 106 | 107 |
| 107 bool OffscreenCanvas::originClean() const | 108 bool OffscreenCanvas::originClean() const |
| 108 { | 109 { |
| 109 return m_originClean && !m_disableReadingFromCanvas; | 110 return m_originClean && !m_disableReadingFromCanvas; |
| 110 } | 111 } |
| 111 | 112 |
| 113 bool OffscreenCanvas::isPaintable() const | |
| 114 { | |
| 115 if (!m_context) | |
| 116 return ImageBuffer::canCreateImageBuffer(m_size); | |
|
Ken Russell (switch to Gerrit)
2016/08/19 20:31:01
How reliable is this query, and how much does that
| |
| 117 return m_context->isPaintable(); | |
| 118 } | |
| 119 | |
| 112 DEFINE_TRACE(OffscreenCanvas) | 120 DEFINE_TRACE(OffscreenCanvas) |
| 113 { | 121 { |
| 114 visitor->trace(m_context); | 122 visitor->trace(m_context); |
| 115 } | 123 } |
| 116 | 124 |
| 117 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |