| Index: third_party/WebKit/Source/core/frame/ImageBitmap.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
|
| index 60f71c7f1a8f29312bdf1527b31549a72dee39f2..356b458dfe7cefafbddd1a56f352fbdbceaa88f7 100644
|
| --- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
|
| @@ -8,12 +8,6 @@
|
| #include "core/html/HTMLCanvasElement.h"
|
| #include "core/html/HTMLVideoElement.h"
|
| #include "core/html/ImageData.h"
|
| -#include "platform/graphics/GraphicsContext.h"
|
| -#include "platform/graphics/ImageBuffer.h"
|
| -#include "platform/graphics/StaticBitmapImage.h"
|
| -#include "platform/graphics/paint/DrawingRecorder.h"
|
| -#include "platform/graphics/paint/SkPictureBuilder.h"
|
| -#include "third_party/skia/include/core/SkScalar.h"
|
| #include "third_party/skia/include/core/SkSurface.h"
|
| #include "wtf/RefPtr.h"
|
|
|
| @@ -29,7 +23,7 @@ static inline IntRect normalizeRect(const IntRect& rect)
|
|
|
| ImageBitmap::ImageBitmap(HTMLImageElement* image, const IntRect& cropRect)
|
| {
|
| - m_image = cropImage(image->cachedImage()->image()->imageForCurrentFrame(), cropRect);
|
| + m_image = cropImage(static_cast<StaticBitmapImage*>(image->cachedImage()->image()), cropRect);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect)
|
| @@ -46,13 +40,13 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect)
|
|
|
| IntPoint dstPoint = IntPoint(std::max(0, -cropRect.x()), std::max(0, -cropRect.y()));
|
| video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size()), nullptr);
|
| - m_image = buffer->newSkImageSnapshot(PreferNoAcceleration);
|
| + m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAcceleration));
|
| }
|
|
|
| ImageBitmap::ImageBitmap(HTMLCanvasElement* canvas, const IntRect& cropRect)
|
| {
|
| ASSERT(canvas->isPaintable());
|
| - m_image = cropImage(canvas->copiedImage(BackBuffer, PreferAcceleration)->imageForCurrentFrame(), cropRect);
|
| + m_image = cropImage(static_cast<StaticBitmapImage*>(canvas->copiedImage(BackBuffer, PreferAcceleration).get()), cropRect);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
|
| @@ -64,7 +58,7 @@ ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
|
| return;
|
|
|
| if (srcRect.isEmpty()) {
|
| - m_image = buffer->newSkImageSnapshot(PreferNoAcceleration);
|
| + m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAcceleration));
|
| return;
|
| }
|
|
|
| @@ -74,17 +68,22 @@ ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
|
| if (cropRect.y() < 0)
|
| dstPoint.setY(-cropRect.y());
|
| buffer->putByteArray(Unmultiplied, data->data()->data(), data->size(), srcRect, dstPoint);
|
| - m_image = buffer->newSkImageSnapshot(PreferNoAcceleration);
|
| + m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAcceleration));
|
| }
|
|
|
| ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect)
|
| {
|
| - m_image = cropImage(bitmap->skImage(), cropRect);
|
| + m_image = cropImage(bitmap->bitmapImage(), cropRect);
|
| }
|
|
|
| ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect)
|
| {
|
| - m_image = cropImage(image->imageForCurrentFrame(), cropRect);
|
| + m_image = cropImage(static_cast<StaticBitmapImage*>(image), cropRect);
|
| +}
|
| +
|
| +ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image)
|
| +{
|
| + m_image = image;
|
| }
|
|
|
| ImageBitmap::~ImageBitmap()
|
| @@ -127,7 +126,12 @@ PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntR
|
| return adoptRefWillBeNoop(new ImageBitmap(image, normalizedCropRect));
|
| }
|
|
|
| -PassRefPtr<SkImage> ImageBitmap::cropImage(PassRefPtr<SkImage> image, const IntRect& cropRect)
|
| +PassRefPtrWillBeRawPtr<ImageBitmap> ImageBitmap::create(PassRefPtr<StaticBitmapImage> image)
|
| +{
|
| + return adoptRefWillBeNoop(new ImageBitmap(image));
|
| +}
|
| +
|
| +PassRefPtr<StaticBitmapImage> ImageBitmap::cropImage(StaticBitmapImage* image, const IntRect& cropRect)
|
| {
|
| ASSERT(image);
|
|
|
| @@ -135,12 +139,12 @@ PassRefPtr<SkImage> ImageBitmap::cropImage(PassRefPtr<SkImage> image, const IntR
|
| const IntRect srcRect = intersection(imgRect, cropRect);
|
|
|
| if (cropRect == srcRect)
|
| - return adoptRef(image->newSubset(srcRect));
|
| + return StaticBitmapImage::create(adoptRef(image->imageForCurrentFrame()->newSubset(srcRect)));
|
|
|
| RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRasterN32Premul(cropRect.width(), cropRect.height()));
|
|
|
| if (srcRect.isEmpty())
|
| - return adoptRef(surface->newImageSnapshot());
|
| + return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()));
|
|
|
| SkScalar dstLeft = std::min(0, -cropRect.x());
|
| SkScalar dstTop = std::min(0, -cropRect.y());
|
| @@ -148,8 +152,8 @@ PassRefPtr<SkImage> ImageBitmap::cropImage(PassRefPtr<SkImage> image, const IntR
|
| dstLeft = -cropRect.x();
|
| if (cropRect.y() < 0)
|
| dstTop = -cropRect.y();
|
| - surface->getCanvas()->drawImage(image.get(), dstLeft, dstTop);
|
| - return adoptRef(surface->newImageSnapshot());
|
| + surface->getCanvas()->drawImage(image->imageForCurrentFrame().get(), dstLeft, dstTop);
|
| + return StaticBitmapImage::create(adoptRef(surface->newImageSnapshot()));
|
| }
|
|
|
| unsigned long ImageBitmap::width() const
|
| @@ -183,7 +187,7 @@ void ImageBitmap::notifyImageSourceChanged()
|
| PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas(SourceImageStatus* status, AccelerationHint) const
|
| {
|
| *status = NormalSourceImageStatus;
|
| - return m_image ? StaticBitmapImage::create(m_image) : nullptr;
|
| + return m_image ? m_image : nullptr;
|
| }
|
|
|
| void ImageBitmap::adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const
|
|
|