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

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

Issue 1050923003: zero-copy: Clarify to allocate/destroy GpuMemoryBuffer on any thread and use it on the main thread o (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: just add thread check Created 5 years, 8 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
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/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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/threading/thread_checker.h"
12 #include "library_loaders/libeglplatform_shim.h" 13 #include "library_loaders/libeglplatform_shim.h"
13 #include "third_party/khronos/EGL/egl.h" 14 #include "third_party/khronos/EGL/egl.h"
14 #include "ui/events/devices/device_data_manager.h" 15 #include "ui/events/devices/device_data_manager.h"
15 #include "ui/events/event.h" 16 #include "ui/events/event.h"
16 #include "ui/events/ozone/device/device_manager.h" 17 #include "ui/events/ozone/device/device_manager.h"
17 #include "ui/events/ozone/evdev/event_factory_evdev.h" 18 #include "ui/events/ozone/evdev/event_factory_evdev.h"
18 #include "ui/events/ozone/events_ozone.h" 19 #include "ui/events/ozone/events_ozone.h"
19 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 20 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
20 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" 21 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
21 #include "ui/events/platform/platform_event_dispatcher.h" 22 #include "ui/events/platform/platform_event_dispatcher.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 234
234 // EGL surface factory for libeglplatform_shim. 235 // EGL surface factory for libeglplatform_shim.
235 // 236 //
236 // This finds the right EGL/GLES2 libraries for loading, and creates 237 // This finds the right EGL/GLES2 libraries for loading, and creates
237 // a single native window via ShimCreateWindow for drawing 238 // a single native window via ShimCreateWindow for drawing
238 // into. 239 // into.
239 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { 240 class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
240 public: 241 public:
241 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) 242 SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim)
242 : eglplatform_shim_(eglplatform_shim) {} 243 : eglplatform_shim_(eglplatform_shim) {}
243 ~SurfaceFactoryEgltest() override {} 244 ~SurfaceFactoryEgltest() override {
245 DCHECK(thread_checker_.CalledOnValidThread());
246 }
244 247
245 // SurfaceFactoryOzone: 248 // SurfaceFactoryOzone:
246 intptr_t GetNativeDisplay() override; 249 intptr_t GetNativeDisplay() override;
247 scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget( 250 scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget(
248 gfx::AcceleratedWidget widget) override; 251 gfx::AcceleratedWidget widget) override;
249 const int32* GetEGLSurfaceProperties(const int32* desired_list) override; 252 const int32* GetEGLSurfaceProperties(const int32* desired_list) override;
250 bool LoadEGLGLES2Bindings( 253 bool LoadEGLGLES2Bindings(
251 AddGLLibraryCallback add_gl_library, 254 AddGLLibraryCallback add_gl_library,
252 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; 255 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override;
253 256
254 private: 257 private:
255 LibeglplatformShimLoader* eglplatform_shim_; 258 LibeglplatformShimLoader* eglplatform_shim_;
259 base::ThreadChecker thread_checker_;
256 }; 260 };
257 261
258 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { 262 intptr_t SurfaceFactoryEgltest::GetNativeDisplay() {
263 DCHECK(thread_checker_.CalledOnValidThread());
259 return eglplatform_shim_->ShimGetNativeDisplay(); 264 return eglplatform_shim_->ShimGetNativeDisplay();
260 } 265 }
261 266
262 scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( 267 scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
263 gfx::AcceleratedWidget widget) { 268 gfx::AcceleratedWidget widget) {
269 DCHECK(thread_checker_.CalledOnValidThread());
264 return make_scoped_ptr<SurfaceOzoneEGL>( 270 return make_scoped_ptr<SurfaceOzoneEGL>(
265 new SurfaceOzoneEgltest(widget, eglplatform_shim_)); 271 new SurfaceOzoneEgltest(widget, eglplatform_shim_));
266 } 272 }
267 273
268 bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings( 274 bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings(
269 AddGLLibraryCallback add_gl_library, 275 AddGLLibraryCallback add_gl_library,
270 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { 276 SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
277 DCHECK(thread_checker_.CalledOnValidThread());
271 const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY); 278 const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY);
272 const char* gles_soname = 279 const char* gles_soname =
273 eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY); 280 eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY);
274 if (!egl_soname) 281 if (!egl_soname)
275 egl_soname = kDefaultEglSoname; 282 egl_soname = kDefaultEglSoname;
276 if (!gles_soname) 283 if (!gles_soname)
277 gles_soname = kDefaultGlesSoname; 284 gles_soname = kDefaultGlesSoname;
278 285
279 return ::ui::LoadEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address, 286 return ::ui::LoadEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address,
280 egl_soname, gles_soname); 287 egl_soname, gles_soname);
281 } 288 }
282 289
283 const int32* SurfaceFactoryEgltest::GetEGLSurfaceProperties( 290 const int32* SurfaceFactoryEgltest::GetEGLSurfaceProperties(
284 const int32* desired_list) { 291 const int32* desired_list) {
292 DCHECK(thread_checker_.CalledOnValidThread());
285 static const int32 broken_props[] = { 293 static const int32 broken_props[] = {
286 EGL_RENDERABLE_TYPE, 294 EGL_RENDERABLE_TYPE,
287 EGL_OPENGL_ES2_BIT, 295 EGL_OPENGL_ES2_BIT,
288 EGL_SURFACE_TYPE, 296 EGL_SURFACE_TYPE,
289 EGL_WINDOW_BIT | EGL_PBUFFER_BIT, 297 EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
290 EGL_NONE, 298 EGL_NONE,
291 }; 299 };
292 return broken_props; 300 return broken_props;
293 } 301 }
294 302
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 402
395 } // namespace 403 } // namespace
396 404
397 OzonePlatform* CreateOzonePlatformEgltest() { 405 OzonePlatform* CreateOzonePlatformEgltest() {
398 OzonePlatformEgltest* platform = new OzonePlatformEgltest; 406 OzonePlatformEgltest* platform = new OzonePlatformEgltest;
399 platform->Initialize(); 407 platform->Initialize();
400 return platform; 408 return platform;
401 } 409 }
402 410
403 } // namespace ui 411 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698