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

Side by Side Diff: components/mus/gles2/command_buffer_driver.cc

Issue 2106103005: Revert of Pass initial size and GPU preference via context attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/mus/gles2/command_buffer_driver.h" 5 #include "components/mus/gles2/command_buffer_driver.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 DestroyDecoder(); 76 DestroyDecoder();
77 } 77 }
78 78
79 bool CommandBufferDriver::Initialize( 79 bool CommandBufferDriver::Initialize(
80 mojo::ScopedSharedBufferHandle shared_state, 80 mojo::ScopedSharedBufferHandle shared_state,
81 mojo::Array<int32_t> attribs) { 81 mojo::Array<int32_t> attribs) {
82 DCHECK(CalledOnValidThread()); 82 DCHECK(CalledOnValidThread());
83 gpu::gles2::ContextCreationAttribHelper attrib_helper; 83 gpu::gles2::ContextCreationAttribHelper attrib_helper;
84 if (!attrib_helper.Parse(attribs.storage())) 84 if (!attrib_helper.Parse(attribs.storage()))
85 return false; 85 return false;
86 // TODO(piman): attribs can't currently represent gpu_preference.
87 86
88 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; 87 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget;
89 if (offscreen) { 88 if (offscreen) {
90 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size(0, 0)); 89 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size(0, 0));
91 } else { 90 } else {
92 #if defined(USE_OZONE) 91 #if defined(USE_OZONE)
93 scoped_refptr<gl::GLSurface> underlying_surface = 92 scoped_refptr<gl::GLSurface> underlying_surface =
94 gl::init::CreateSurfacelessViewGLSurface(widget_); 93 gl::init::CreateSurfacelessViewGLSurface(widget_);
95 if (!underlying_surface) 94 if (!underlying_surface)
96 underlying_surface = gl::init::CreateViewGLSurface(widget_); 95 underlying_surface = gl::init::CreateViewGLSurface(widget_);
(...skipping 13 matching lines...) Expand all
110 if (vsync_provider) { 109 if (vsync_provider) {
111 vsync_provider->GetVSyncParameters( 110 vsync_provider->GetVSyncParameters(
112 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, 111 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters,
113 weak_factory_.GetWeakPtr())); 112 weak_factory_.GetWeakPtr()));
114 } 113 }
115 } 114 }
116 115
117 if (!surface_.get()) 116 if (!surface_.get())
118 return false; 117 return false;
119 118
120 // TODO(piman): virtual contexts. 119 // TODO(piman): virtual contexts, gpu preference.
121 context_ = gl::init::CreateGLContext( 120 context_ = gl::init::CreateGLContext(gpu_state_->share_group(),
122 gpu_state_->share_group(), surface_.get(), attrib_helper.gpu_preference); 121 surface_.get(), gl::PreferIntegratedGpu);
123 if (!context_.get()) 122 if (!context_.get())
124 return false; 123 return false;
125 124
126 if (!context_->MakeCurrent(surface_.get())) 125 if (!context_->MakeCurrent(surface_.get()))
127 return false; 126 return false;
128 127
129 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but 128 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but
130 // only needs to be per-thread. 129 // only needs to be per-thread.
131 const bool bind_generates_resource = attrib_helper.bind_generates_resource; 130 const bool bind_generates_resource = attrib_helper.bind_generates_resource;
132 scoped_refptr<gpu::gles2::FeatureInfo> feature_info = 131 scoped_refptr<gpu::gles2::FeatureInfo> feature_info =
(...skipping 22 matching lines...) Expand all
155 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); 154 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this)));
156 decoder_->SetWaitFenceSyncCallback(base::Bind( 155 decoder_->SetWaitFenceSyncCallback(base::Bind(
157 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); 156 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this)));
158 decoder_->SetDescheduleUntilFinishedCallback(base::Bind( 157 decoder_->SetDescheduleUntilFinishedCallback(base::Bind(
159 &CommandBufferDriver::OnDescheduleUntilFinished, base::Unretained(this))); 158 &CommandBufferDriver::OnDescheduleUntilFinished, base::Unretained(this)));
160 decoder_->SetRescheduleAfterFinishedCallback(base::Bind( 159 decoder_->SetRescheduleAfterFinishedCallback(base::Bind(
161 &CommandBufferDriver::OnRescheduleAfterFinished, base::Unretained(this))); 160 &CommandBufferDriver::OnRescheduleAfterFinished, base::Unretained(this)));
162 161
163 gpu::gles2::DisallowedFeatures disallowed_features; 162 gpu::gles2::DisallowedFeatures disallowed_features;
164 163
165 if (!decoder_->Initialize(surface_, context_, offscreen, disallowed_features, 164 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1),
166 attrib_helper)) 165 disallowed_features, attrib_helper))
167 return false; 166 return false;
168 167
169 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 168 command_buffer_->SetPutOffsetChangeCallback(base::Bind(
170 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); 169 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get())));
171 command_buffer_->SetGetBufferChangeCallback(base::Bind( 170 command_buffer_->SetGetBufferChangeCallback(base::Bind(
172 &gpu::CommandExecutor::SetGetBuffer, base::Unretained(executor_.get()))); 171 &gpu::CommandExecutor::SetGetBuffer, base::Unretained(executor_.get())));
173 command_buffer_->SetParseErrorCallback( 172 command_buffer_->SetParseErrorCallback(
174 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); 173 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this)));
175 174
176 // TODO(piman): other callbacks 175 // TODO(piman): other callbacks
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 558 }
560 559
561 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { 560 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) {
562 DCHECK(CalledOnValidThread()); 561 DCHECK(CalledOnValidThread());
563 if (client_) { 562 if (client_) {
564 client_->OnGpuCompletedSwapBuffers(result); 563 client_->OnGpuCompletedSwapBuffers(result);
565 } 564 }
566 } 565 }
567 566
568 } // namespace mus 567 } // namespace mus
OLDNEW
« no previous file with comments | « components/display_compositor/yuv_readback_unittest.cc ('k') | components/mus/public/cpp/lib/gles2_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698