| Index: Source/core/page/ImageBitmap.cpp
|
| diff --git a/Source/core/page/ImageBitmap.cpp b/Source/core/page/ImageBitmap.cpp
|
| index fabe6847b5aabfeb1a3482cb5754b9cbb20caddd..d352971f9e2fd1738c1aefb35b938a9e8014b4b3 100644
|
| --- a/Source/core/page/ImageBitmap.cpp
|
| +++ b/Source/core/page/ImageBitmap.cpp
|
| @@ -11,6 +11,11 @@
|
| #include "core/html/ImageData.h"
|
| #include "core/page/ImageBitmapCallback.h"
|
| #include "core/platform/graphics/GraphicsContext.h"
|
| +#include "skia/ext/platform_canvas.h"
|
| +#include "third_party/skia/include/core/SkColorPriv.h"
|
| +#include "third_party/skia/include/core/SkSurface.h"
|
| +#include "third_party/skia/include/gpu/GrContext.h"
|
| +#include "third_party/skia/include/gpu/SkGpuDevice.h"
|
| #include "wtf/RefPtr.h"
|
|
|
| using namespace std;
|
| @@ -34,17 +39,20 @@ static inline PassRefPtr<BitmapImage> cropImage(Image* image, IntRect cropRect)
|
|
|
| ImageBitmap::ImageBitmap(HTMLImageElement* image, IntRect cropRect)
|
| : m_bitmapOffset(max(0, -cropRect.x()), max(0, -cropRect.y()))
|
| - , m_size(cropRect.size())
|
| + , m_cropRect(cropRect)
|
| + , m_canvasImage(0)
|
| {
|
| Image* bitmapImage = image->cachedImage()->image();
|
| - m_bitmap = cropImage(bitmapImage, cropRect).get();
|
| + m_bitmap = cropImage(bitmapImage, cropRect);
|
| + m_bitmapSize = IntSize(m_bitmap->size());
|
|
|
| ScriptWrappable::init(this);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(HTMLVideoElement* video, IntRect cropRect)
|
| : m_bitmapOffset(max(0, -cropRect.x()), max(0, -cropRect.y()))
|
| - , m_size(cropRect.size())
|
| + , m_cropRect(cropRect)
|
| + , m_canvasImage(0)
|
| {
|
| IntRect videoRect = IntRect(IntPoint(), video->player()->naturalSize());
|
| IntRect srcRect = intersection(cropRect, videoRect);
|
| @@ -55,29 +63,26 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video, IntRect cropRect)
|
| c->clip(dstRect);
|
| c->translate(-srcRect.x(), -srcRect.y());
|
| video->paintCurrentFrameInContext(c, videoRect);
|
| - m_bitmap = static_cast<BitmapImage*>(m_buffer->copyImage(DontCopyBackingStore).get());
|
| + m_bitmap = m_buffer->copyImage(DontCopyBackingStore);
|
| + m_bitmapSize = IntSize(m_bitmap->size());
|
|
|
| ScriptWrappable::init(this);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, IntRect cropRect)
|
| : m_bitmapOffset(max(0, -cropRect.x()), max(0, -cropRect.y()))
|
| - , m_size(cropRect.size())
|
| + , m_cropRect(cropRect)
|
| + , m_bitmapSize(cropRect.size())
|
| {
|
| - IntSize canvasSize = canvas->size();
|
| - IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), canvasSize));
|
| - IntRect dstRect(IntPoint(), srcRect.size());
|
| -
|
| - m_buffer = ImageBuffer::create(canvasSize);
|
| - m_buffer->context()->drawImageBuffer(canvas->buffer(), dstRect, srcRect);
|
| - m_bitmap = static_cast<BitmapImage*>(m_buffer->copyImage(DontCopyBackingStore).get());
|
| + m_canvasImage = canvas->buffer()->imageSnapshot();
|
|
|
| ScriptWrappable::init(this);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(ImageData* data, IntRect cropRect)
|
| : m_bitmapOffset(max(0, -cropRect.x()), max(0, -cropRect.y()))
|
| - , m_size(cropRect.size())
|
| + , m_cropRect(cropRect)
|
| + , m_canvasImage(0)
|
| {
|
| IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
|
|
|
| @@ -85,18 +90,21 @@ ImageBitmap::ImageBitmap(ImageData* data, IntRect cropRect)
|
| if (srcRect.width() > 0 && srcRect.height() > 0)
|
| m_buffer->putByteArray(Unmultiplied, data->data(), data->size(), srcRect, IntPoint(min(0, -cropRect.x()), min(0, -cropRect.y())));
|
|
|
| - m_bitmap = static_cast<BitmapImage*>(m_buffer->copyImage(DontCopyBackingStore).get());
|
| + m_bitmap = m_buffer->copyImage(DontCopyBackingStore);
|
| + m_bitmapSize = IntSize(m_bitmap->size());
|
|
|
| ScriptWrappable::init(this);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(ImageBitmap* bitmap, IntRect cropRect)
|
| : m_bitmapOffset(max(0, bitmap->bitmapOffset().x() - cropRect.x()), max(0, bitmap->bitmapOffset().y() - cropRect.y()))
|
| - , m_size(cropRect.size())
|
| + , m_cropRect(cropRect)
|
| + , m_canvasImage(0)
|
| {
|
| - Image* bitmapImage = bitmap->bitmapImage();
|
| + Image* bitmapImage = bitmap->bitmapImage().get();
|
| cropRect.moveBy(IntPoint(-bitmap->bitmapOffset().x(), -bitmap->bitmapOffset().y()));
|
| - m_bitmap = cropImage(bitmapImage, cropRect).get();
|
| + m_bitmap = cropImage(bitmapImage, cropRect);
|
| + m_bitmapSize = IntSize(m_bitmap->size());
|
|
|
| ScriptWrappable::init(this);
|
| }
|
|
|