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

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 1652873002: Android: Use virtualized context only for those with compatible config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 10 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 (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
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(),
no sievers 2016/02/19 20:25:18 nit: not needed
Jinsuk Kim 2016/02/20 13:56:57 Done.
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 613
613 #if defined(OS_WIN) 614 #if defined(OS_WIN)
614 vsync_override_ = false; 615 vsync_override_ = false;
615 swap_generation_ = 0; 616 swap_generation_ = 0;
616 RECT windowRect; 617 RECT windowRect;
617 if (GetClientRect(window_, &windowRect)) 618 if (GetClientRect(window_, &windowRect))
618 size_ = gfx::Rect(windowRect).size(); 619 size_ = gfx::Rect(windowRect).size();
619 #endif 620 #endif
620 } 621 }
621 622
622 bool NativeViewGLSurfaceEGL::Initialize() {
623 return Initialize(SURFACE_DEFAULT);
624 }
625
626 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { 623 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) {
627 format_ = format; 624 format_ = format;
628 return Initialize(nullptr); 625 return Initialize(nullptr);
629 } 626 }
630 627
631 bool NativeViewGLSurfaceEGL::Initialize( 628 bool NativeViewGLSurfaceEGL::Initialize(
632 scoped_ptr<VSyncProvider> sync_provider) { 629 scoped_ptr<VSyncProvider> sync_provider) {
633 DCHECK(!surface_); 630 DCHECK(!surface_);
634 631
635 if (!GetDisplay()) { 632 if (!GetDisplay()) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 925
929 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) 926 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size)
930 : size_(size), 927 : size_(size),
931 surface_(NULL) { 928 surface_(NULL) {
932 // Some implementations of Pbuffer do not support having a 0 size. For such 929 // Some implementations of Pbuffer do not support having a 0 size. For such
933 // cases use a (1, 1) surface. 930 // cases use a (1, 1) surface.
934 if (size_.GetArea() == 0) 931 if (size_.GetArea() == 0)
935 size_.SetSize(1, 1); 932 size_.SetSize(1, 1);
936 } 933 }
937 934
935 bool PbufferGLSurfaceEGL::Initialize() {
936 GLSurface::Format format = SURFACE_DEFAULT;
937 #if defined(OS_ANDROID)
938 if (base::SysInfo::IsLowEndDevice())
939 format = SURFACE_RGB565;
940 #endif
941 return Initialize(format);
942 }
943
938 bool PbufferGLSurfaceEGL::Initialize(GLSurface::Format format) { 944 bool PbufferGLSurfaceEGL::Initialize(GLSurface::Format format) {
939 EGLSurface old_surface = surface_; 945 EGLSurface old_surface = surface_;
940 format_ = format; 946 format_ = format;
941 947
942 EGLDisplay display = GetDisplay(); 948 EGLDisplay display = GetDisplay();
943 if (!display) { 949 if (!display) {
944 LOG(ERROR) << "Trying to create surface with invalid display."; 950 LOG(ERROR) << "Trying to create surface with invalid display.";
945 return false; 951 return false;
946 } 952 }
947 953
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1104 }
1099 1105
1100 void* SurfacelessEGL::GetShareHandle() { 1106 void* SurfacelessEGL::GetShareHandle() {
1101 return NULL; 1107 return NULL;
1102 } 1108 }
1103 1109
1104 SurfacelessEGL::~SurfacelessEGL() { 1110 SurfacelessEGL::~SurfacelessEGL() {
1105 } 1111 }
1106 1112
1107 } // namespace gfx 1113 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698