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

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"
11 #include "cc/output/context_provider.h" 11 #include "cc/output/context_provider.h"
12 #include "cc/output/output_surface_client.h" 12 #include "cc/output/output_surface_client.h"
13 #include "cc/output/software_output_device.h" 13 #include "cc/output/software_output_device.h"
14 #include "content/browser/android/in_process/synchronous_compositor_impl.h" 14 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "gpu/command_buffer/client/gl_in_process_context.h"
17 #include "gpu/command_buffer/client/gles2_interface.h" 16 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 17 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
19 #include "third_party/skia/include/core/SkBitmapDevice.h" 18 #include "third_party/skia/include/core/SkBitmapDevice.h"
20 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
21 #include "ui/gfx/rect_conversions.h" 20 #include "ui/gfx/rect_conversions.h"
22 #include "ui/gfx/skia_util.h" 21 #include "ui/gfx/skia_util.h"
23 #include "ui/gfx/transform.h" 22 #include "ui/gfx/transform.h"
24 #include "ui/gl/gl_surface.h"
25 #include "webkit/common/gpu/context_provider_in_process.h"
26 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
27 23
28 namespace content { 24 namespace content {
29 25
30 namespace { 26 namespace {
31 27
32 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
33 CreateWebGraphicsContext3D(scoped_refptr<gfx::GLSurface> surface) {
34 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
35 const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
36
37 blink::WebGraphicsContext3D::Attributes attributes;
38 attributes.antialias = false;
39 attributes.shareResources = true;
40 attributes.noAutomaticFlushes = true;
41
42 gpu::GLInProcessContextAttribs in_process_attribs;
43 WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
44 attributes, &in_process_attribs);
45 scoped_ptr<gpu::GLInProcessContext> context(
46 gpu::GLInProcessContext::CreateWithSurface(surface,
47 attributes.shareResources,
48 in_process_attribs,
49 gpu_preference));
50
51 if (!context.get())
52 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>();
53
54 return WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
55 context.Pass(), attributes).Pass();
56 }
57
58 void DidActivatePendingTree(int routing_id) { 28 void DidActivatePendingTree(int routing_id) {
59 SynchronousCompositorOutputSurfaceDelegate* delegate = 29 SynchronousCompositorOutputSurfaceDelegate* delegate =
60 SynchronousCompositorImpl::FromRoutingID(routing_id); 30 SynchronousCompositorImpl::FromRoutingID(routing_id);
61 if (delegate) 31 if (delegate)
62 delegate->DidActivatePendingTree(); 32 delegate->DidActivatePendingTree();
63 } 33 }
64 34
65 } // namespace 35 } // namespace
66 36
67 class SynchronousCompositorOutputSurface::SoftwareDevice 37 class SynchronousCompositorOutputSurface::SoftwareDevice
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 153 }
184 154
185 namespace { 155 namespace {
186 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) { 156 void AdjustTransform(gfx::Transform* transform, gfx::Rect viewport) {
187 // CC's draw origin starts at the viewport. 157 // CC's draw origin starts at the viewport.
188 transform->matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 158 transform->matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
189 } 159 }
190 } // namespace 160 } // namespace
191 161
192 bool SynchronousCompositorOutputSurface::InitializeHwDraw( 162 bool SynchronousCompositorOutputSurface::InitializeHwDraw(
193 scoped_refptr<gfx::GLSurface> surface, 163 scoped_refptr<cc::ContextProvider> onscreen_context_provider,
194 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 164 scoped_refptr<cc::ContextProvider> offscreen_context_provider) {
195 DCHECK(CalledOnValidThread()); 165 DCHECK(CalledOnValidThread());
196 DCHECK(HasClient()); 166 DCHECK(HasClient());
197 DCHECK(!context_provider_); 167 DCHECK(!context_provider_);
198 DCHECK(surface);
199 168
200 scoped_refptr<cc::ContextProvider> onscreen_context_provider =
201 webkit::gpu::ContextProviderInProcess::Create(
202 CreateWebGraphicsContext3D(surface), "SynchronousCompositor");
203 return InitializeAndSetContext3d(onscreen_context_provider, 169 return InitializeAndSetContext3d(onscreen_context_provider,
204 offscreen_context_provider); 170 offscreen_context_provider);
205 } 171 }
206 172
207 void SynchronousCompositorOutputSurface::ReleaseHwDraw() { 173 void SynchronousCompositorOutputSurface::ReleaseHwDraw() {
208 DCHECK(CalledOnValidThread()); 174 DCHECK(CalledOnValidThread());
209 cc::OutputSurface::ReleaseGL(); 175 cc::OutputSurface::ReleaseGL();
210 } 176 }
211 177
212 bool SynchronousCompositorOutputSurface::DemandDrawHw( 178 bool SynchronousCompositorOutputSurface::DemandDrawHw(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 270 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
305 return BrowserThread::CurrentlyOn(BrowserThread::UI); 271 return BrowserThread::CurrentlyOn(BrowserThread::UI);
306 } 272 }
307 273
308 SynchronousCompositorOutputSurfaceDelegate* 274 SynchronousCompositorOutputSurfaceDelegate*
309 SynchronousCompositorOutputSurface::GetDelegate() { 275 SynchronousCompositorOutputSurface::GetDelegate() {
310 return SynchronousCompositorImpl::FromRoutingID(routing_id_); 276 return SynchronousCompositorImpl::FromRoutingID(routing_id_);
311 } 277 }
312 278
313 } // namespace content 279 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698