| Index: ui/gfx/ozone/impl/file_surface_factory.cc
|
| diff --git a/ui/gfx/ozone/impl/file_surface_factory.cc b/ui/gfx/ozone/impl/file_surface_factory.cc
|
| index 2120bd114b4d6e2e2dee38d60f6a7f60946c5072..d2755876c7cbee044b49b94716821650f5603cd9 100644
|
| --- a/ui/gfx/ozone/impl/file_surface_factory.cc
|
| +++ b/ui/gfx/ozone/impl/file_surface_factory.cc
|
| @@ -12,8 +12,12 @@
|
| #include "third_party/skia/include/core/SkBitmapDevice.h"
|
| #include "third_party/skia/include/core/SkDevice.h"
|
| #include "ui/gfx/codec/png_codec.h"
|
| +#include "ui/gfx/ozone/surface_ozone.h"
|
| +#include "ui/gfx/skia_util.h"
|
| #include "ui/gfx/vsync_provider.h"
|
|
|
| +namespace gfx {
|
| +
|
| namespace {
|
|
|
| void WriteDataToFile(const base::FilePath& location,
|
| @@ -25,9 +29,43 @@ void WriteDataToFile(const base::FilePath& location,
|
| png_data.size());
|
| }
|
|
|
| -}
|
| +class FileSurface : public SurfaceOzone {
|
| + public:
|
| + FileSurface(const base::FilePath& location) : location_(location) {}
|
| + virtual ~FileSurface() {}
|
|
|
| -namespace gfx {
|
| + bool InitializeCanvas() OVERRIDE {
|
| + return true;
|
| + }
|
| +
|
| + bool ResizeCanvas(const Rect& bounds) OVERRIDE {
|
| + device_ = skia::AdoptRef(new SkBitmapDevice(
|
| + SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()));
|
| + canvas_ = skia::AdoptRef(new SkCanvas(device_.get()));
|
| + return true;
|
| + }
|
| +
|
| + SkCanvas* GetCanvas() OVERRIDE { return canvas_.get(); }
|
| +
|
| + bool SwapCanvas() OVERRIDE {
|
| + SkBitmap bitmap;
|
| + bitmap.setConfig(
|
| + SkBitmap::kARGB_8888_Config, device_->width(), device_->height());
|
| +
|
| + if (canvas_->readPixels(&bitmap, 0, 0)) {
|
| + base::WorkerPool::PostTask(
|
| + FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true);
|
| + }
|
| + return true;
|
| + }
|
| +
|
| + private:
|
| + base::FilePath location_;
|
| + skia::RefPtr<SkBitmapDevice> device_;
|
| + skia::RefPtr<SkCanvas> canvas_;
|
| +};
|
| +
|
| +} // namespace
|
|
|
| FileSurfaceFactory::FileSurfaceFactory(
|
| const base::FilePath& dump_location)
|
| @@ -51,9 +89,9 @@ AcceleratedWidget FileSurfaceFactory::GetAcceleratedWidget() {
|
| return 1;
|
| }
|
|
|
| -AcceleratedWidget FileSurfaceFactory::RealizeAcceleratedWidget(
|
| +scoped_ptr<SurfaceOzone> FileSurfaceFactory::CreateSurfaceForWidget(
|
| AcceleratedWidget widget) {
|
| - return 1;
|
| + return make_scoped_ptr<SurfaceOzone>(new FileSurface(location_));
|
| }
|
|
|
| bool FileSurfaceFactory::LoadEGLGLES2Bindings(
|
| @@ -62,37 +100,4 @@ bool FileSurfaceFactory::LoadEGLGLES2Bindings(
|
| return false;
|
| }
|
|
|
| -bool FileSurfaceFactory::AttemptToResizeAcceleratedWidget(
|
| - AcceleratedWidget widget,
|
| - const Rect& bounds) {
|
| - device_ = skia::AdoptRef(new SkBitmapDevice(SkBitmap::kARGB_8888_Config,
|
| - bounds.width(),
|
| - bounds.height()));
|
| - canvas_ = skia::AdoptRef(new SkCanvas(device_.get()));
|
| - return true;
|
| -}
|
| -
|
| -bool FileSurfaceFactory::SchedulePageFlip(AcceleratedWidget widget) {
|
| - SkBitmap bitmap;
|
| - bitmap.setConfig(SkBitmap::kARGB_8888_Config,
|
| - device_->width(),
|
| - device_->height());
|
| -
|
| - if (canvas_->readPixels(&bitmap, 0, 0)) {
|
| - base::WorkerPool::PostTask(FROM_HERE,
|
| - base::Bind(&WriteDataToFile, location_, bitmap),
|
| - true);
|
| - }
|
| - return true;
|
| -}
|
| -
|
| -SkCanvas* FileSurfaceFactory::GetCanvasForWidget(AcceleratedWidget w) {
|
| - return canvas_.get();
|
| -}
|
| -
|
| -scoped_ptr<VSyncProvider> FileSurfaceFactory::CreateVSyncProvider(
|
| - AcceleratedWidget w) {
|
| - return scoped_ptr<VSyncProvider>();
|
| -}
|
| -
|
| } // namespace gfx
|
|
|