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 21 matching lines...) Expand all Loading... |
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 ~FileSurface() override {} | 35 ~FileSurface() override {} |
36 | 36 |
37 // SurfaceOzoneCanvas overrides: | 37 // SurfaceOzoneCanvas overrides: |
38 void ResizeCanvas(const gfx::Size& viewport_size) override { | 38 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 skia::RefPtr<SkCanvas> GetCanvas() override { | 42 skia::RefPtr<SkSurface> GetSurface() override { return surface_; } |
43 return skia::SharePtr(surface_->getCanvas()); | |
44 } | |
45 void PresentCanvas(const gfx::Rect& damage) override { | 43 void PresentCanvas(const gfx::Rect& damage) override { |
46 if (location_.empty()) | 44 if (location_.empty()) |
47 return; | 45 return; |
48 SkBitmap bitmap; | 46 SkBitmap bitmap; |
49 bitmap.setInfo(surface_->getCanvas()->imageInfo()); | 47 bitmap.setInfo(surface_->getCanvas()->imageInfo()); |
50 | 48 |
51 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. | 49 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. |
52 // See crbug.com/361605 for details. | 50 // See crbug.com/361605 for details. |
53 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { | 51 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { |
54 base::WorkerPool::PostTask( | 52 base::WorkerPool::PostTask( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); | 101 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); |
104 } | 102 } |
105 | 103 |
106 bool TestWindowManager::LoadEGLGLES2Bindings( | 104 bool TestWindowManager::LoadEGLGLES2Bindings( |
107 AddGLLibraryCallback add_gl_library, | 105 AddGLLibraryCallback add_gl_library, |
108 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 106 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
109 return false; | 107 return false; |
110 } | 108 } |
111 | 109 |
112 } // namespace ui | 110 } // namespace ui |
OLD | NEW |