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/egltest/ozone_platform_egltest.h" | 5 #include "ui/ozone/platform/egltest/ozone_platform_egltest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 class EgltestWindow : public PlatformWindow, public PlatformEventDispatcher { | 48 class EgltestWindow : public PlatformWindow, public PlatformEventDispatcher { |
49 public: | 49 public: |
50 EgltestWindow(PlatformWindowDelegate* delegate, | 50 EgltestWindow(PlatformWindowDelegate* delegate, |
51 LibeglplatformShimLoader* eglplatform_shim, | 51 LibeglplatformShimLoader* eglplatform_shim, |
52 EventFactoryEvdev* event_factory, | 52 EventFactoryEvdev* event_factory, |
53 const gfx::Rect& bounds); | 53 const gfx::Rect& bounds); |
54 virtual ~EgltestWindow(); | 54 virtual ~EgltestWindow(); |
55 | 55 |
56 // PlatformWindow: | 56 // PlatformWindow: |
57 virtual gfx::Rect GetBounds() OVERRIDE; | 57 virtual gfx::Rect GetBounds() override; |
58 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 58 virtual void SetBounds(const gfx::Rect& bounds) override; |
59 virtual void Show() OVERRIDE; | 59 virtual void Show() override; |
60 virtual void Hide() OVERRIDE; | 60 virtual void Hide() override; |
61 virtual void Close() OVERRIDE; | 61 virtual void Close() override; |
62 virtual void SetCapture() OVERRIDE; | 62 virtual void SetCapture() override; |
63 virtual void ReleaseCapture() OVERRIDE; | 63 virtual void ReleaseCapture() override; |
64 virtual void ToggleFullscreen() OVERRIDE; | 64 virtual void ToggleFullscreen() override; |
65 virtual void Maximize() OVERRIDE; | 65 virtual void Maximize() override; |
66 virtual void Minimize() OVERRIDE; | 66 virtual void Minimize() override; |
67 virtual void Restore() OVERRIDE; | 67 virtual void Restore() override; |
68 virtual void SetCursor(PlatformCursor cursor) OVERRIDE; | 68 virtual void SetCursor(PlatformCursor cursor) override; |
69 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; | 69 virtual void MoveCursorTo(const gfx::Point& location) override; |
70 | 70 |
71 // PlatformEventDispatcher: | 71 // PlatformEventDispatcher: |
72 virtual bool CanDispatchEvent(const PlatformEvent& event) OVERRIDE; | 72 virtual bool CanDispatchEvent(const PlatformEvent& event) override; |
73 virtual uint32_t DispatchEvent(const PlatformEvent& event) OVERRIDE; | 73 virtual uint32_t DispatchEvent(const PlatformEvent& event) override; |
74 | 74 |
75 private: | 75 private: |
76 PlatformWindowDelegate* delegate_; | 76 PlatformWindowDelegate* delegate_; |
77 LibeglplatformShimLoader* eglplatform_shim_; | 77 LibeglplatformShimLoader* eglplatform_shim_; |
78 EventFactoryEvdev* event_factory_; | 78 EventFactoryEvdev* event_factory_; |
79 gfx::Rect bounds_; | 79 gfx::Rect bounds_; |
80 ShimNativeWindowId window_id_; | 80 ShimNativeWindowId window_id_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(EgltestWindow); | 82 DISALLOW_COPY_AND_ASSIGN(EgltestWindow); |
83 }; | 83 }; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 SurfaceOzoneEgltest(ShimNativeWindowId window_id, | 167 SurfaceOzoneEgltest(ShimNativeWindowId window_id, |
168 LibeglplatformShimLoader* eglplatform_shim) | 168 LibeglplatformShimLoader* eglplatform_shim) |
169 : eglplatform_shim_(eglplatform_shim) { | 169 : eglplatform_shim_(eglplatform_shim) { |
170 native_window_ = eglplatform_shim_->ShimGetNativeWindow(window_id); | 170 native_window_ = eglplatform_shim_->ShimGetNativeWindow(window_id); |
171 } | 171 } |
172 virtual ~SurfaceOzoneEgltest() { | 172 virtual ~SurfaceOzoneEgltest() { |
173 bool ret = eglplatform_shim_->ShimReleaseNativeWindow(native_window_); | 173 bool ret = eglplatform_shim_->ShimReleaseNativeWindow(native_window_); |
174 DCHECK(ret); | 174 DCHECK(ret); |
175 } | 175 } |
176 | 176 |
177 virtual intptr_t GetNativeWindow() OVERRIDE { return native_window_; } | 177 virtual intptr_t GetNativeWindow() override { return native_window_; } |
178 | 178 |
179 virtual bool OnSwapBuffers() OVERRIDE { return true; } | 179 virtual bool OnSwapBuffers() override { return true; } |
180 | 180 |
181 virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) OVERRIDE { | 181 virtual bool ResizeNativeWindow(const gfx::Size& viewport_size) override { |
182 return true; | 182 return true; |
183 } | 183 } |
184 | 184 |
185 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() OVERRIDE { | 185 virtual scoped_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { |
186 return scoped_ptr<gfx::VSyncProvider>(); | 186 return scoped_ptr<gfx::VSyncProvider>(); |
187 } | 187 } |
188 | 188 |
189 private: | 189 private: |
190 LibeglplatformShimLoader* eglplatform_shim_; | 190 LibeglplatformShimLoader* eglplatform_shim_; |
191 intptr_t native_window_; | 191 intptr_t native_window_; |
192 }; | 192 }; |
193 | 193 |
194 // EGL surface factory for libeglplatform_shim. | 194 // EGL surface factory for libeglplatform_shim. |
195 // | 195 // |
196 // This finds the right EGL/GLES2 libraries for loading, and creates | 196 // This finds the right EGL/GLES2 libraries for loading, and creates |
197 // a single native window via ShimCreateWindow for drawing | 197 // a single native window via ShimCreateWindow for drawing |
198 // into. | 198 // into. |
199 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { | 199 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { |
200 public: | 200 public: |
201 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) | 201 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) |
202 : eglplatform_shim_(eglplatform_shim) {} | 202 : eglplatform_shim_(eglplatform_shim) {} |
203 virtual ~SurfaceFactoryEgltest() {} | 203 virtual ~SurfaceFactoryEgltest() {} |
204 | 204 |
205 // SurfaceFactoryOzone: | 205 // SurfaceFactoryOzone: |
206 virtual intptr_t GetNativeDisplay() OVERRIDE; | 206 virtual intptr_t GetNativeDisplay() override; |
207 virtual scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget( | 207 virtual scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget( |
208 gfx::AcceleratedWidget widget) OVERRIDE; | 208 gfx::AcceleratedWidget widget) override; |
209 virtual const int32* GetEGLSurfaceProperties( | 209 virtual const int32* GetEGLSurfaceProperties( |
210 const int32* desired_list) OVERRIDE; | 210 const int32* desired_list) override; |
211 virtual bool LoadEGLGLES2Bindings( | 211 virtual bool LoadEGLGLES2Bindings( |
212 AddGLLibraryCallback add_gl_library, | 212 AddGLLibraryCallback add_gl_library, |
213 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE; | 213 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; |
214 | 214 |
215 private: | 215 private: |
216 LibeglplatformShimLoader* eglplatform_shim_; | 216 LibeglplatformShimLoader* eglplatform_shim_; |
217 }; | 217 }; |
218 | 218 |
219 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { | 219 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { |
220 return eglplatform_shim_->ShimGetNativeDisplay(); | 220 return eglplatform_shim_->ShimGetNativeDisplay(); |
221 } | 221 } |
222 | 222 |
223 scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( | 223 scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 LOG(FATAL) << "failed to load " << library; | 311 LOG(FATAL) << "failed to load " << library; |
312 } | 312 } |
313 | 313 |
314 void Initialize() { | 314 void Initialize() { |
315 LoadShim(); | 315 LoadShim(); |
316 shim_initialized_ = eglplatform_shim_.ShimInitialize(); | 316 shim_initialized_ = eglplatform_shim_.ShimInitialize(); |
317 } | 317 } |
318 | 318 |
319 // OzonePlatform: | 319 // OzonePlatform: |
320 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 320 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
321 return surface_factory_ozone_.get(); | 321 return surface_factory_ozone_.get(); |
322 } | 322 } |
323 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { | 323 virtual CursorFactoryOzone* GetCursorFactoryOzone() override { |
324 return cursor_factory_ozone_.get(); | 324 return cursor_factory_ozone_.get(); |
325 } | 325 } |
326 virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE { | 326 virtual GpuPlatformSupport* GetGpuPlatformSupport() override { |
327 return gpu_platform_support_.get(); | 327 return gpu_platform_support_.get(); |
328 } | 328 } |
329 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE { | 329 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
330 return gpu_platform_support_host_.get(); | 330 return gpu_platform_support_host_.get(); |
331 } | 331 } |
332 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( | 332 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( |
333 PlatformWindowDelegate* delegate, | 333 PlatformWindowDelegate* delegate, |
334 const gfx::Rect& bounds) OVERRIDE { | 334 const gfx::Rect& bounds) override { |
335 return make_scoped_ptr<PlatformWindow>( | 335 return make_scoped_ptr<PlatformWindow>( |
336 new EgltestWindow(delegate, | 336 new EgltestWindow(delegate, |
337 &eglplatform_shim_, | 337 &eglplatform_shim_, |
338 event_factory_ozone_.get(), | 338 event_factory_ozone_.get(), |
339 bounds)); | 339 bounds)); |
340 } | 340 } |
341 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | 341 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
342 OVERRIDE { | 342 override { |
343 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); | 343 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
344 } | 344 } |
345 | 345 |
346 virtual void InitializeUI() OVERRIDE { | 346 virtual void InitializeUI() override { |
347 device_manager_ = CreateDeviceManager(); | 347 device_manager_ = CreateDeviceManager(); |
348 if (!surface_factory_ozone_) | 348 if (!surface_factory_ozone_) |
349 surface_factory_ozone_.reset( | 349 surface_factory_ozone_.reset( |
350 new SurfaceFactoryEgltest(&eglplatform_shim_)); | 350 new SurfaceFactoryEgltest(&eglplatform_shim_)); |
351 event_factory_ozone_.reset( | 351 event_factory_ozone_.reset( |
352 new EventFactoryEvdev(NULL, device_manager_.get())); | 352 new EventFactoryEvdev(NULL, device_manager_.get())); |
353 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | 353 cursor_factory_ozone_.reset(new CursorFactoryOzone()); |
354 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 354 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
355 } | 355 } |
356 | 356 |
357 virtual void InitializeGPU() OVERRIDE { | 357 virtual void InitializeGPU() override { |
358 if (!surface_factory_ozone_) | 358 if (!surface_factory_ozone_) |
359 surface_factory_ozone_.reset( | 359 surface_factory_ozone_.reset( |
360 new SurfaceFactoryEgltest(&eglplatform_shim_)); | 360 new SurfaceFactoryEgltest(&eglplatform_shim_)); |
361 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 361 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
362 } | 362 } |
363 | 363 |
364 private: | 364 private: |
365 LibeglplatformShimLoader eglplatform_shim_; | 365 LibeglplatformShimLoader eglplatform_shim_; |
366 scoped_ptr<DeviceManager> device_manager_; | 366 scoped_ptr<DeviceManager> device_manager_; |
367 scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_; | 367 scoped_ptr<SurfaceFactoryEgltest> surface_factory_ozone_; |
368 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 368 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
369 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 369 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
370 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 370 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
371 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | 371 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
372 | 372 |
373 bool shim_initialized_; | 373 bool shim_initialized_; |
374 | 374 |
375 DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest); | 375 DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest); |
376 }; | 376 }; |
377 | 377 |
378 } // namespace | 378 } // namespace |
379 | 379 |
380 OzonePlatform* CreateOzonePlatformEgltest() { | 380 OzonePlatform* CreateOzonePlatformEgltest() { |
381 OzonePlatformEgltest* platform = new OzonePlatformEgltest; | 381 OzonePlatformEgltest* platform = new OzonePlatformEgltest; |
382 platform->Initialize(); | 382 platform->Initialize(); |
383 return platform; | 383 return platform; |
384 } | 384 } |
385 | 385 |
386 } // namespace ui | 386 } // namespace ui |
OLD | NEW |