| 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/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
| 10 #include "core/frame/ImageBitmap.h" | 11 #include "core/frame/ImageBitmap.h" |
| 11 #include "core/html/ImageData.h" | 12 #include "core/html/ImageData.h" |
| 12 #include "core/html/canvas/CanvasAsyncBlobCreator.h" | 13 #include "core/html/canvas/CanvasAsyncBlobCreator.h" |
| 13 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 14 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 14 #include "core/html/canvas/CanvasRenderingContext.h" | 15 #include "core/html/canvas/CanvasRenderingContext.h" |
| 15 #include "core/html/canvas/CanvasRenderingContextFactory.h" | 16 #include "core/html/canvas/CanvasRenderingContextFactory.h" |
| 16 #include "platform/graphics/Image.h" | 17 #include "platform/graphics/Image.h" |
| 17 #include "platform/graphics/ImageBuffer.h" | 18 #include "platform/graphics/ImageBuffer.h" |
| 18 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" | 19 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 331 } |
| 331 if (!image_data) { | 332 if (!image_data) { |
| 332 exception_state.ThrowDOMException( | 333 exception_state.ThrowDOMException( |
| 333 kInvalidStateError, "OffscreenCanvas object has no rendering contexts"); | 334 kInvalidStateError, "OffscreenCanvas object has no rendering contexts"); |
| 334 return exception_state.Reject(script_state); | 335 return exception_state.Reject(script_state); |
| 335 } | 336 } |
| 336 | 337 |
| 337 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 338 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
| 338 | 339 |
| 339 Document* document = | 340 Document* document = |
| 340 script_state->GetExecutionContext()->IsDocument() | 341 ExecutionContext::From(script_state)->IsDocument() |
| 341 ? static_cast<Document*>(script_state->GetExecutionContext()) | 342 ? static_cast<Document*>(ExecutionContext::From(script_state)) |
| 342 : nullptr; | 343 : nullptr; |
| 343 | 344 |
| 344 CanvasAsyncBlobCreator* async_creator = CanvasAsyncBlobCreator::Create( | 345 CanvasAsyncBlobCreator* async_creator = CanvasAsyncBlobCreator::Create( |
| 345 image_data->data(), encoding_mime_type, image_data->size(), start_time, | 346 image_data->data(), encoding_mime_type, image_data->size(), start_time, |
| 346 document, resolver); | 347 document, resolver); |
| 347 | 348 |
| 348 async_creator->ScheduleAsyncBlobCreation(options.quality()); | 349 async_creator->ScheduleAsyncBlobCreation(options.quality()); |
| 349 | 350 |
| 350 return resolver->Promise(); | 351 return resolver->Promise(); |
| 351 } | 352 } |
| 352 | 353 |
| 353 DEFINE_TRACE(OffscreenCanvas) { | 354 DEFINE_TRACE(OffscreenCanvas) { |
| 354 visitor->Trace(context_); | 355 visitor->Trace(context_); |
| 355 visitor->Trace(execution_context_); | 356 visitor->Trace(execution_context_); |
| 356 visitor->Trace(commit_promise_resolver_); | 357 visitor->Trace(commit_promise_resolver_); |
| 357 EventTargetWithInlineData::Trace(visitor); | 358 EventTargetWithInlineData::Trace(visitor); |
| 358 } | 359 } |
| 359 | 360 |
| 360 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |