| 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 config_(nullptr) {} |
| 440 format_(SURFACE_DEFAULT) {} | |
| 441 | 441 |
| 442 bool GLSurfaceEGL::InitializeOneOff() { | 442 bool GLSurfaceEGL::InitializeOneOff() { |
| 443 static bool initialized = false; | 443 static bool initialized = false; |
| 444 if (initialized) | 444 if (initialized) |
| 445 return true; | 445 return true; |
| 446 | 446 |
| 447 InitializeDisplay(); | 447 InitializeDisplay(); |
| 448 if (g_display == EGL_NO_DISPLAY) | 448 if (g_display == EGL_NO_DISPLAY) |
| 449 return false; | 449 return false; |
| 450 | 450 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 612 |
| 613 #if defined(OS_WIN) | 613 #if defined(OS_WIN) |
| 614 vsync_override_ = false; | 614 vsync_override_ = false; |
| 615 swap_generation_ = 0; | 615 swap_generation_ = 0; |
| 616 RECT windowRect; | 616 RECT windowRect; |
| 617 if (GetClientRect(window_, &windowRect)) | 617 if (GetClientRect(window_, &windowRect)) |
| 618 size_ = gfx::Rect(windowRect).size(); | 618 size_ = gfx::Rect(windowRect).size(); |
| 619 #endif | 619 #endif |
| 620 } | 620 } |
| 621 | 621 |
| 622 bool NativeViewGLSurfaceEGL::Initialize() { | |
| 623 return Initialize(SURFACE_DEFAULT); | |
| 624 } | |
| 625 | |
| 626 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { | 622 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { |
| 627 format_ = format; | 623 format_ = format; |
| 628 return Initialize(nullptr); | 624 return Initialize(nullptr); |
| 629 } | 625 } |
| 630 | 626 |
| 631 bool NativeViewGLSurfaceEGL::Initialize( | 627 bool NativeViewGLSurfaceEGL::Initialize( |
| 632 scoped_ptr<VSyncProvider> sync_provider) { | 628 scoped_ptr<VSyncProvider> sync_provider) { |
| 633 DCHECK(!surface_); | 629 DCHECK(!surface_); |
| 634 | 630 |
| 635 if (!GetDisplay()) { | 631 if (!GetDisplay()) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 924 |
| 929 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) | 925 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) |
| 930 : size_(size), | 926 : size_(size), |
| 931 surface_(NULL) { | 927 surface_(NULL) { |
| 932 // Some implementations of Pbuffer do not support having a 0 size. For such | 928 // Some implementations of Pbuffer do not support having a 0 size. For such |
| 933 // cases use a (1, 1) surface. | 929 // cases use a (1, 1) surface. |
| 934 if (size_.GetArea() == 0) | 930 if (size_.GetArea() == 0) |
| 935 size_.SetSize(1, 1); | 931 size_.SetSize(1, 1); |
| 936 } | 932 } |
| 937 | 933 |
| 934 bool PbufferGLSurfaceEGL::Initialize() { |
| 935 GLSurface::Format format = SURFACE_DEFAULT; |
| 936 #if defined(OS_ANDROID) |
| 937 // This is to allow context virtualization which requires on- and offscreen |
| 938 // to use a compatible config. We expect the client to request RGB565 |
| 939 // onscreen surface also for this to work (with the exception of |
| 940 // fullscreen video). |
| 941 if (base::SysInfo::IsLowEndDevice()) |
| 942 format = SURFACE_RGB565; |
| 943 #endif |
| 944 return Initialize(format); |
| 945 } |
| 946 |
| 938 bool PbufferGLSurfaceEGL::Initialize(GLSurface::Format format) { | 947 bool PbufferGLSurfaceEGL::Initialize(GLSurface::Format format) { |
| 939 EGLSurface old_surface = surface_; | 948 EGLSurface old_surface = surface_; |
| 940 format_ = format; | 949 format_ = format; |
| 941 | 950 |
| 942 EGLDisplay display = GetDisplay(); | 951 EGLDisplay display = GetDisplay(); |
| 943 if (!display) { | 952 if (!display) { |
| 944 LOG(ERROR) << "Trying to create surface with invalid display."; | 953 LOG(ERROR) << "Trying to create surface with invalid display."; |
| 945 return false; | 954 return false; |
| 946 } | 955 } |
| 947 | 956 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 } | 1107 } |
| 1099 | 1108 |
| 1100 void* SurfacelessEGL::GetShareHandle() { | 1109 void* SurfacelessEGL::GetShareHandle() { |
| 1101 return NULL; | 1110 return NULL; |
| 1102 } | 1111 } |
| 1103 | 1112 |
| 1104 SurfacelessEGL::~SurfacelessEGL() { | 1113 SurfacelessEGL::~SurfacelessEGL() { |
| 1105 } | 1114 } |
| 1106 | 1115 |
| 1107 } // namespace gfx | 1116 } // namespace gfx |
| OLD | NEW |