| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Implementation of a client that produces output in the form of RGBA | 5 // Implementation of a client that produces output in the form of RGBA |
| 6 // buffers when receiving pointer/touch events. RGB contains the lower | 6 // buffers when receiving pointer/touch events. RGB contains the lower |
| 7 // 24 bits of the event timestamp and A is 0xff. | 7 // 24 bits of the event timestamp and A is 0xff. |
| 8 | 8 |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <linux-dmabuf-unstable-v1-client-protocol.h> | 10 #include <linux-dmabuf-unstable-v1-client-protocol.h> |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 DISALLOW_COPY_AND_ASSIGN(MotionEvents); | 363 DISALLOW_COPY_AND_ASSIGN(MotionEvents); |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 int MotionEvents::Run() { | 366 int MotionEvents::Run() { |
| 367 display_.reset(wl_display_connect(nullptr)); | 367 display_.reset(wl_display_connect(nullptr)); |
| 368 if (!display_) { | 368 if (!display_) { |
| 369 LOG(ERROR) << "wl_display_connect failed"; | 369 LOG(ERROR) << "wl_display_connect failed"; |
| 370 return 1; | 370 return 1; |
| 371 } | 371 } |
| 372 | 372 |
| 373 bool gl_initialized = gl::init::InitializeGLOneOff(); | |
| 374 DCHECK(gl_initialized); | |
| 375 gl_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); | |
| 376 gl_context_ = | |
| 377 gl::init::CreateGLContext(nullptr, // share_group | |
| 378 gl_surface_.get(), gl::GLContextAttribs()); | |
| 379 | |
| 380 make_current_.reset( | |
| 381 new ui::ScopedMakeCurrent(gl_context_.get(), gl_surface_.get())); | |
| 382 | |
| 383 wl_registry_listener registry_listener = {RegistryHandler, RegistryRemover}; | 373 wl_registry_listener registry_listener = {RegistryHandler, RegistryRemover}; |
| 384 | 374 |
| 385 wl_registry* registry = wl_display_get_registry(display_.get()); | 375 wl_registry* registry = wl_display_get_registry(display_.get()); |
| 386 wl_registry_add_listener(registry, ®istry_listener, &globals_); | 376 wl_registry_add_listener(registry, ®istry_listener, &globals_); |
| 387 | 377 |
| 388 wl_display_roundtrip(display_.get()); | 378 wl_display_roundtrip(display_.get()); |
| 389 | 379 |
| 390 if (!globals_.compositor) { | 380 if (!globals_.compositor) { |
| 391 LOG(ERROR) << "Can't find compositor interface"; | 381 LOG(ERROR) << "Can't find compositor interface"; |
| 392 return 1; | 382 return 1; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 LOG_IF(ERROR, !use_drm_) << "Can't find drm device"; | 429 LOG_IF(ERROR, !use_drm_) << "Can't find drm device"; |
| 440 return 1; | 430 return 1; |
| 441 } | 431 } |
| 442 | 432 |
| 443 device_.reset(gbm_create_device(drm_fd_.get())); | 433 device_.reset(gbm_create_device(drm_fd_.get())); |
| 444 if (!device_) { | 434 if (!device_) { |
| 445 LOG(ERROR) << "Can't create gbm device"; | 435 LOG(ERROR) << "Can't create gbm device"; |
| 446 return 1; | 436 return 1; |
| 447 } | 437 } |
| 448 | 438 |
| 439 bool gl_initialized = gl::init::InitializeGLOneOff(); |
| 440 DCHECK(gl_initialized); |
| 441 gl_surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); |
| 442 gl_context_ = |
| 443 gl::init::CreateGLContext(nullptr, // share_group |
| 444 gl_surface_.get(), gl::GLContextAttribs()); |
| 445 |
| 446 make_current_.reset( |
| 447 new ui::ScopedMakeCurrent(gl_context_.get(), gl_surface_.get())); |
| 448 |
| 449 if (gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external") || | 449 if (gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external") || |
| 450 gl::GLSurfaceEGL::HasEGLExtension("EGL_ARM_implicit_external_sync")) { | 450 gl::GLSurfaceEGL::HasEGLExtension("EGL_ARM_implicit_external_sync")) { |
| 451 egl_sync_type = EGL_SYNC_FENCE_KHR; | 451 egl_sync_type = EGL_SYNC_FENCE_KHR; |
| 452 } | 452 } |
| 453 if (gl::GLSurfaceEGL::HasEGLExtension("EGL_ANDROID_native_fence_sync")) { | 453 if (gl::GLSurfaceEGL::HasEGLExtension("EGL_ANDROID_native_fence_sync")) { |
| 454 egl_sync_type = EGL_SYNC_NATIVE_FENCE_ANDROID; | 454 egl_sync_type = EGL_SYNC_NATIVE_FENCE_ANDROID; |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 sk_sp<const GrGLInterface> native_interface(GrGLCreateNativeInterface()); | 458 sk_sp<const GrGLInterface> native_interface(GrGLCreateNativeInterface()); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 new std::string(command_line->GetSwitchValueASCII(switches::kUseDrm))); | 899 new std::string(command_line->GetSwitchValueASCII(switches::kUseDrm))); |
| 900 } | 900 } |
| 901 | 901 |
| 902 exo::wayland::clients::MotionEvents client( | 902 exo::wayland::clients::MotionEvents client( |
| 903 width, height, scale, num_rects, max_frames_pending, | 903 width, height, scale, num_rects, max_frames_pending, |
| 904 command_line->HasSwitch(switches::kFullscreen), | 904 command_line->HasSwitch(switches::kFullscreen), |
| 905 command_line->HasSwitch(switches::kShowFpsCounter), num_benchmark_runs, | 905 command_line->HasSwitch(switches::kShowFpsCounter), num_benchmark_runs, |
| 906 base::TimeDelta::FromMilliseconds(benchmark_interval_ms), use_drm.get()); | 906 base::TimeDelta::FromMilliseconds(benchmark_interval_ms), use_drm.get()); |
| 907 return client.Run(); | 907 return client.Run(); |
| 908 } | 908 } |
| OLD | NEW |