Chromium Code Reviews| 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/ozone/platform/test/file_surface_factory.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/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" |
| 11 #include "base/threading/worker_pool.h" | 11 #include "base/threading/worker_pool.h" |
| 12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
| 13 #include "third_party/skia/include/core/SkSurface.h" | 13 #include "third_party/skia/include/core/SkSurface.h" |
| 14 #include "ui/gfx/codec/png_codec.h" | 14 #include "ui/gfx/codec/png_codec.h" |
| 15 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 return scoped_ptr<gfx::VSyncProvider>(); | 56 return scoped_ptr<gfx::VSyncProvider>(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 base::FilePath location_; | 60 base::FilePath location_; |
| 61 skia::RefPtr<SkSurface> surface_; | 61 skia::RefPtr<SkSurface> surface_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 FileSurfaceFactory::FileSurfaceFactory(const base::FilePath& dump_location) | 66 TestWindowManager::TestWindowManager(const base::FilePath& dump_location) |
| 67 : location_(dump_location) { | 67 : location_(dump_location) { |
| 68 CHECK(!base::DirectoryExists(location_)) << "Location cannot be a directory (" | 68 if (!DirectoryExists(location_) && !base::CreateDirectory(location_) && |
|
alexst (slow to review)
2014/07/17 15:28:30
Can you move this into a separate function? Maybe
spang
2014/07/17 19:51:44
Done.
| |
| 69 << location_.value() << ")"; | 69 dump_location != base::FilePath("/dev/null")) |
| 70 CHECK(!base::PathExists(location_) || base::PathIsWritable(location_)); | 70 PLOG(FATAL) << "unable to create output directory"; |
| 71 if (!base::PathIsWritable(location_)) | |
| 72 PLOG(FATAL) << "unable to write to output location"; | |
| 71 } | 73 } |
| 72 | 74 |
| 73 FileSurfaceFactory::~FileSurfaceFactory() { | 75 TestWindowManager::~TestWindowManager() { |
| 74 } | 76 } |
| 75 | 77 |
| 76 SurfaceFactoryOzone::HardwareState FileSurfaceFactory::InitializeHardware() { | 78 int32_t TestWindowManager::AddWindow(TestWindow* window) { |
| 79 return windows_.Add(window); | |
| 80 } | |
| 81 | |
| 82 void TestWindowManager::RemoveWindow(int32_t window_id, TestWindow* window) { | |
| 83 DCHECK_EQ(window, windows_.Lookup(window_id)); | |
| 84 windows_.Remove(window_id); | |
| 85 } | |
| 86 | |
| 87 base::FilePath TestWindowManager::base_path() const { | |
| 88 return location_; | |
| 89 } | |
| 90 | |
| 91 SurfaceFactoryOzone::HardwareState TestWindowManager::InitializeHardware() { | |
| 77 return INITIALIZED; | 92 return INITIALIZED; |
| 78 } | 93 } |
| 79 | 94 |
| 80 void FileSurfaceFactory::ShutdownHardware() { | 95 void TestWindowManager::ShutdownHardware() { |
| 81 } | 96 } |
| 82 | 97 |
| 83 gfx::AcceleratedWidget FileSurfaceFactory::GetAcceleratedWidget() { | 98 gfx::AcceleratedWidget TestWindowManager::GetAcceleratedWidget() { |
| 84 return 1; | 99 NOTREACHED(); |
| 100 return -1; | |
| 85 } | 101 } |
| 86 | 102 |
| 87 scoped_ptr<SurfaceOzoneCanvas> FileSurfaceFactory::CreateCanvasForWidget( | 103 scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget( |
| 88 gfx::AcceleratedWidget w) { | 104 gfx::AcceleratedWidget widget) { |
| 89 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(location_)); | 105 TestWindow* window = windows_.Lookup(widget); |
|
alexst (slow to review)
2014/07/17 15:28:30
Please DCHECK that this is sane.
spang
2014/07/17 19:51:44
Done.
| |
| 106 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); | |
| 90 } | 107 } |
| 91 | 108 |
| 92 bool FileSurfaceFactory::LoadEGLGLES2Bindings( | 109 bool TestWindowManager::LoadEGLGLES2Bindings( |
| 93 AddGLLibraryCallback add_gl_library, | 110 AddGLLibraryCallback add_gl_library, |
| 94 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 111 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
| 95 return false; | 112 return false; |
| 96 } | 113 } |
| 97 | 114 |
| 98 } // namespace ui | 115 } // namespace ui |
| OLD | NEW |