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

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: comment 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/stream_texture_android.cc » ('j') | ui/gl/gl_surface.h » ('J')
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/hash.h" 12 #include "base/hash.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
16 #include "base/sys_info.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "content/common/gpu/gpu_channel.h" 20 #include "content/common/gpu/gpu_channel.h"
20 #include "content/common/gpu/gpu_channel_manager.h" 21 #include "content/common/gpu/gpu_channel_manager.h"
21 #include "content/common/gpu/gpu_memory_manager.h" 22 #include "content/common/gpu/gpu_memory_manager.h"
22 #include "content/common/gpu/gpu_memory_tracking.h" 23 #include "content/common/gpu/gpu_memory_tracking.h"
23 #include "content/common/gpu/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
24 #include "content/common/gpu/gpu_watchdog.h" 25 #include "content/common/gpu/gpu_watchdog.h"
25 #include "content/common/gpu/image_transport_surface.h" 26 #include "content/common/gpu/image_transport_surface.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 res->SetDouble("used_bytes", channel->GetMemoryUsage()); 156 res->SetDouble("used_bytes", channel->GetMemoryUsage());
156 return new DevToolsChannelData(res.release()); 157 return new DevToolsChannelData(res.release());
157 } 158 }
158 159
159 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) { 160 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) {
160 return (static_cast<uint64_t>(channel_id) << 32) | route_id; 161 return (static_cast<uint64_t>(channel_id) << 32) | route_id;
161 } 162 }
162 163
163 gfx::GLSurface::Format GetSurfaceFormatFromAttribute( 164 gfx::GLSurface::Format GetSurfaceFormatFromAttribute(
164 const gpu::gles2::ContextCreationAttribHelper& attrib, 165 const gpu::gles2::ContextCreationAttribHelper& attrib,
165 bool use_virtualized_gl_context) { 166 bool use_virtualized_gl_context) {
no sievers 2016/02/17 23:38:01 nit: this argument is unused now
Jinsuk Kim 2016/02/18 02:57:24 Done.
166 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888 167 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888
167 if (!use_virtualized_gl_context && 168 if (attrib.red_size <= 5 &&
168 attrib.red_size <= 5 &&
169 attrib.green_size <= 6 && 169 attrib.green_size <= 6 &&
170 attrib.blue_size <= 5 && 170 attrib.blue_size <= 5 &&
171 attrib.alpha_size == 0) { 171 attrib.alpha_size == 0) {
172 format = gfx::GLSurface::SURFACE_RGB565; 172 format = gfx::GLSurface::SURFACE_RGB565;
173 } 173 }
174 return format; 174 return format;
175 } 175 }
176 } // namespace 176 } // namespace
177 177
178 GpuCommandBufferStub::GpuCommandBufferStub( 178 GpuCommandBufferStub::GpuCommandBufferStub(
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 surface_ = manager->GetDefaultOffscreenSurface(); 554 surface_ = manager->GetDefaultOffscreenSurface();
555 } 555 }
556 556
557 if (!surface_.get()) { 557 if (!surface_.get()) {
558 DLOG(ERROR) << "Failed to create surface."; 558 DLOG(ERROR) << "Failed to create surface.";
559 OnInitializeFailed(reply_message); 559 OnInitializeFailed(reply_message);
560 return; 560 return;
561 } 561 }
562 562
563 scoped_refptr<gfx::GLContext> context; 563 scoped_refptr<gfx::GLContext> context;
564 if (use_virtualized_gl_context_ && channel_->share_group()) { 564 gfx::GLShareGroup* share_group = channel_->share_group();
565 context = channel_->share_group()->GetSharedContext(); 565
566 // On-screen 16-bit surfaces on low-end device won't use virtualized context.
no sievers 2016/02/17 23:38:01 You mean 32-bit surfaces, right?
Jinsuk Kim 2016/02/18 02:57:24 My bad.. removed the comment as this part is being
567 if (handle_.is_null() ||
568 !base::SysInfo::IsLowEndDevice() ||
no sievers 2016/02/17 23:38:01 You could actually generalize this and just say th
Jinsuk Kim 2016/02/18 02:57:24 Done.
569 surface_format_ == gfx::GLSurface::SURFACE_RGB565) {
570 context = share_group->GetSharedContext();
566 if (!context.get()) { 571 if (!context.get()) {
567 context = gfx::GLContext::CreateGLContext( 572 context = gfx::GLContext::CreateGLContext(
568 channel_->share_group(), 573 channel_->share_group(),
569 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(), 574 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(),
570 gpu_preference_); 575 gpu_preference_);
571 if (!context.get()) { 576 if (!context.get()) {
572 DLOG(ERROR) << "Failed to create shared context for virtualization."; 577 DLOG(ERROR) << "Failed to create shared context for virtualization.";
573 OnInitializeFailed(reply_message); 578 OnInitializeFailed(reply_message);
574 return; 579 return;
575 } 580 }
576 channel_->share_group()->SetSharedContext(context.get()); 581 channel_->share_group()->SetSharedContext(context.get());
577 } 582 }
578 // This should be a non-virtual GL context. 583 // This should be a non-virtual GL context.
579 DCHECK(context->GetHandle()); 584 DCHECK(context->GetHandle());
580 context = new gpu::GLContextVirtual( 585 context = new gpu::GLContextVirtual(
581 channel_->share_group(), context.get(), decoder_->AsWeakPtr()); 586 share_group, context.get(), decoder_->AsWeakPtr());
582 if (!context->Initialize(surface_.get(), gpu_preference_)) { 587 if (!context->Initialize(surface_.get(), gpu_preference_)) {
583 // TODO(sievers): The real context created above for the default 588 // TODO(sievers): The real context created above for the default
584 // offscreen surface might not be compatible with this surface. 589 // offscreen surface might not be compatible with this surface.
585 // Need to adjust at least GLX to be able to create the initial context 590 // 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. 591 // with a config that is compatible with onscreen and offscreen surfaces.
587 context = NULL; 592 context = NULL;
588 593
589 DLOG(ERROR) << "Failed to initialize virtual GL context."; 594 DLOG(ERROR) << "Failed to initialize virtual GL context.";
590 OnInitializeFailed(reply_message); 595 OnInitializeFailed(reply_message);
591 return; 596 return;
592 } 597 }
593 } 598 }
594 if (!context.get()) { 599 if (!context.get()) {
595 context = gfx::GLContext::CreateGLContext( 600 context = gfx::GLContext::CreateGLContext(
596 channel_->share_group(), surface_.get(), gpu_preference_); 601 share_group, surface_.get(), gpu_preference_);
597 } 602 }
598 if (!context.get()) { 603 if (!context.get()) {
599 DLOG(ERROR) << "Failed to create context."; 604 DLOG(ERROR) << "Failed to create context.";
600 OnInitializeFailed(reply_message); 605 OnInitializeFailed(reply_message);
601 return; 606 return;
602 } 607 }
603 608
604 if (!context->MakeCurrent(surface_.get())) { 609 if (!context->MakeCurrent(surface_.get())) {
605 LOG(ERROR) << "Failed to make context current."; 610 LOG(ERROR) << "Failed to make context current.";
606 OnInitializeFailed(reply_message); 611 OnInitializeFailed(reply_message);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 result)); 1183 result));
1179 } 1184 }
1180 1185
1181 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1186 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1182 base::TimeDelta interval) { 1187 base::TimeDelta interval) {
1183 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1188 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1184 interval)); 1189 interval));
1185 } 1190 }
1186 1191
1187 } // namespace content 1192 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/stream_texture_android.cc » ('j') | ui/gl/gl_surface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698