| 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 18 matching lines...) Expand all Loading... |
| 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 ~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_ = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul( |
| 40 viewport_size.width(), viewport_size.height()))); | 40 viewport_size.width(), viewport_size.height())); |
| 41 } | 41 } |
| 42 skia::RefPtr<SkSurface> GetSurface() override { return surface_; } | 42 sk_sp<SkSurface> GetSurface() override { return surface_; } |
| 43 void PresentCanvas(const gfx::Rect& damage) override { | 43 void PresentCanvas(const gfx::Rect& damage) override { |
| 44 if (location_.empty()) | 44 if (location_.empty()) |
| 45 return; | 45 return; |
| 46 SkBitmap bitmap; | 46 SkBitmap bitmap; |
| 47 bitmap.setInfo(surface_->getCanvas()->imageInfo()); | 47 bitmap.setInfo(surface_->getCanvas()->imageInfo()); |
| 48 | 48 |
| 49 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. | 49 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. |
| 50 // See crbug.com/361605 for details. | 50 // See crbug.com/361605 for details. |
| 51 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { | 51 if (surface_->getCanvas()->readPixels(&bitmap, 0, 0)) { |
| 52 base::WorkerPool::PostTask( | 52 base::WorkerPool::PostTask( |
| 53 FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); | 53 FROM_HERE, base::Bind(&WriteDataToFile, location_, bitmap), true); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { | 56 scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { |
| 57 return nullptr; | 57 return nullptr; |
| 58 } | 58 } |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 base::FilePath location_; | 61 base::FilePath location_; |
| 62 skia::RefPtr<SkSurface> surface_; | 62 sk_sp<SkSurface> surface_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 TestWindowManager::TestWindowManager(const base::FilePath& dump_location) | 67 TestWindowManager::TestWindowManager(const base::FilePath& dump_location) |
| 68 : location_(dump_location) { | 68 : location_(dump_location) { |
| 69 } | 69 } |
| 70 | 70 |
| 71 TestWindowManager::~TestWindowManager() { | 71 TestWindowManager::~TestWindowManager() { |
| 72 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DCHECK(thread_checker_.CalledOnValidThread()); | 109 DCHECK(thread_checker_.CalledOnValidThread()); |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace ui | 113 } // namespace ui |
| OLD | NEW |