| 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/html/canvas/CanvasAsyncBlobCreator.h" | 5 #include "core/html/canvas/CanvasAsyncBlobCreator.h" |
| 6 | 6 |
| 7 #include "core/fileapi/Blob.h" | 7 #include "core/fileapi/Blob.h" |
| 8 #include "platform/ThreadSafeFunctional.h" | 8 #include "platform/ThreadSafeFunctional.h" |
| 9 #include "platform/graphics/ImageBuffer.h" | 9 #include "platform/graphics/ImageBuffer.h" |
| 10 #include "platform/image-encoders/JPEGImageEncoder.h" | 10 #include "platform/image-encoders/JPEGImageEncoder.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 m_data.clear(); | 271 m_data.clear(); |
| 272 m_callback.clear(); | 272 m_callback.clear(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void CanvasAsyncBlobCreator::encodeImageOnEncoderThread(double quality) | 275 void CanvasAsyncBlobCreator::encodeImageOnEncoderThread(double quality) |
| 276 { | 276 { |
| 277 ASSERT(!isMainThread()); | 277 ASSERT(!isMainThread()); |
| 278 ASSERT(m_mimeType == MimeTypeWebp); | 278 ASSERT(m_mimeType == MimeTypeWebp); |
| 279 | 279 |
| 280 if (!ImageDataBuffer(m_size, m_data->data()).encodeImage("image/webp", quali
ty, m_encodedImage.get())) { | 280 if (!ImageDataBuffer(m_size, m_data->data()).encodeImage("image/webp", quali
ty, m_encodedImage.get())) { |
| 281 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_
callback.get()), nullptr)); | 281 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_
callback), nullptr)); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H
ERE, threadSafeBind(&CanvasAsyncBlobCreator::createBlobAndInvokeCallback, wrapCr
ossThreadPersistent(this))); | 285 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H
ERE, threadSafeBind(&CanvasAsyncBlobCreator::createBlobAndInvokeCallback, wrapCr
ossThreadPersistent(this))); |
| 286 } | 286 } |
| 287 | 287 |
| 288 bool CanvasAsyncBlobCreator::initializePngStruct() | 288 bool CanvasAsyncBlobCreator::initializePngStruct() |
| 289 { | 289 { |
| 290 m_pngEncoderState = PNGImageEncoderState::create(m_size, m_encodedImage.get(
)); | 290 m_pngEncoderState = PNGImageEncoderState::create(m_size, m_encodedImage.get(
)); |
| 291 if (!m_pngEncoderState) { | 291 if (!m_pngEncoderState) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 void CanvasAsyncBlobCreator::postDelayedTaskToMainThread(const WebTraceLocation&
location, std::unique_ptr<SameThreadClosure> task, double delayMs) | 364 void CanvasAsyncBlobCreator::postDelayedTaskToMainThread(const WebTraceLocation&
location, std::unique_ptr<SameThreadClosure> task, double delayMs) |
| 365 { | 365 { |
| 366 DCHECK(isMainThread()); | 366 DCHECK(isMainThread()); |
| 367 Platform::current()->mainThread()->getWebTaskRunner()->postDelayedTask(locat
ion, std::move(task), delayMs); | 367 Platform::current()->mainThread()->getWebTaskRunner()->postDelayedTask(locat
ion, std::move(task), delayMs); |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace blink | 370 } // namespace blink |
| OLD | NEW |