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 (" | |
69 << location_.value() << ")"; | |
70 CHECK(!base::PathExists(location_) || base::PathIsWritable(location_)); | |
71 } | 68 } |
72 | 69 |
73 FileSurfaceFactory::~FileSurfaceFactory() { | 70 TestWindowManager::~TestWindowManager() { |
74 } | 71 } |
75 | 72 |
76 SurfaceFactoryOzone::HardwareState FileSurfaceFactory::InitializeHardware() { | 73 void TestWindowManager::Initialize() { |
| 74 if (!DirectoryExists(location_) && !base::CreateDirectory(location_) && |
| 75 location_ != base::FilePath("/dev/null")) |
| 76 PLOG(FATAL) << "unable to create output directory"; |
| 77 if (!base::PathIsWritable(location_)) |
| 78 PLOG(FATAL) << "unable to write to output location"; |
| 79 } |
| 80 |
| 81 int32_t TestWindowManager::AddWindow(TestWindow* window) { |
| 82 return windows_.Add(window); |
| 83 } |
| 84 |
| 85 void TestWindowManager::RemoveWindow(int32_t window_id, TestWindow* window) { |
| 86 DCHECK_EQ(window, windows_.Lookup(window_id)); |
| 87 windows_.Remove(window_id); |
| 88 } |
| 89 |
| 90 base::FilePath TestWindowManager::base_path() const { |
| 91 return location_; |
| 92 } |
| 93 |
| 94 SurfaceFactoryOzone::HardwareState TestWindowManager::InitializeHardware() { |
77 return INITIALIZED; | 95 return INITIALIZED; |
78 } | 96 } |
79 | 97 |
80 void FileSurfaceFactory::ShutdownHardware() { | 98 void TestWindowManager::ShutdownHardware() { |
81 } | 99 } |
82 | 100 |
83 gfx::AcceleratedWidget FileSurfaceFactory::GetAcceleratedWidget() { | 101 gfx::AcceleratedWidget TestWindowManager::GetAcceleratedWidget() { |
84 return 1; | 102 NOTREACHED(); |
| 103 return -1; |
85 } | 104 } |
86 | 105 |
87 scoped_ptr<SurfaceOzoneCanvas> FileSurfaceFactory::CreateCanvasForWidget( | 106 scoped_ptr<SurfaceOzoneCanvas> TestWindowManager::CreateCanvasForWidget( |
88 gfx::AcceleratedWidget w) { | 107 gfx::AcceleratedWidget widget) { |
89 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(location_)); | 108 TestWindow* window = windows_.Lookup(widget); |
| 109 DCHECK(window); |
| 110 return make_scoped_ptr<SurfaceOzoneCanvas>(new FileSurface(window->path())); |
90 } | 111 } |
91 | 112 |
92 bool FileSurfaceFactory::LoadEGLGLES2Bindings( | 113 bool TestWindowManager::LoadEGLGLES2Bindings( |
93 AddGLLibraryCallback add_gl_library, | 114 AddGLLibraryCallback add_gl_library, |
94 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 115 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
95 return false; | 116 return false; |
96 } | 117 } |
97 | 118 |
98 } // namespace ui | 119 } // namespace ui |
OLD | NEW |