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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.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
« no previous file with comments | « no previous file | content/common/gpu/image_transport_surface_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gpu_command_buffer_stub.h" 5 #include "content/common/gpu/gpu_command_buffer_stub.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); 153 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue);
154 res->SetInteger("renderer_pid", channel->GetClientPID()); 154 res->SetInteger("renderer_pid", channel->GetClientPID());
155 res->SetDouble("used_bytes", channel->GetMemoryUsage()); 155 res->SetDouble("used_bytes", channel->GetMemoryUsage());
156 return new DevToolsChannelData(res.release()); 156 return new DevToolsChannelData(res.release());
157 } 157 }
158 158
159 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) { 159 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) {
160 return (static_cast<uint64_t>(channel_id) << 32) | route_id; 160 return (static_cast<uint64_t>(channel_id) << 32) | route_id;
161 } 161 }
162 162
163 gfx::GLSurface::Format GetSurfaceFormatFromAttribute(
164 const gpu::gles2::ContextCreationAttribHelper& attrib,
165 bool use_virtualized_gl_context) {
166 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888
167 if (!use_virtualized_gl_context &&
168 attrib.red_size <= 5 &&
169 attrib.green_size <= 6 &&
170 attrib.blue_size <= 5 &&
171 attrib.alpha_size == 0) {
172 format = gfx::GLSurface::SURFACE_RGB565;
173 }
174 return format;
175 }
176 } // namespace 163 } // namespace
177 164
178 GpuCommandBufferStub::GpuCommandBufferStub( 165 GpuCommandBufferStub::GpuCommandBufferStub(
179 GpuChannel* channel, 166 GpuChannel* channel,
180 gpu::SyncPointManager* sync_point_manager, 167 gpu::SyncPointManager* sync_point_manager,
181 base::SingleThreadTaskRunner* task_runner, 168 base::SingleThreadTaskRunner* task_runner,
182 GpuCommandBufferStub* share_group, 169 GpuCommandBufferStub* share_group,
183 const gfx::GLSurfaceHandle& handle, 170 const gfx::GLSurfaceHandle& handle,
184 gpu::gles2::MailboxManager* mailbox_manager, 171 gpu::gles2::MailboxManager* mailbox_manager,
185 gpu::PreemptionFlag* preempt_by_flag, 172 gpu::PreemptionFlag* preempt_by_flag,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 use_virtualized_gl_context_ = true; 230 use_virtualized_gl_context_ = true;
244 #endif 231 #endif
245 232
246 use_virtualized_gl_context_ |= 233 use_virtualized_gl_context_ |=
247 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts; 234 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts;
248 235
249 // MailboxManagerSync synchronization correctness currently depends on having 236 // MailboxManagerSync synchronization correctness currently depends on having
250 // only a single context. See crbug.com/510243 for details. 237 // only a single context. See crbug.com/510243 for details.
251 use_virtualized_gl_context_ |= mailbox_manager->UsesSync(); 238 use_virtualized_gl_context_ |= mailbox_manager->UsesSync();
252 239
253 surface_format_ = GetSurfaceFormatFromAttribute(attrib_parser, 240 #if defined(OS_ANDROID)
254 use_virtualized_gl_context_); 241 if (attrib_parser.red_size <= 5 &&
242 attrib_parser.green_size <= 6 &&
243 attrib_parser.blue_size <= 5 &&
244 attrib_parser.alpha_size == 0)
245 surface_format_ = gfx::GLSurface::SURFACE_RGB565;
246 gfx::GLSurface* defaultOffscreenSurface =
247 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface();
248 if (surface_format_ != defaultOffscreenSurface->GetFormat())
249 use_virtualized_gl_context_ = false;
250 #endif
255 251
256 if (offscreen && initial_size_.IsEmpty()) { 252 if (offscreen && initial_size_.IsEmpty()) {
257 // If we're an offscreen surface with zero width and/or height, set to a 253 // If we're an offscreen surface with zero width and/or height, set to a
258 // non-zero size so that we have a complete framebuffer for operations like 254 // non-zero size so that we have a complete framebuffer for operations like
259 // glClear. 255 // glClear.
260 initial_size_ = gfx::Size(1, 1); 256 initial_size_ = gfx::Size(1, 1);
261 } 257 }
262 } 258 }
263 259
264 GpuCommandBufferStub::~GpuCommandBufferStub() { 260 GpuCommandBufferStub::~GpuCommandBufferStub() {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 surface_ = manager->GetDefaultOffscreenSurface(); 550 surface_ = manager->GetDefaultOffscreenSurface();
555 } 551 }
556 552
557 if (!surface_.get()) { 553 if (!surface_.get()) {
558 DLOG(ERROR) << "Failed to create surface."; 554 DLOG(ERROR) << "Failed to create surface.";
559 OnInitializeFailed(reply_message); 555 OnInitializeFailed(reply_message);
560 return; 556 return;
561 } 557 }
562 558
563 scoped_refptr<gfx::GLContext> context; 559 scoped_refptr<gfx::GLContext> context;
564 if (use_virtualized_gl_context_ && channel_->share_group()) { 560 gfx::GLShareGroup* share_group = channel_->share_group();
565 context = channel_->share_group()->GetSharedContext(); 561 if (use_virtualized_gl_context_ && share_group) {
562 context = share_group->GetSharedContext();
566 if (!context.get()) { 563 if (!context.get()) {
567 context = gfx::GLContext::CreateGLContext( 564 context = gfx::GLContext::CreateGLContext(
568 channel_->share_group(), 565 channel_->share_group(),
569 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(), 566 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(),
570 gpu_preference_); 567 gpu_preference_);
571 if (!context.get()) { 568 if (!context.get()) {
572 DLOG(ERROR) << "Failed to create shared context for virtualization."; 569 DLOG(ERROR) << "Failed to create shared context for virtualization.";
573 OnInitializeFailed(reply_message); 570 OnInitializeFailed(reply_message);
574 return; 571 return;
575 } 572 }
576 channel_->share_group()->SetSharedContext(context.get()); 573 channel_->share_group()->SetSharedContext(context.get());
577 } 574 }
578 // This should be a non-virtual GL context. 575 // This should be a non-virtual GL context.
579 DCHECK(context->GetHandle()); 576 DCHECK(context->GetHandle());
580 context = new gpu::GLContextVirtual( 577 context = new gpu::GLContextVirtual(
581 channel_->share_group(), context.get(), decoder_->AsWeakPtr()); 578 share_group, context.get(), decoder_->AsWeakPtr());
582 if (!context->Initialize(surface_.get(), gpu_preference_)) { 579 if (!context->Initialize(surface_.get(), gpu_preference_)) {
583 // TODO(sievers): The real context created above for the default 580 // The real context created above for the default offscreen surface
584 // offscreen surface might not be compatible with this surface. 581 // might not be compatible with this surface.
585 // Need to adjust at least GLX to be able to create the initial context
586 // with a config that is compatible with onscreen and offscreen surfaces.
587 context = NULL; 582 context = NULL;
588 583
589 DLOG(ERROR) << "Failed to initialize virtual GL context."; 584 DLOG(ERROR) << "Failed to initialize virtual GL context.";
590 OnInitializeFailed(reply_message); 585 OnInitializeFailed(reply_message);
591 return; 586 return;
592 } 587 }
593 } 588 }
594 if (!context.get()) { 589 if (!context.get()) {
595 context = gfx::GLContext::CreateGLContext( 590 context = gfx::GLContext::CreateGLContext(
596 channel_->share_group(), surface_.get(), gpu_preference_); 591 share_group, surface_.get(), gpu_preference_);
597 } 592 }
598 if (!context.get()) { 593 if (!context.get()) {
599 DLOG(ERROR) << "Failed to create context."; 594 DLOG(ERROR) << "Failed to create context.";
600 OnInitializeFailed(reply_message); 595 OnInitializeFailed(reply_message);
601 return; 596 return;
602 } 597 }
603 598
604 if (!context->MakeCurrent(surface_.get())) { 599 if (!context->MakeCurrent(surface_.get())) {
605 LOG(ERROR) << "Failed to make context current."; 600 LOG(ERROR) << "Failed to make context current.";
606 OnInitializeFailed(reply_message); 601 OnInitializeFailed(reply_message);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 result)); 1173 result));
1179 } 1174 }
1180 1175
1181 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1176 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1182 base::TimeDelta interval) { 1177 base::TimeDelta interval) {
1183 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1178 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1184 interval)); 1179 interval));
1185 } 1180 }
1186 1181
1187 } // namespace content 1182 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/image_transport_surface_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698