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

Unified Diff: Source/core/frame/ImageBitmap.cpp

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: build fixes for win+mac Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/frame/ImageBitmap.cpp
diff --git a/Source/core/frame/ImageBitmap.cpp b/Source/core/frame/ImageBitmap.cpp
index ff9effb04d8ca649fe46eb892d97984b8199fcd2..e48bc79ac132f34c57f0f8435840a0b31aa601cb 100644
--- a/Source/core/frame/ImageBitmap.cpp
+++ b/Source/core/frame/ImageBitmap.cpp
@@ -12,6 +12,7 @@
#include "core/platform/graphics/BitmapImage.h"
#include "core/platform/graphics/GraphicsContext.h"
#include "core/platform/graphics/ImageBuffer.h"
+#include "platform/graphics/UnacceleratedImageBufferSurface.h"
#include "wtf/RefPtr.h"
using namespace std;
@@ -63,12 +64,15 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video, const IntRect& cropRect)
IntRect srcRect = intersection(cropRect, videoRect);
IntRect dstRect(IntPoint(), srcRect.size());
- OwnPtr<ImageBuffer> buf = ImageBuffer::create(videoRect.size(), 1, UnacceleratedNonPlatformBuffer);
- GraphicsContext* c = buf->context();
+ OwnPtr<ImageBufferSurface> surface = adoptPtr(new UnacceleratedImageBufferSurface(videoRect.size()));
+ if (!surface->isValid())
+ return;
+ ImageBuffer buf(surface.release());
+ GraphicsContext* c = buf.context();
c->clip(dstRect);
c->translate(-srcRect.x(), -srcRect.y());
video->paintCurrentFrameInContext(c, videoRect);
- m_bitmap = buf->copyImage(DontCopyBackingStore);
+ m_bitmap = buf.copyImage(DontCopyBackingStore);
m_bitmapRect = IntRect(IntPoint(max(0, -cropRect.x()), max(0, -cropRect.y())), srcRect.size());
ScriptWrappable::init(this);
@@ -97,11 +101,14 @@ ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect)
{
IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), data->size()));
- OwnPtr<ImageBuffer> buf = ImageBuffer::create(data->size(), 1, UnacceleratedNonPlatformBuffer);
+ OwnPtr<ImageBufferSurface> surface = adoptPtr(new UnacceleratedImageBufferSurface(data->size()));
+ if (!surface->isValid())
+ return;
+ ImageBuffer buf(surface.release());
if (srcRect.width() > 0 && srcRect.height() > 0)
- buf->putByteArray(Premultiplied, data->data(), data->size(), srcRect, IntPoint(min(0, -cropRect.x()), min(0, -cropRect.y())));
+ buf.putByteArray(Premultiplied, data->data(), data->size(), srcRect, IntPoint(min(0, -cropRect.x()), min(0, -cropRect.y())));
- m_bitmap = buf->copyImage(DontCopyBackingStore);
+ m_bitmap = buf.copyImage(DontCopyBackingStore);
m_bitmapRect = IntRect(IntPoint(max(0, -cropRect.x()), max(0, -cropRect.y())), srcRect.size());
ScriptWrappable::init(this);

Powered by Google App Engine
This is Rietveld 408576698