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/caca/caca_surface_factory.h" | 5 #include "ui/ozone/platform/caca/caca_surface_factory.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "third_party/skia/include/core/SkSurface.h" | 9 #include "third_party/skia/include/core/SkSurface.h" |
10 #include "ui/gfx/ozone/surface_ozone_canvas.h" | |
11 #include "ui/gfx/skia_util.h" | 10 #include "ui/gfx/skia_util.h" |
12 #include "ui/gfx/vsync_provider.h" | 11 #include "ui/gfx/vsync_provider.h" |
13 #include "ui/ozone/platform/caca/caca_connection.h" | 12 #include "ui/ozone/platform/caca/caca_connection.h" |
| 13 #include "ui/ozone/public/surface_ozone_canvas.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; | 19 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; |
20 | 20 |
21 class CacaSurface : public gfx::SurfaceOzoneCanvas { | 21 class CacaSurface : public ui::SurfaceOzoneCanvas { |
22 public: | 22 public: |
23 CacaSurface(CacaConnection* connection); | 23 CacaSurface(CacaConnection* connection); |
24 virtual ~CacaSurface(); | 24 virtual ~CacaSurface(); |
25 | 25 |
26 bool Initialize(); | 26 bool Initialize(); |
27 | 27 |
28 // gfx::SurfaceOzoneCanvas overrides: | 28 // ui::SurfaceOzoneCanvas overrides: |
29 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE; | 29 virtual skia::RefPtr<SkCanvas> GetCanvas() OVERRIDE; |
30 virtual void ResizeCanvas(const gfx::Size& viewport_size) OVERRIDE; | 30 virtual void ResizeCanvas(const gfx::Size& viewport_size) OVERRIDE; |
31 virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE; | 31 virtual void PresentCanvas(const gfx::Rect& damage) OVERRIDE; |
32 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; | 32 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE; |
33 | 33 |
34 private: | 34 private: |
35 CacaConnection* connection_; // Not owned. | 35 CacaConnection* connection_; // Not owned. |
36 | 36 |
37 caca_dither_t* dither_; | 37 caca_dither_t* dither_; |
38 | 38 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 CacaSurfaceFactory::CacaSurfaceFactory(CacaConnection* connection) | 104 CacaSurfaceFactory::CacaSurfaceFactory(CacaConnection* connection) |
105 : state_(UNINITIALIZED), | 105 : state_(UNINITIALIZED), |
106 connection_(connection) { | 106 connection_(connection) { |
107 } | 107 } |
108 | 108 |
109 CacaSurfaceFactory::~CacaSurfaceFactory() { | 109 CacaSurfaceFactory::~CacaSurfaceFactory() { |
110 if (state_ == INITIALIZED) | 110 if (state_ == INITIALIZED) |
111 ShutdownHardware(); | 111 ShutdownHardware(); |
112 } | 112 } |
113 | 113 |
114 gfx::SurfaceFactoryOzone::HardwareState | 114 ui::SurfaceFactoryOzone::HardwareState |
115 CacaSurfaceFactory::InitializeHardware() { | 115 CacaSurfaceFactory::InitializeHardware() { |
116 connection_->Initialize(); | 116 connection_->Initialize(); |
117 state_ = INITIALIZED; | 117 state_ = INITIALIZED; |
118 return state_; | 118 return state_; |
119 } | 119 } |
120 | 120 |
121 void CacaSurfaceFactory::ShutdownHardware() { | 121 void CacaSurfaceFactory::ShutdownHardware() { |
122 CHECK_EQ(INITIALIZED, state_); | 122 CHECK_EQ(INITIALIZED, state_); |
123 state_ = UNINITIALIZED; | 123 state_ = UNINITIALIZED; |
124 } | 124 } |
125 | 125 |
126 gfx::AcceleratedWidget CacaSurfaceFactory::GetAcceleratedWidget() { | 126 gfx::AcceleratedWidget CacaSurfaceFactory::GetAcceleratedWidget() { |
127 return kDefaultWidgetHandle; | 127 return kDefaultWidgetHandle; |
128 } | 128 } |
129 | 129 |
130 bool CacaSurfaceFactory::LoadEGLGLES2Bindings( | 130 bool CacaSurfaceFactory::LoadEGLGLES2Bindings( |
131 AddGLLibraryCallback add_gl_library, | 131 AddGLLibraryCallback add_gl_library, |
132 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 132 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
133 NOTREACHED(); | 133 NOTREACHED(); |
134 return false; | 134 return false; |
135 } | 135 } |
136 | 136 |
137 scoped_ptr<gfx::SurfaceOzoneCanvas> CacaSurfaceFactory::CreateCanvasForWidget( | 137 scoped_ptr<ui::SurfaceOzoneCanvas> CacaSurfaceFactory::CreateCanvasForWidget( |
138 gfx::AcceleratedWidget widget) { | 138 gfx::AcceleratedWidget widget) { |
139 CHECK_EQ(INITIALIZED, state_); | 139 CHECK_EQ(INITIALIZED, state_); |
140 CHECK_EQ(kDefaultWidgetHandle, widget); | 140 CHECK_EQ(kDefaultWidgetHandle, widget); |
141 | 141 |
142 scoped_ptr<CacaSurface> canvas(new CacaSurface(connection_)); | 142 scoped_ptr<CacaSurface> canvas(new CacaSurface(connection_)); |
143 CHECK(canvas->Initialize()); | 143 CHECK(canvas->Initialize()); |
144 return canvas.PassAs<gfx::SurfaceOzoneCanvas>(); | 144 return canvas.PassAs<ui::SurfaceOzoneCanvas>(); |
145 } | 145 } |
146 | 146 |
147 } // namespace ui | 147 } // namespace ui |
OLD | NEW |