OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gl/gl_surface_egl.h" | 5 #include "ui/gl/gl_surface_egl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/sys_info.h" | |
19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
22 #include "ui/gl/egl_util.h" | 23 #include "ui/gl/egl_util.h" |
23 #include "ui/gl/gl_context.h" | 24 #include "ui/gl/gl_context.h" |
24 #include "ui/gl/gl_image.h" | 25 #include "ui/gl/gl_image.h" |
25 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
26 #include "ui/gl/gl_surface_stub.h" | 27 #include "ui/gl/gl_surface_stub.h" |
27 #include "ui/gl/gl_switches.h" | 28 #include "ui/gl/gl_switches.h" |
28 #include "ui/gl/scoped_make_current.h" | 29 #include "ui/gl/scoped_make_current.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 } | 430 } |
430 | 431 |
431 // If no displays are available due to missing angle extensions or invalid | 432 // If no displays are available due to missing angle extensions or invalid |
432 // flags, request the default display. | 433 // flags, request the default display. |
433 if (init_displays->empty()) { | 434 if (init_displays->empty()) { |
434 init_displays->push_back(DEFAULT); | 435 init_displays->push_back(DEFAULT); |
435 } | 436 } |
436 } | 437 } |
437 | 438 |
438 GLSurfaceEGL::GLSurfaceEGL() : | 439 GLSurfaceEGL::GLSurfaceEGL() : |
439 config_(nullptr), | 440 GLSurface(), |
440 format_(SURFACE_DEFAULT) {} | 441 config_(nullptr) {} |
441 | 442 |
442 bool GLSurfaceEGL::InitializeOneOff() { | 443 bool GLSurfaceEGL::InitializeOneOff() { |
443 static bool initialized = false; | 444 static bool initialized = false; |
444 if (initialized) | 445 if (initialized) |
445 return true; | 446 return true; |
446 | 447 |
447 InitializeDisplay(); | 448 InitializeDisplay(); |
448 if (g_display == EGL_NO_DISPLAY) | 449 if (g_display == EGL_NO_DISPLAY) |
449 return false; | 450 return false; |
450 | 451 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 } | 533 } |
533 | 534 |
534 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { | 535 bool GLSurfaceEGL::IsEGLSurfacelessContextSupported() { |
535 return g_egl_surfaceless_context_supported; | 536 return g_egl_surfaceless_context_supported; |
536 } | 537 } |
537 | 538 |
538 bool GLSurfaceEGL::IsDirectCompositionSupported() { | 539 bool GLSurfaceEGL::IsDirectCompositionSupported() { |
539 return g_use_direct_composition; | 540 return g_use_direct_composition; |
540 } | 541 } |
541 | 542 |
543 GLSurface::Format GLSurfaceEGL::GetDefaultFormat() const { | |
544 return base::SysInfo::IsLowEndDevice() ? SURFACE_RGB565 : SURFACE_ARGB8888; | |
no sievers
2016/02/18 20:19:45
wherever we override this, it needs #ifdef ANDROID
Jinsuk Kim
2016/02/19 01:04:40
Done. Moved it to PbufferGLSurafceEGL::Initialize(
| |
545 } | |
546 | |
542 GLSurfaceEGL::~GLSurfaceEGL() {} | 547 GLSurfaceEGL::~GLSurfaceEGL() {} |
543 | 548 |
544 // InitializeDisplay is necessary because the static binding code | 549 // InitializeDisplay is necessary because the static binding code |
545 // needs a full Display init before it can query the Display extensions. | 550 // needs a full Display init before it can query the Display extensions. |
546 // static | 551 // static |
547 EGLDisplay GLSurfaceEGL::InitializeDisplay() { | 552 EGLDisplay GLSurfaceEGL::InitializeDisplay() { |
548 if (g_display != EGL_NO_DISPLAY) { | 553 if (g_display != EGL_NO_DISPLAY) { |
549 return g_display; | 554 return g_display; |
550 } | 555 } |
551 | 556 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 | 617 |
613 #if defined(OS_WIN) | 618 #if defined(OS_WIN) |
614 vsync_override_ = false; | 619 vsync_override_ = false; |
615 swap_generation_ = 0; | 620 swap_generation_ = 0; |
616 RECT windowRect; | 621 RECT windowRect; |
617 if (GetClientRect(window_, &windowRect)) | 622 if (GetClientRect(window_, &windowRect)) |
618 size_ = gfx::Rect(windowRect).size(); | 623 size_ = gfx::Rect(windowRect).size(); |
619 #endif | 624 #endif |
620 } | 625 } |
621 | 626 |
622 bool NativeViewGLSurfaceEGL::Initialize() { | |
623 return Initialize(SURFACE_DEFAULT); | |
624 } | |
625 | |
626 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { | 627 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { |
627 format_ = format; | 628 format_ = format; |
628 return Initialize(nullptr); | 629 return Initialize(nullptr); |
629 } | 630 } |
630 | 631 |
631 bool NativeViewGLSurfaceEGL::Initialize( | 632 bool NativeViewGLSurfaceEGL::Initialize( |
632 scoped_ptr<VSyncProvider> sync_provider) { | 633 scoped_ptr<VSyncProvider> sync_provider) { |
633 DCHECK(!surface_); | 634 DCHECK(!surface_); |
634 | 635 |
635 if (!GetDisplay()) { | 636 if (!GetDisplay()) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1098 } | 1099 } |
1099 | 1100 |
1100 void* SurfacelessEGL::GetShareHandle() { | 1101 void* SurfacelessEGL::GetShareHandle() { |
1101 return NULL; | 1102 return NULL; |
1102 } | 1103 } |
1103 | 1104 |
1104 SurfacelessEGL::~SurfacelessEGL() { | 1105 SurfacelessEGL::~SurfacelessEGL() { |
1105 } | 1106 } |
1106 | 1107 |
1107 } // namespace gfx | 1108 } // namespace gfx |
OLD | NEW |