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

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 455783002: GPU context creation code duplication cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 4 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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #ifndef GL_GLEXT_PROTOTYPES 8 #ifndef GL_GLEXT_PROTOTYPES
9 #define GL_GLEXT_PROTOTYPES 1 9 #define GL_GLEXT_PROTOTYPES 1
10 #endif 10 #endif
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) { 178 bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) {
179 if (!host_.get()) 179 if (!host_.get())
180 return false; 180 return false;
181 181
182 CommandBufferProxyImpl* share_group_command_buffer = NULL; 182 CommandBufferProxyImpl* share_group_command_buffer = NULL;
183 183
184 if (share_context) { 184 if (share_context) {
185 share_group_command_buffer = share_context->command_buffer_.get(); 185 share_group_command_buffer = share_context->command_buffer_.get();
186 } 186 }
187 187
188 ::gpu::gles2::ContextCreationAttribHelper attribs_for_gles2;
189 ConvertAttributes(attributes_, &attribs_for_gles2);
190 attribs_for_gles2.lose_context_when_out_of_memory_ =
191 lose_context_when_out_of_memory_;
192 attribs_for_gles2.bind_generates_resource_ = false;
193 DCHECK(attribs_for_gles2.buffer_preserved_);
188 std::vector<int32> attribs; 194 std::vector<int32> attribs;
189 attribs.push_back(ALPHA_SIZE); 195 attribs_for_gles2.Serialize(&attribs);
190 attribs.push_back(attributes_.alpha ? 8 : 0);
191 attribs.push_back(DEPTH_SIZE);
192 attribs.push_back(attributes_.depth ? 24 : 0);
193 attribs.push_back(STENCIL_SIZE);
194 attribs.push_back(attributes_.stencil ? 8 : 0);
195 attribs.push_back(SAMPLES);
196 attribs.push_back(attributes_.antialias ? 4 : 0);
197 attribs.push_back(SAMPLE_BUFFERS);
198 attribs.push_back(attributes_.antialias ? 1 : 0);
199 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT);
200 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0);
201 attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY);
202 attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0);
203 attribs.push_back(BIND_GENERATES_RESOURCES);
204 attribs.push_back(0);
205 attribs.push_back(NONE);
206 196
207 // Create a proxy to a command buffer in the GPU process. 197 // Create a proxy to a command buffer in the GPU process.
208 if (onscreen) { 198 if (onscreen) {
209 command_buffer_.reset(host_->CreateViewCommandBuffer( 199 command_buffer_.reset(host_->CreateViewCommandBuffer(
210 surface_id_, 200 surface_id_,
211 share_group_command_buffer, 201 share_group_command_buffer,
212 attribs, 202 attribs,
213 active_url_, 203 active_url_,
214 gpu_preference_)); 204 gpu_preference_));
215 } else { 205 } else {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 share_group_->RemoveAllContexts(); 423 share_group_->RemoveAllContexts();
434 424
435 DCHECK(host_.get()); 425 DCHECK(host_.get());
436 { 426 {
437 base::AutoLock lock(g_default_share_groups_lock.Get()); 427 base::AutoLock lock(g_default_share_groups_lock.Get());
438 g_default_share_groups.Get().erase(host_.get()); 428 g_default_share_groups.Get().erase(host_.get());
439 } 429 }
440 } 430 }
441 431
442 } // namespace content 432 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698