| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
| 40 #include "core/html/HTMLCanvasElement.h" | 40 #include "core/html/HTMLCanvasElement.h" |
| 41 #include "core/html/HTMLImageElement.h" | 41 #include "core/html/HTMLImageElement.h" |
| 42 #include "core/html/HTMLVideoElement.h" | 42 #include "core/html/HTMLVideoElement.h" |
| 43 #include "core/html/ImageData.h" | 43 #include "core/html/ImageData.h" |
| 44 #include "core/html/canvas/CanvasRenderingContext2D.h" | 44 #include "core/html/canvas/CanvasRenderingContext2D.h" |
| 45 #include "core/workers/WorkerGlobalScope.h" | 45 #include "core/workers/WorkerGlobalScope.h" |
| 46 #include "platform/SharedBuffer.h" | 46 #include "platform/SharedBuffer.h" |
| 47 #include "platform/graphics/BitmapImage.h" | 47 #include "platform/graphics/BitmapImage.h" |
| 48 #include "platform/graphics/ImageSource.h" | 48 #include "platform/graphics/ImageSource.h" |
| 49 #include "platform/graphics/skia/NativeImageSkia.h" | |
| 50 #include "public/platform/WebSize.h" | 49 #include "public/platform/WebSize.h" |
| 51 #include <v8.h> | 50 #include <v8.h> |
| 52 | 51 |
| 53 namespace blink { | 52 namespace blink { |
| 54 | 53 |
| 55 static LayoutSize sizeFor(HTMLImageElement* image) | 54 static LayoutSize sizeFor(HTMLImageElement* image) |
| 56 { | 55 { |
| 57 if (ImageResource* cachedImage = image->cachedImage()) | 56 if (ImageResource* cachedImage = image->cachedImage()) |
| 58 return cachedImage->imageSizeForRenderer(image->layoutObject(), 1.0f); /
/ FIXME: Not sure about this. | 57 return cachedImage->imageSizeForRenderer(image->layoutObject(), 1.0f); /
/ FIXME: Not sure about this. |
| 59 return LayoutSize(); | 58 return LayoutSize(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 void ImageBitmapFactories::ImageBitmapLoader::didFinishLoading() | 299 void ImageBitmapFactories::ImageBitmapLoader::didFinishLoading() |
| 301 { | 300 { |
| 302 if (!m_loader.arrayBufferResult()) { | 301 if (!m_loader.arrayBufferResult()) { |
| 303 rejectPromise(); | 302 rejectPromise(); |
| 304 return; | 303 return; |
| 305 } | 304 } |
| 306 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr
ayBufferResult()->data(), m_loader.arrayBufferResult()->byteLength()); | 305 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr
ayBufferResult()->data(), m_loader.arrayBufferResult()->byteLength()); |
| 307 | 306 |
| 308 OwnPtr<ImageSource> source = adoptPtr(new ImageSource()); | 307 OwnPtr<ImageSource> source = adoptPtr(new ImageSource()); |
| 309 source->setData(*sharedBuffer, true); | 308 source->setData(*sharedBuffer, true); |
| 310 RefPtr<NativeImageSkia> imageSkia = source->createFrameAtIndex(0); | 309 SkBitmap bitmap; |
| 311 if (!imageSkia) { | 310 if (!source->createFrameAtIndex(0, &bitmap)) { |
| 312 rejectPromise(); | 311 rejectPromise(); |
| 313 return; | 312 return; |
| 314 } | 313 } |
| 315 | 314 |
| 316 RefPtr<Image> image = BitmapImage::create(imageSkia); | 315 RefPtr<Image> image = BitmapImage::create(bitmap); |
| 317 if (!image->width() || !image->height()) { | 316 if (!image->width() || !image->height()) { |
| 318 rejectPromise(); | 317 rejectPromise(); |
| 319 return; | 318 return; |
| 320 } | 319 } |
| 321 if (!m_cropRect.width() && !m_cropRect.height()) { | 320 if (!m_cropRect.width() && !m_cropRect.height()) { |
| 322 // No cropping variant was called. | 321 // No cropping variant was called. |
| 323 m_cropRect = IntRect(IntPoint(), image->size()); | 322 m_cropRect = IntRect(IntPoint(), image->size()); |
| 324 } | 323 } |
| 325 | 324 |
| 326 RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get(
), m_cropRect); | 325 RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get(
), m_cropRect); |
| 327 m_resolver->resolve(imageBitmap.release()); | 326 m_resolver->resolve(imageBitmap.release()); |
| 328 m_factory->didFinishLoading(this); | 327 m_factory->didFinishLoading(this); |
| 329 } | 328 } |
| 330 | 329 |
| 331 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) | 330 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) |
| 332 { | 331 { |
| 333 rejectPromise(); | 332 rejectPromise(); |
| 334 } | 333 } |
| 335 | 334 |
| 336 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) | 335 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) |
| 337 { | 336 { |
| 338 visitor->trace(m_factory); | 337 visitor->trace(m_factory); |
| 339 visitor->trace(m_resolver); | 338 visitor->trace(m_resolver); |
| 340 } | 339 } |
| 341 | 340 |
| 342 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |