| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 context_->Reset(); | 71 context_->Reset(); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 size_ = size; | 74 size_ = size; |
| 75 if (frame_dispatcher_) { | 75 if (frame_dispatcher_) { |
| 76 frame_dispatcher_->Reshape(size_.Width(), size_.Height()); | 76 frame_dispatcher_->Reshape(size_.Width(), size_.Height()); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void OffscreenCanvas::SetNeutered() { | 80 void OffscreenCanvas::SetNeutered() { |
| 81 ASSERT(!context_); | 81 DCHECK(!context_); |
| 82 is_neutered_ = true; | 82 is_neutered_ = true; |
| 83 size_.SetWidth(0); | 83 size_.SetWidth(0); |
| 84 size_.SetHeight(0); | 84 size_.SetHeight(0); |
| 85 } | 85 } |
| 86 | 86 |
| 87 ImageBitmap* OffscreenCanvas::transferToImageBitmap( | 87 ImageBitmap* OffscreenCanvas::transferToImageBitmap( |
| 88 ScriptState* script_state, | 88 ScriptState* script_state, |
| 89 ExceptionState& exception_state) { | 89 ExceptionState& exception_state) { |
| 90 if (is_neutered_) { | 90 if (is_neutered_) { |
| 91 exception_state.ThrowDOMException( | 91 exception_state.ThrowDOMException( |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 int type) { | 202 int type) { |
| 203 ASSERT(type < CanvasRenderingContext::kContextTypeCount); | 203 ASSERT(type < CanvasRenderingContext::kContextTypeCount); |
| 204 return RenderingContextFactories()[type].get(); | 204 return RenderingContextFactories()[type].get(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void OffscreenCanvas::RegisterRenderingContextFactory( | 207 void OffscreenCanvas::RegisterRenderingContextFactory( |
| 208 std::unique_ptr<CanvasRenderingContextFactory> rendering_context_factory) { | 208 std::unique_ptr<CanvasRenderingContextFactory> rendering_context_factory) { |
| 209 CanvasRenderingContext::ContextType type = | 209 CanvasRenderingContext::ContextType type = |
| 210 rendering_context_factory->GetContextType(); | 210 rendering_context_factory->GetContextType(); |
| 211 ASSERT(type < CanvasRenderingContext::kContextTypeCount); | 211 ASSERT(type < CanvasRenderingContext::kContextTypeCount); |
| 212 ASSERT(!RenderingContextFactories()[type]); | 212 DCHECK(!RenderingContextFactories()[type]); |
| 213 RenderingContextFactories()[type] = std::move(rendering_context_factory); | 213 RenderingContextFactories()[type] = std::move(rendering_context_factory); |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool OffscreenCanvas::OriginClean() const { | 216 bool OffscreenCanvas::OriginClean() const { |
| 217 return origin_clean_ && !disable_reading_from_canvas_; | 217 return origin_clean_ && !disable_reading_from_canvas_; |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool OffscreenCanvas::IsPaintable() const { | 220 bool OffscreenCanvas::IsPaintable() const { |
| 221 if (!context_) | 221 if (!context_) |
| 222 return ImageBuffer::CanCreateImageBuffer(size_); | 222 return ImageBuffer::CanCreateImageBuffer(size_); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 402 } |
| 403 | 403 |
| 404 DEFINE_TRACE(OffscreenCanvas) { | 404 DEFINE_TRACE(OffscreenCanvas) { |
| 405 visitor->Trace(context_); | 405 visitor->Trace(context_); |
| 406 visitor->Trace(execution_context_); | 406 visitor->Trace(execution_context_); |
| 407 visitor->Trace(commit_promise_resolver_); | 407 visitor->Trace(commit_promise_resolver_); |
| 408 EventTargetWithInlineData::Trace(visitor); | 408 EventTargetWithInlineData::Trace(visitor); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace blink | 411 } // namespace blink |
| OLD | NEW |