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

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 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
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
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)
no sievers 2016/02/22 22:50:03 nit: Can you put a comment that we do this for all
Jinsuk Kim 2016/02/23 01:27:38 Done.
937 if (base::SysInfo::IsLowEndDevice())
938 format = SURFACE_RGB565;
939 #endif
940 return Initialize(format);
941 }
942
938 bool PbufferGLSurfaceEGL::Initialize(GLSurface::Format format) { 943 bool PbufferGLSurfaceEGL::Initialize(GLSurface::Format format) {
939 EGLSurface old_surface = surface_; 944 EGLSurface old_surface = surface_;
940 format_ = format; 945 format_ = format;
941 946
942 EGLDisplay display = GetDisplay(); 947 EGLDisplay display = GetDisplay();
943 if (!display) { 948 if (!display) {
944 LOG(ERROR) << "Trying to create surface with invalid display."; 949 LOG(ERROR) << "Trying to create surface with invalid display.";
945 return false; 950 return false;
946 } 951 }
947 952
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1103 }
1099 1104
1100 void* SurfacelessEGL::GetShareHandle() { 1105 void* SurfacelessEGL::GetShareHandle() {
1101 return NULL; 1106 return NULL;
1102 } 1107 }
1103 1108
1104 SurfacelessEGL::~SurfacelessEGL() { 1109 SurfacelessEGL::~SurfacelessEGL() {
1105 } 1110 }
1106 1111
1107 } // namespace gfx 1112 } // namespace gfx
OLDNEW
« ui/gl/gl_surface_egl.h ('K') | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698