Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp

Issue 1696753002: Change createImageBitmap(Blob) to use ImageDecoder instead of ImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 #include "core/frame/LocalDOMWindow.h" 37 #include "core/frame/LocalDOMWindow.h"
38 #include "core/frame/UseCounter.h" 38 #include "core/frame/UseCounter.h"
39 #include "core/html/HTMLCanvasElement.h" 39 #include "core/html/HTMLCanvasElement.h"
40 #include "core/html/HTMLImageElement.h" 40 #include "core/html/HTMLImageElement.h"
41 #include "core/html/HTMLVideoElement.h" 41 #include "core/html/HTMLVideoElement.h"
42 #include "core/html/ImageData.h" 42 #include "core/html/ImageData.h"
43 #include "core/imagebitmap/ImageBitmapOptions.h" 43 #include "core/imagebitmap/ImageBitmapOptions.h"
44 #include "core/workers/WorkerGlobalScope.h" 44 #include "core/workers/WorkerGlobalScope.h"
45 #include "platform/SharedBuffer.h" 45 #include "platform/SharedBuffer.h"
46 #include "platform/ThreadSafeFunctional.h" 46 #include "platform/ThreadSafeFunctional.h"
47 #include "platform/graphics/ImageSource.h" 47 #include "platform/image-decoders/ImageDecoder.h"
48 #include "platform/threading/BackgroundTaskRunner.h" 48 #include "platform/threading/BackgroundTaskRunner.h"
49 #include "public/platform/Platform.h" 49 #include "public/platform/Platform.h"
50 #include "public/platform/WebThread.h" 50 #include "public/platform/WebThread.h"
51 #include "public/platform/WebTraceLocation.h" 51 #include "public/platform/WebTraceLocation.h"
52 #include <v8.h> 52 #include <v8.h>
53 53
54 namespace blink { 54 namespace blink {
55 55
56 static inline ImageBitmapSource* toImageBitmapSourceInternal(const ImageBitmapSo urceUnion& value) 56 static inline ImageBitmapSource* toImageBitmapSourceInternal(const ImageBitmapSo urceUnion& value)
57 { 57 {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 BackgroundTaskRunner::TaskSize taskSize = (m_loader.arrayBufferResult()->byt eLength() >= longTaskByteLengthThreshold) ? BackgroundTaskRunner::TaskSizeLongRu nningTask : BackgroundTaskRunner::TaskSizeShortRunningTask; 212 BackgroundTaskRunner::TaskSize taskSize = (m_loader.arrayBufferResult()->byt eLength() >= longTaskByteLengthThreshold) ? BackgroundTaskRunner::TaskSizeLongRu nningTask : BackgroundTaskRunner::TaskSizeShortRunningTask;
213 WebTaskRunner* taskRunner = Platform::current()->currentThread()->taskRunner (); 213 WebTaskRunner* taskRunner = Platform::current()->currentThread()->taskRunner ();
214 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, AllowCros sThreadAccess(this), AllowCrossThreadAccess(taskRunner)), taskSize); 214 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, AllowCros sThreadAccess(this), AllowCrossThreadAccess(taskRunner)), taskSize);
215 } 215 }
216 216
217 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread(WebTask Runner* taskRunner) 217 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread(WebTask Runner* taskRunner)
218 { 218 {
219 ASSERT(!isMainThread()); 219 ASSERT(!isMainThread());
220 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr ayBufferResult()->data(), static_cast<size_t>(m_loader.arrayBufferResult()->byte Length())); 220 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr ayBufferResult()->data(), static_cast<size_t>(m_loader.arrayBufferResult()->byte Length()));
221 221
222 OwnPtr<ImageSource> source = adoptPtr(new ImageSource()); 222 OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*sharedBuffer, ImageDecode r::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied));
223 source->setData(*sharedBuffer, true); 223 if (decoder)
224 224 decoder->setData(sharedBuffer.get(), true);
225 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories:: ImageBitmapLoader::resolvePromiseOnOriginalThread, AllowCrossThreadAccess(this), source.release())); 225 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories:: ImageBitmapLoader::resolvePromiseOnOriginalThread, AllowCrossThreadAccess(this), decoder.release()));
226 } 226 }
227 227
228 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas sOwnPtr<ImageSource> source) 228 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas sOwnPtr<ImageDecoder> decoder)
229 { 229 {
230 RefPtr<SkImage> frame = source->createFrameAtIndex(0); 230 if (!decoder) {
231 rejectPromise();
232 return;
233 }
234 RefPtr<SkImage> frame = ImageBitmap::getSkImageFromDecoder(decoder);
231 ASSERT(!frame || (frame->width() && frame->height())); 235 ASSERT(!frame || (frame->width() && frame->height()));
232 if (!frame) { 236 if (!frame) {
233 rejectPromise(); 237 rejectPromise();
234 return; 238 return;
235 } 239 }
236 240
237 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(frame); 241 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(frame);
238 image->setOriginClean(true); 242 image->setOriginClean(true);
239 if (!m_cropRect.width() && !m_cropRect.height()) { 243 if (!m_cropRect.width() && !m_cropRect.height()) {
240 // No cropping variant was called. 244 // No cropping variant was called.
(...skipping 10 matching lines...) Expand all
251 m_factory->didFinishLoading(this); 255 m_factory->didFinishLoading(this);
252 } 256 }
253 257
254 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) 258 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader)
255 { 259 {
256 visitor->trace(m_factory); 260 visitor->trace(m_factory);
257 visitor->trace(m_resolver); 261 visitor->trace(m_resolver);
258 } 262 }
259 263
260 } // namespace blink 264 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698