OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/platform/test/test_window_manager.h" | 5 #include "ui/ozone/platform/test/test_window_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/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 void ResizeCanvas(const gfx::Size& viewport_size) OVERRIDE { | 38 virtual void ResizeCanvas(const gfx::Size& viewport_size) override { |
39 surface_ = skia::AdoptRef(SkSurface::NewRaster(SkImageInfo::MakeN32Premul( | 39 surface_ = skia::AdoptRef(SkSurface::NewRaster(SkImageInfo::MakeN32Premul( |
40 viewport_size.width(), viewport_size.height()))); | 40 viewport_size.width(), viewport_size.height()))); |
41 } | 41 } |
42 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE { | 42 virtual skia::RefPtr<SkCanvas> GetCanvas() override { |
43 return skia::SharePtr(surface_->getCanvas()); | 43 return skia::SharePtr(surface_->getCanvas()); |
44 } | 44 } |
45 virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE { | 45 virtual void PresentCanvas(const gfx::Rect& damage) override { |
46 if (location_.empty()) | 46 if (location_.empty()) |
47 return; | 47 return; |
48 SkBitmap bitmap; | 48 SkBitmap bitmap; |
49 bitmap.setInfo(surface_->getCanvas()->imageInfo()); | 49 bitmap.setInfo(surface_->getCanvas()->imageInfo()); |
50 | 50 |
51 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. | 51 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. |
52 // See crbug.com/361605 for details. | 52 // See crbug.com/361605 for details. |
53 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { | 53 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { |
54 base::WorkerPool::PostTask( | 54 base::WorkerPool::PostTask( |
55 FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); | 55 FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); |
56 } | 56 } |
57 } | 57 } |
58 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE { | 58 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { |
59 return scoped_ptr<gfx::VSyncProvider>(); | 59 return scoped_ptr<gfx::VSyncProvider>(); |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
63 base::FilePath location_; | 63 base::FilePath location_; |
64 skia::RefPtr<SkSurface> surface_; | 64 skia::RefPtr<SkSurface> surface_; |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); | 103 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); |
104 } | 104 } |
105 | 105 |
106 bool TestWindowManager::LoadEGLGLES2Bindings( | 106 bool TestWindowManager::LoadEGLGLES2Bindings( |
107 AddGLLibraryCallback add_gl_library, | 107 AddGLLibraryCallback add_gl_library, |
108 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 108 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 } // namespace ui | 112 } // namespace ui |
OLD | NEW |