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

Unified Diff: Source/core/frame/Frame.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/Frame.cpp
diff --git a/Source/core/frame/Frame.cpp b/Source/core/frame/Frame.cpp
index 7886475dc9376a359111fc0f84045272f6073f13..ce78d997bc751b5b17980e8396984f1b2424e607 100644
--- a/Source/core/frame/Frame.cpp
+++ b/Source/core/frame/Frame.cpp
@@ -65,6 +65,7 @@
#include "core/rendering/RenderPart.h"
#include "core/rendering/RenderView.h"
#include "core/svg/SVGDocument.h"
+#include "platform/graphics/UnacceleratedImageBufferSurface.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefCountedLeakCounter.h"
#include "wtf/StdLibExtras.h"
@@ -649,15 +650,16 @@ PassOwnPtr<DragImage> Frame::nodeImage(Node* node)
paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
- OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceScaleFactor));
- if (!buffer)
+ OwnPtr<ImageBufferSurface> surface = adoptPtr(new UnacceleratedImageBufferSurface(paintingRect.size(), NonOpaque, deviceScaleFactor));
+ if (!surface->isValid())
return nullptr;
- buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
- buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
+ ImageBuffer buffer(surface.release());
+ buffer.context()->translate(-paintingRect.x(), -paintingRect.y());
+ buffer.context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
- m_view->paintContents(buffer->context(), paintingRect);
+ m_view->paintContents(buffer.context(), paintingRect);
- RefPtr<Image> image = buffer->copyImage();
+ RefPtr<Image> image = buffer.copyImage();
return DragImage::create(image.get(), renderer->shouldRespectImageOrientation());
}
@@ -678,15 +680,16 @@ PassOwnPtr<DragImage> Frame::dragImageForSelection()
paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
- OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), deviceScaleFactor));
- if (!buffer)
+ OwnPtr<ImageBufferSurface> surface = adoptPtr(new UnacceleratedImageBufferSurface(paintingRect.size(), NonOpaque, deviceScaleFactor));
+ if (!surface->isValid())
return nullptr;
- buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
- buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
+ ImageBuffer buffer(surface.release());
+ buffer.context()->translate(-paintingRect.x(), -paintingRect.y());
+ buffer.context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
- m_view->paintContents(buffer->context(), paintingRect);
+ m_view->paintContents(buffer.context(), paintingRect);
- RefPtr<Image> image = buffer->copyImage();
+ RefPtr<Image> image = buffer.copyImage();
return DragImage::create(image.get());
}

Powered by Google App Engine
This is Rietveld 408576698