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

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

Issue 213743003: Pass GL context bind_generates_resources flag to GPU Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 8 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() { 223 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() {
224 DCHECK(contexts_.empty()); 224 DCHECK(contexts_.empty());
225 } 225 }
226 226
227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( 227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
228 int surface_id, 228 int surface_id,
229 const GURL& active_url, 229 const GURL& active_url,
230 GpuChannelHost* host, 230 GpuChannelHost* host,
231 const Attributes& attributes, 231 const Attributes& attributes,
232 bool bind_generates_resources,
233 bool lose_context_when_out_of_memory, 232 bool lose_context_when_out_of_memory,
234 const SharedMemoryLimits& limits, 233 const SharedMemoryLimits& limits,
235 WebGraphicsContext3DCommandBufferImpl* share_context) 234 WebGraphicsContext3DCommandBufferImpl* share_context)
236 : initialize_failed_(false), 235 : initialize_failed_(false),
237 visible_(false), 236 visible_(false),
238 host_(host), 237 host_(host),
239 surface_id_(surface_id), 238 surface_id_(surface_id),
240 active_url_(active_url), 239 active_url_(active_url),
241 context_lost_callback_(0), 240 context_lost_callback_(0),
242 context_lost_reason_(GL_NO_ERROR), 241 context_lost_reason_(GL_NO_ERROR),
243 error_message_callback_(0), 242 error_message_callback_(0),
244 attributes_(attributes), 243 attributes_(attributes),
245 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu 244 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu
246 : gfx::PreferIntegratedGpu), 245 : gfx::PreferIntegratedGpu),
247 weak_ptr_factory_(this), 246 weak_ptr_factory_(this),
248 initialized_(false), 247 initialized_(false),
249 gl_(NULL), 248 gl_(NULL),
250 bind_generates_resources_(bind_generates_resources),
251 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), 249 lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
252 mem_limits_(limits), 250 mem_limits_(limits),
253 flush_id_(0) { 251 flush_id_(0) {
254 if (share_context) { 252 if (share_context) {
255 DCHECK(!attributes_.shareResources); 253 DCHECK(!attributes_.shareResources);
256 share_group_ = share_context->share_group_; 254 share_group_ = share_context->share_group_;
257 } else { 255 } else {
258 share_group_ = attributes_.shareResources 256 share_group_ = attributes_.shareResources
259 ? GetDefaultShareGroupForHost(host) 257 ? GetDefaultShareGroupForHost(host)
260 : scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>( 258 : scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup>(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 attribs.push_back(STENCIL_SIZE); 345 attribs.push_back(STENCIL_SIZE);
348 attribs.push_back(attributes_.stencil ? 8 : 0); 346 attribs.push_back(attributes_.stencil ? 8 : 0);
349 attribs.push_back(SAMPLES); 347 attribs.push_back(SAMPLES);
350 attribs.push_back(attributes_.antialias ? 4 : 0); 348 attribs.push_back(attributes_.antialias ? 4 : 0);
351 attribs.push_back(SAMPLE_BUFFERS); 349 attribs.push_back(SAMPLE_BUFFERS);
352 attribs.push_back(attributes_.antialias ? 1 : 0); 350 attribs.push_back(attributes_.antialias ? 1 : 0);
353 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); 351 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT);
354 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); 352 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0);
355 attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY); 353 attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY);
356 attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0); 354 attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0);
355 attribs.push_back(BIND_GENERATES_RESOURCES);
356 attribs.push_back(0);
357 attribs.push_back(NONE); 357 attribs.push_back(NONE);
358 358
359 // Create a proxy to a command buffer in the GPU process. 359 // Create a proxy to a command buffer in the GPU process.
360 if (onscreen) { 360 if (onscreen) {
361 command_buffer_.reset(host_->CreateViewCommandBuffer( 361 command_buffer_.reset(host_->CreateViewCommandBuffer(
362 surface_id_, 362 surface_id_,
363 share_group_command_buffer, 363 share_group_command_buffer,
364 attribs, 364 attribs,
365 active_url_, 365 active_url_,
366 gpu_preference_)); 366 gpu_preference_));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 if (attributes_.noAutomaticFlushes) 422 if (attributes_.noAutomaticFlushes)
423 gles2_helper_->SetAutomaticFlushes(false); 423 gles2_helper_->SetAutomaticFlushes(false);
424 // Create a transfer buffer used to copy resources between the renderer 424 // Create a transfer buffer used to copy resources between the renderer
425 // process and the GPU process. 425 // process and the GPU process.
426 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); 426 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get()));
427 427
428 DCHECK(host_.get()); 428 DCHECK(host_.get());
429 429
430 // Create the object exposing the OpenGL API. 430 // Create the object exposing the OpenGL API.
431 bool bind_generates_resources = false;
431 real_gl_.reset( 432 real_gl_.reset(
432 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), 433 new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
433 gles2_share_group, 434 gles2_share_group,
434 transfer_buffer_.get(), 435 transfer_buffer_.get(),
435 bind_generates_resources_, 436 bind_generates_resources,
436 lose_context_when_out_of_memory_, 437 lose_context_when_out_of_memory_,
437 command_buffer_.get())); 438 command_buffer_.get()));
438 gl_ = real_gl_.get(); 439 gl_ = real_gl_.get();
439 440
440 if (!real_gl_->Initialize( 441 if (!real_gl_->Initialize(
441 mem_limits_.start_transfer_buffer_size, 442 mem_limits_.start_transfer_buffer_size,
442 mem_limits_.min_transfer_buffer_size, 443 mem_limits_.min_transfer_buffer_size,
443 mem_limits_.max_transfer_buffer_size, 444 mem_limits_.max_transfer_buffer_size,
444 mem_limits_.mapped_memory_reclaim_limit)) { 445 mem_limits_.mapped_memory_reclaim_limit)) {
445 LOG(ERROR) << "Failed to initialize GLES2Implementation."; 446 LOG(ERROR) << "Failed to initialize GLES2Implementation.";
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 bool lose_context_when_out_of_memory, 1200 bool lose_context_when_out_of_memory,
1200 const GURL& active_url, 1201 const GURL& active_url,
1201 const SharedMemoryLimits& limits, 1202 const SharedMemoryLimits& limits,
1202 WebGraphicsContext3DCommandBufferImpl* share_context) { 1203 WebGraphicsContext3DCommandBufferImpl* share_context) {
1203 if (!host) 1204 if (!host)
1204 return NULL; 1205 return NULL;
1205 1206
1206 if (share_context && share_context->IsCommandBufferContextLost()) 1207 if (share_context && share_context->IsCommandBufferContextLost())
1207 return NULL; 1208 return NULL;
1208 1209
1209 bool bind_generates_resources = false;
1210 return new WebGraphicsContext3DCommandBufferImpl( 1210 return new WebGraphicsContext3DCommandBufferImpl(
1211 0, 1211 0,
1212 active_url, 1212 active_url,
1213 host, 1213 host,
1214 attributes, 1214 attributes,
1215 bind_generates_resources,
1216 lose_context_when_out_of_memory, 1215 lose_context_when_out_of_memory,
1217 limits, 1216 limits,
1218 share_context); 1217 share_context);
1219 } 1218 }
1220 1219
1221 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, 1220 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
1222 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) 1221 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint)
1223 1222
1224 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, 1223 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT,
1225 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) 1224 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint)
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 1399
1401 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( 1400 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage(
1402 const std::string& message, int id) { 1401 const std::string& message, int id) {
1403 if (error_message_callback_) { 1402 if (error_message_callback_) {
1404 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); 1403 blink::WebString str = blink::WebString::fromUTF8(message.c_str());
1405 error_message_callback_->onErrorMessage(str, id); 1404 error_message_callback_->onErrorMessage(str, id);
1406 } 1405 }
1407 } 1406 }
1408 1407
1409 } // namespace content 1408 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698