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

Side by Side Diff: gpu/command_buffer/service/gl_context_virtual.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: rebased 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 "gpu/command_buffer/service/gl_context_virtual.h" 5 #include "gpu/command_buffer/service/gl_context_virtual.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 8 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
10 #include "ui/gl/gl_gl_api_implementation.h" 10 #include "ui/gl/gl_gl_api_implementation.h"
11 #include "ui/gl/gl_surface.h" 11 #include "ui/gl/gl_surface.h"
12 #include "ui/gl/gpu_preference.h" 12 #include "ui/gl/gpu_preference.h"
13 #include "ui/gl/gpu_timing.h" 13 #include "ui/gl/gpu_timing.h"
14 #include "ui/gl/scoped_api.h" 14 #include "ui/gl/scoped_api.h"
15 15
16 namespace gpu { 16 namespace gpu {
17 17
18 GLContextVirtual::GLContextVirtual( 18 GLContextVirtual::GLContextVirtual(
19 gfx::GLShareGroup* share_group, 19 gfx::GLShareGroup* share_group,
20 gfx::GLContext* shared_context, 20 gfx::GLContext* shared_context,
21 base::WeakPtr<gles2::GLES2Decoder> decoder) 21 base::WeakPtr<gles2::GLES2Decoder> decoder)
22 : GLContext(share_group), 22 : GLContext(share_group),
23 shared_context_(shared_context), 23 shared_context_(shared_context),
24 decoder_(decoder) { 24 decoder_(decoder) {
25 } 25 }
26 26
27 bool GLContextVirtual::Initialize( 27 bool GLContextVirtual::Initialize(
28 gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) { 28 gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) {
29 SetGLStateRestorer(new GLStateRestorerImpl(decoder_)); 29 SetGLStateRestorer(new GLStateRestorerImpl(decoder_));
30 format_ = compatible_surface->GetFormat();
30 31
31 // Virtual contexts obviously can't make a context that is compatible 32 // Virtual contexts obviously can't make a context that is compatible
32 // with the surface (the context already exists), but we do need to 33 // with the surface (the context already exists), but we do need to
33 // make a context current for SetupForVirtualization() below. 34 // make a context current for SetupForVirtualization() below.
34 if (!IsCurrent(compatible_surface)) { 35 if (!IsCurrent(compatible_surface)) {
35 if (!shared_context_->MakeCurrent(compatible_surface)) { 36 if (!shared_context_->MakeCurrent(compatible_surface)) {
36 // This is likely an error. The real context should be made as 37 // This is likely an error. The real context should be made as
37 // compatible with all required surfaces when it was created. 38 // compatible with all required surfaces when it was created.
38 LOG(ERROR) << "Failed MakeCurrent(compatible_surface)"; 39 LOG(ERROR) << "Failed MakeCurrent(compatible_surface)";
39 return false; 40 return false;
40 } 41 }
41 } 42 }
42 43
43 shared_context_->SetupForVirtualization(); 44 shared_context_->SetupForVirtualization();
44 shared_context_->MakeVirtuallyCurrent(this, compatible_surface); 45 shared_context_->MakeVirtuallyCurrent(this, compatible_surface);
45 return true; 46 return true;
46 } 47 }
47 48
48 void GLContextVirtual::Destroy() { 49 void GLContextVirtual::Destroy() {
49 shared_context_->OnReleaseVirtuallyCurrent(this); 50 shared_context_->OnReleaseVirtuallyCurrent(this);
50 shared_context_ = NULL; 51 shared_context_ = NULL;
51 } 52 }
52 53
54 void GLContextVirtual::UpdateSharedContext(GLContext* context) {
55 shared_context_ = context;
56 }
57
53 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) { 58 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) {
54 if (decoder_.get()) 59 if (decoder_.get())
55 return shared_context_->MakeVirtuallyCurrent(this, surface); 60 return shared_context_->MakeVirtuallyCurrent(this, surface);
56 61
57 LOG(ERROR) << "Trying to make virtual context current without decoder."; 62 LOG(ERROR) << "Trying to make virtual context current without decoder.";
58 return false; 63 return false;
59 } 64 }
60 65
61 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { 66 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) {
62 if (IsCurrent(surface)) { 67 if (IsCurrent(surface)) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api; 124 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api;
120 GetGLStateRestorer()->RestoreState(NULL); 125 GetGLStateRestorer()->RestoreState(NULL);
121 shared_context_->SetStateWasDirtiedExternally(false); 126 shared_context_->SetStateWasDirtiedExternally(false);
122 } 127 }
123 128
124 GLContextVirtual::~GLContextVirtual() { 129 GLContextVirtual::~GLContextVirtual() {
125 Destroy(); 130 Destroy();
126 } 131 }
127 132
128 } // namespace gpu 133 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698