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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_output_surface.cc

Issue 143023005: Support multiple service instances with GLInProcessContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/output/begin_frame_args.h" 9 #include "cc/output/begin_frame_args.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 12 matching lines...) Expand all
23 #include "ui/gfx/transform.h" 23 #include "ui/gfx/transform.h"
24 #include "ui/gl/gl_surface.h" 24 #include "ui/gl/gl_surface.h"
25 #include "webkit/common/gpu/context_provider_in_process.h" 25 #include "webkit/common/gpu/context_provider_in_process.h"
26 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 26 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
27 27
28 namespace content { 28 namespace content {
29 29
30 namespace { 30 namespace {
31 31
32 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> 32 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
33 CreateWebGraphicsContext3D(scoped_refptr<gfx::GLSurface> surface) { 33 CreateWebGraphicsContext3D(
34 scoped_refptr<gfx::GLSurface> surface,
35 scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
36 GLInProcessContext* share_context) {
34 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 37 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
35 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 38 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
36 39
37 blink::WebGraphicsContext3D::Attributes attributes; 40 blink::WebGraphicsContext3D::Attributes attributes;
38 attributes.antialias = false; 41 attributes.antialias = false;
39 attributes.shareResources = true; 42 attributes.shareResources = true;
40 attributes.noAutomaticFlushes = true; 43 attributes.noAutomaticFlushes = true;
41 44
42 gpu::GLInProcessContextAttribs in_process_attribs; 45 gpu::GLInProcessContextAttribs in_process_attribs;
43 WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( 46 WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
44 attributes, &in_process_attribs); 47 attributes, &in_process_attribs);
45 scoped_ptr<gpu::GLInProcessContext> context( 48 scoped_ptr<gpu::GLInProcessContext> context(
46 gpu::GLInProcessContext::CreateWithSurface(surface, 49 gpu::GLInProcessContext::CreateWithSurface(surface,
50 service,
51 share_context,
47 attributes.shareResources, 52 attributes.shareResources,
48 in_process_attribs, 53 in_process_attribs,
49 gpu_preference)); 54 gpu_preference));
50 55
51 if (!context.get()) 56 if (!context.get())
52 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); 57 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>();
53 58
54 return WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( 59 return WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
55 context.Pass(), attributes).Pass(); 60 context.Pass(), attributes).Pass();
56 } 61 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 189
185 namespace { 190 namespace {
186 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) { 191 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) {
187 // CC's draw origin starts at the viewport. 192 // CC's draw origin starts at the viewport.
188 transform->matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 193 transform->matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
189 } 194 }
190 } // namespace 195 } // namespace
191 196
192 bool SynchronousCompositorOutputSurface::InitializeHwDraw( 197 bool SynchronousCompositorOutputSurface::InitializeHwDraw(
193 scoped_refptr<gfx::GLSurface> surface, 198 scoped_refptr<gfx::GLSurface> surface,
194 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 199 scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
200 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
201 gpu::GLInProcessContext* share_context) {
195 DCHECK(CalledOnValidThread()); 202 DCHECK(CalledOnValidThread());
196 DCHECK(HasClient()); 203 DCHECK(HasClient());
197 DCHECK(!context_provider_); 204 DCHECK(!context_provider_);
198 DCHECK(surface); 205 DCHECK(surface);
199 206
200 scoped_refptr<cc::ContextProvider> onscreen_context_provider = 207 scoped_refptr<cc::ContextProvider> onscreen_context_provider =
201 webkit::gpu::ContextProviderInProcess::Create( 208 webkit::gpu::ContextProviderInProcess::Create(
202 CreateWebGraphicsContext3D(surface), "SynchronousCompositor"); 209 CreateWebGraphicsContext3D(
210 surface, service, share_context),
211 "SynchronousCompositor");
203 return InitializeAndSetContext3d(onscreen_context_provider, 212 return InitializeAndSetContext3d(onscreen_context_provider,
204 offscreen_context_provider); 213 offscreen_context_provider);
205 } 214 }
206 215
207 void SynchronousCompositorOutputSurface::ReleaseHwDraw() { 216 void SynchronousCompositorOutputSurface::ReleaseHwDraw() {
208 DCHECK(CalledOnValidThread()); 217 DCHECK(CalledOnValidThread());
209 cc::OutputSurface::ReleaseGL(); 218 cc::OutputSurface::ReleaseGL();
210 } 219 }
211 220
212 bool SynchronousCompositorOutputSurface::DemandDrawHw( 221 bool SynchronousCompositorOutputSurface::DemandDrawHw(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 313 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
305 return BrowserThread::CurrentlyOn(BrowserThread::UI); 314 return BrowserThread::CurrentlyOn(BrowserThread::UI);
306 } 315 }
307 316
308 SynchronousCompositorOutputSurfaceDelegate* 317 SynchronousCompositorOutputSurfaceDelegate*
309 SynchronousCompositorOutputSurface::GetDelegate() { 318 SynchronousCompositorOutputSurface::GetDelegate() {
310 return SynchronousCompositorImpl::FromRoutingID(routing_id_); 319 return SynchronousCompositorImpl::FromRoutingID(routing_id_);
311 } 320 }
312 321
313 } // namespace content 322 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698