OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/ozone/impl/file_surface_factory.h" | 5 #include "ui/gfx/ozone/impl/file_surface_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 reinterpret_cast<const char*>(vector_as_array(&png_data)), | 28 reinterpret_cast<const char*>(vector_as_array(&png_data)), |
29 png_data.size()); | 29 png_data.size()); |
30 } | 30 } |
31 | 31 |
32 class FileSurface : public SurfaceOzoneCanvas { | 32 class FileSurface : public SurfaceOzoneCanvas { |
33 public: | 33 public: |
34 FileSurface(const base::FilePath& location) : location_(location) {} | 34 FileSurface(const base::FilePath& location) : location_(location) {} |
35 virtual ~FileSurface() {} | 35 virtual ~FileSurface() {} |
36 | 36 |
37 // SurfaceOzoneCanvas overrides: | 37 // SurfaceOzoneCanvas overrides: |
38 virtual bool ResizeCanvas(const Size& viewport_size) OVERRIDE { | 38 virtual void ResizeCanvas(const Size& viewport_size) OVERRIDE { |
39 surface_ = skia::AdoptRef(SkSurface::NewRaster( | 39 surface_ = skia::AdoptRef(SkSurface::NewRaster( |
40 SkImageInfo::MakeN32Premul(viewport_size.width(), | 40 SkImageInfo::MakeN32Premul(viewport_size.width(), |
41 viewport_size.height()))); | 41 viewport_size.height()))); |
42 return true; | |
43 } | 42 } |
44 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE { | 43 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE { |
45 return skia::SharePtr(surface_->getCanvas()); | 44 return skia::SharePtr(surface_->getCanvas()); |
46 } | 45 } |
47 virtual bool PresentCanvas() OVERRIDE { | 46 virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE { |
48 SkBitmap bitmap; | 47 SkBitmap bitmap; |
49 bitmap.setConfig(surface_->getCanvas()->imageInfo()); | 48 bitmap.setConfig(surface_->getCanvas()->imageInfo()); |
50 | 49 |
51 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. | 50 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. |
52 // See crbug.com/361605 for details. | 51 // See crbug.com/361605 for details. |
53 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { | 52 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { |
54 base::WorkerPool::PostTask( | 53 base::WorkerPool::PostTask( |
55 FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); | 54 FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); |
56 } | 55 } |
57 return true; | |
58 } | 56 } |
59 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE { | 57 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE { |
60 return scoped_ptr<gfx::VSyncProvider>(); | 58 return scoped_ptr<gfx::VSyncProvider>(); |
61 } | 59 } |
62 | 60 |
63 private: | 61 private: |
64 base::FilePath location_; | 62 base::FilePath location_; |
65 skia::RefPtr<SkSurface> surface_; | 63 skia::RefPtr<SkSurface> surface_; |
66 }; | 64 }; |
67 | 65 |
(...skipping 26 matching lines...) Expand all Loading... |
94 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(location_)); | 92 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(location_)); |
95 } | 93 } |
96 | 94 |
97 bool FileSurfaceFactory::LoadEGLGLES2Bindings( | 95 bool FileSurfaceFactory::LoadEGLGLES2Bindings( |
98 AddGLLibraryCallback add_gl_library, | 96 AddGLLibraryCallback add_gl_library, |
99 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 97 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
100 return false; | 98 return false; |
101 } | 99 } |
102 | 100 |
103 } // namespace gfx | 101 } // namespace gfx |
OLD | NEW |