Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: ui/ozone/platform/egltest/ozone_platform_egltest.cc

Issue 312393002: ozone: Move the factory interfaces into a common target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r278697 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.cc ('k') | ui/ozone/platform/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "library_loaders/libeglplatform_shim.h" 11 #include "library_loaders/libeglplatform_shim.h"
12 #include "ui/base/cursor/ozone/cursor_factory_ozone.h"
13 #include "ui/events/ozone/device/device_manager.h" 12 #include "ui/events/ozone/device/device_manager.h"
14 #include "ui/events/ozone/evdev/event_factory_evdev.h" 13 #include "ui/events/ozone/evdev/event_factory_evdev.h"
15 #include "ui/gfx/ozone/impl/file_surface_factory.h"
16 #include "ui/gfx/ozone/surface_ozone_egl.h"
17 #include "ui/gfx/vsync_provider.h" 14 #include "ui/gfx/vsync_provider.h"
18 #include "ui/ozone/ozone_platform.h" 15 #include "ui/ozone/ozone_platform.h"
19 #include "ui/ozone/ozone_switches.h" 16 #include "ui/ozone/ozone_switches.h"
17 #include "ui/ozone/platform/test/file_surface_factory.h"
18 #include "ui/ozone/public/cursor_factory_ozone.h"
19 #include "ui/ozone/public/surface_ozone_egl.h"
20 20
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
22 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" 22 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h"
23 #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h" 23 #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h"
24 #endif 24 #endif
25 25
26 #include <EGL/egl.h> 26 #include <EGL/egl.h>
27 27
28 namespace ui { 28 namespace ui {
29 29
(...skipping 10 matching lines...) Expand all
40 scoped_ptr<base::Environment> env(base::Environment::Create()); 40 scoped_ptr<base::Environment> env(base::Environment::Create());
41 if (env->GetVar(kEglplatformShim, &library)) 41 if (env->GetVar(kEglplatformShim, &library))
42 return library; 42 return library;
43 return kEglplatformShimDefault; 43 return kEglplatformShimDefault;
44 } 44 }
45 45
46 // EGL surface wrapper for libeglplatform_shim. 46 // EGL surface wrapper for libeglplatform_shim.
47 // 47 //
48 // This just manages the native window lifetime using 48 // This just manages the native window lifetime using
49 // ShimGetNativeWindow & ShimReleaseNativeWindow. 49 // ShimGetNativeWindow & ShimReleaseNativeWindow.
50 class SurfaceOzoneEgltest : public gfx::SurfaceOzoneEGL { 50 class SurfaceOzoneEgltest : public SurfaceOzoneEGL {
51 public: 51 public:
52 SurfaceOzoneEgltest(ShimNativeWindowId window_id, 52 SurfaceOzoneEgltest(ShimNativeWindowId window_id,
53 LibeglplatformShimLoader* eglplatform_shim) 53 LibeglplatformShimLoader* eglplatform_shim)
54 : eglplatform_shim_(eglplatform_shim) { 54 : eglplatform_shim_(eglplatform_shim) {
55 native_window_ = eglplatform_shim_->ShimGetNativeWindow(window_id); 55 native_window_ = eglplatform_shim_->ShimGetNativeWindow(window_id);
56 } 56 }
57 virtual ~SurfaceOzoneEgltest() { 57 virtual ~SurfaceOzoneEgltest() {
58 CHECK(eglplatform_shim_->ShimReleaseNativeWindow(native_window_)); 58 CHECK(eglplatform_shim_->ShimReleaseNativeWindow(native_window_));
59 } 59 }
60 60
(...skipping 12 matching lines...) Expand all
73 private: 73 private:
74 LibeglplatformShimLoader* eglplatform_shim_; 74 LibeglplatformShimLoader* eglplatform_shim_;
75 intptr_t native_window_; 75 intptr_t native_window_;
76 }; 76 };
77 77
78 // EGL surface factory for libeglplatform_shim. 78 // EGL surface factory for libeglplatform_shim.
79 // 79 //
80 // This finds the right EGL/GLES2 libraries for loading, and creates 80 // This finds the right EGL/GLES2 libraries for loading, and creates
81 // a single native window via ShimCreateWindow for drawing 81 // a single native window via ShimCreateWindow for drawing
82 // into. 82 // into.
83 class SurfaceFactoryEgltest : public gfx::SurfaceFactoryOzone { 83 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
84 public: 84 public:
85 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) 85 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim)
86 : eglplatform_shim_(eglplatform_shim), window_id_(SHIM_NO_WINDOW_ID) {} 86 : eglplatform_shim_(eglplatform_shim), window_id_(SHIM_NO_WINDOW_ID) {}
87 virtual ~SurfaceFactoryEgltest() { DestroySingleWindow(); } 87 virtual ~SurfaceFactoryEgltest() { DestroySingleWindow(); }
88 88
89 // Create the window. 89 // Create the window.
90 bool CreateSingleWindow(); 90 bool CreateSingleWindow();
91 void DestroySingleWindow(); 91 void DestroySingleWindow();
92 92
93 // SurfaceFactoryOzone: 93 // SurfaceFactoryOzone:
94 virtual HardwareState InitializeHardware() OVERRIDE; 94 virtual HardwareState InitializeHardware() OVERRIDE;
95 virtual void ShutdownHardware() OVERRIDE; 95 virtual void ShutdownHardware() OVERRIDE;
96 virtual intptr_t GetNativeDisplay() OVERRIDE; 96 virtual intptr_t GetNativeDisplay() OVERRIDE;
97 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; 97 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
98 virtual scoped_ptr<gfx::SurfaceOzoneEGL> CreateEGLSurfaceForWidget( 98 virtual scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget(
99 gfx::AcceleratedWidget widget) OVERRIDE; 99 gfx::AcceleratedWidget widget) OVERRIDE;
100 virtual const int32* GetEGLSurfaceProperties( 100 virtual const int32* GetEGLSurfaceProperties(
101 const int32* desired_list) OVERRIDE; 101 const int32* desired_list) OVERRIDE;
102 virtual bool LoadEGLGLES2Bindings( 102 virtual bool LoadEGLGLES2Bindings(
103 AddGLLibraryCallback add_gl_library, 103 AddGLLibraryCallback add_gl_library,
104 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE; 104 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE;
105 105
106 private: 106 private:
107 LibeglplatformShimLoader* eglplatform_shim_; 107 LibeglplatformShimLoader* eglplatform_shim_;
108 108
(...skipping 22 matching lines...) Expand all
131 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { 131 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() {
132 return eglplatform_shim_->ShimGetNativeDisplay(); 132 return eglplatform_shim_->ShimGetNativeDisplay();
133 } 133 }
134 134
135 gfx::AcceleratedWidget SurfaceFactoryEgltest::GetAcceleratedWidget() { 135 gfx::AcceleratedWidget SurfaceFactoryEgltest::GetAcceleratedWidget() {
136 if (window_id_ == SHIM_NO_WINDOW_ID && !CreateSingleWindow()) 136 if (window_id_ == SHIM_NO_WINDOW_ID && !CreateSingleWindow())
137 LOG(FATAL) << "failed to create window"; 137 LOG(FATAL) << "failed to create window";
138 return window_id_; 138 return window_id_;
139 } 139 }
140 140
141 scoped_ptr<gfx::SurfaceOzoneEGL> 141 scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
142 SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
143 gfx::AcceleratedWidget widget) { 142 gfx::AcceleratedWidget widget) {
144 return make_scoped_ptr<gfx::SurfaceOzoneEGL>( 143 return make_scoped_ptr<SurfaceOzoneEGL>(
145 new SurfaceOzoneEgltest(widget, eglplatform_shim_)); 144 new SurfaceOzoneEgltest(widget, eglplatform_shim_));
146 } 145 }
147 146
148 bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings( 147 bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings(
149 AddGLLibraryCallback add_gl_library, 148 AddGLLibraryCallback add_gl_library,
150 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { 149 SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
151 const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY); 150 const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY);
152 const char* gles_soname = 151 const char* gles_soname =
153 eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY); 152 eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY);
154 if (!egl_soname) 153 if (!egl_soname)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 228
230 LOG(FATAL) << "failed to load " << library; 229 LOG(FATAL) << "failed to load " << library;
231 } 230 }
232 231
233 void Initialize() { 232 void Initialize() {
234 LoadShim(); 233 LoadShim();
235 shim_initialized_ = eglplatform_shim_.ShimInitialize(); 234 shim_initialized_ = eglplatform_shim_.ShimInitialize();
236 } 235 }
237 236
238 // OzonePlatform: 237 // OzonePlatform:
239 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { 238 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
240 return surface_factory_ozone_.get(); 239 return surface_factory_ozone_.get();
241 } 240 }
242 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { 241 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
243 return event_factory_ozone_.get(); 242 return event_factory_ozone_.get();
244 } 243 }
245 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { 244 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
246 return cursor_factory_ozone_.get(); 245 return cursor_factory_ozone_.get();
247 } 246 }
248 247
249 #if defined(OS_CHROMEOS) 248 #if defined(OS_CHROMEOS)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 283
285 } // namespace 284 } // namespace
286 285
287 OzonePlatform* CreateOzonePlatformEgltest() { 286 OzonePlatform* CreateOzonePlatformEgltest() {
288 OzonePlatformEgltest* platform = new OzonePlatformEgltest; 287 OzonePlatformEgltest* platform = new OzonePlatformEgltest;
289 platform->Initialize(); 288 platform->Initialize();
290 return platform; 289 return platform;
291 } 290 }
292 291
293 } // namespace ui 292 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.cc ('k') | ui/ozone/platform/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698