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

Side by Side Diff: content/renderer/android/synchronous_compositor_output_surface.cc

Issue 14888002: Android WebView Merged-Thread Hardware Draw (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 7 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/renderer/android/synchronous_compositor_output_surface.h" 5 #include "content/renderer/android/synchronous_compositor_output_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time.h"
8 #include "cc/output/output_surface_client.h" 9 #include "cc/output/output_surface_client.h"
9 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
10 #include "content/public/renderer/android/synchronous_compositor_client.h" 10 #include "content/public/renderer/android/synchronous_compositor_client.h"
11 #include "content/public/renderer/content_renderer_client.h" 11 #include "content/public/renderer/content_renderer_client.h"
12 #include "skia/ext/refptr.h" 12 #include "skia/ext/refptr.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkPicture.h" 14 #include "third_party/skia/include/core/SkPicture.h"
15 #include "ui/gfx/transform.h"
16 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
17
18 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
15 19
16 namespace content { 20 namespace content {
21 namespace {
22
23 // TODO(boliu): RenderThreadImpl should create in process contexts as well.
24 scoped_ptr<WebKit::WebGraphicsContext3D> CreateWebGraphicsContext3D() {
25 WebKit::WebGraphicsContext3D::Attributes attributes;
26 attributes.antialias = false;
27 attributes.shareResources = true;
28 attributes.noAutomaticFlushes = true;
29
30 return scoped_ptr<WebKit::WebGraphicsContext3D>(
31 WebGraphicsContext3DInProcessCommandBufferImpl
32 ::CreateViewContext(attributes, NULL));
33 }
34 } // namespace
17 35
18 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( 36 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
19 int32 routing_id, 37 int32 routing_id)
20 WebGraphicsContext3DCommandBufferImpl* context) 38 : cc::OutputSurface(CreateWebGraphicsContext3D()),
21 : cc::OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context)),
22 compositor_client_(NULL), 39 compositor_client_(NULL),
23 routing_id_(routing_id) { 40 routing_id_(routing_id),
24 // WARNING: may be called on any thread. 41 vsync_enabled_(false),
42 did_swap_buffer_(false) {
25 } 43 }
26 44
27 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { 45 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
28 DCHECK(CalledOnValidThread()); 46 DCHECK(CalledOnValidThread());
29 if (compositor_client_) 47 if (compositor_client_)
30 compositor_client_->DidDestroyCompositor(this); 48 compositor_client_->DidDestroyCompositor(this);
31 } 49 }
32 50
33 bool SynchronousCompositorOutputSurface::BindToClient( 51 bool SynchronousCompositorOutputSurface::BindToClient(
34 cc::OutputSurfaceClient* surface_client) { 52 cc::OutputSurfaceClient* surface_client) {
35 DCHECK(CalledOnValidThread()); 53 DCHECK(CalledOnValidThread());
36 if (!cc::OutputSurface::BindToClient(surface_client)) 54 if (!cc::OutputSurface::BindToClient(surface_client))
37 return false; 55 return false;
38 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, 56 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_,
39 this); 57 this);
40 return true; 58 return true;
41 } 59 }
42 60
61 void SynchronousCompositorOutputSurface::Reshape(gfx::Size size) {
62 // Intentional no-op.
63 }
64
43 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( 65 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor(
44 cc::CompositorFrame* frame) { 66 cc::CompositorFrame* frame) {
45 // Intentional no-op: see http://crbug.com/237006 67 // Intentional no-op: see http://crbug.com/237006
46 } 68 }
47 69
70 void SynchronousCompositorOutputSurface::EnableVSyncNotification(
71 bool enable_vsync) {
72 DCHECK(CalledOnValidThread());
73 vsync_enabled_ = enable_vsync;
74 UpdateCompositorClientSettings();
75 }
76
77 void SynchronousCompositorOutputSurface::SwapBuffers(
78 const cc::LatencyInfo& info) {
79 context3d()->finish();
no sievers 2013/05/15 23:02:22 Bo, you might want to try if it works replacing th
80 did_swap_buffer_ = true;
81 }
82
48 void SynchronousCompositorOutputSurface::SetClient( 83 void SynchronousCompositorOutputSurface::SetClient(
49 SynchronousCompositorClient* compositor_client) { 84 SynchronousCompositorClient* compositor_client) {
50 DCHECK(CalledOnValidThread()); 85 DCHECK(CalledOnValidThread());
51 compositor_client_ = compositor_client; 86 compositor_client_ = compositor_client;
87 UpdateCompositorClientSettings();
52 } 88 }
53 89
54 bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { 90 bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
55 DCHECK(CalledOnValidThread()); 91 DCHECK(CalledOnValidThread());
56 NOTIMPLEMENTED(); // TODO(joth): call through to OutputSurfaceClient 92 NOTIMPLEMENTED(); // TODO(joth): call through to OutputSurfaceClient
57 return false; 93 return false;
58 } 94 }
59 95
96 bool SynchronousCompositorOutputSurface::DemandDrawHw(
97 gfx::Size view_size,
98 const gfx::Transform& transform,
99 gfx::Rect damage_area) {
100 DCHECK(CalledOnValidThread());
101 DCHECK(client_);
102
103 did_swap_buffer_ = false;
104
105 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the
106 // whole view. Tracking bug to implement this: crbug.com/230463.
107 client_->SetNeedsRedrawRect(damage_area);
108 if (vsync_enabled_)
109 client_->DidVSync(base::TimeTicks::Now());
110
111 return did_swap_buffer_;
112 }
113
114 void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() {
115 if (compositor_client_) {
116 compositor_client_->SetContinuousInvalidate(vsync_enabled_);
117 }
118 }
119
60 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 120 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
61 // requirement: SynchronousCompositorOutputSurface() must only be used by 121 // requirement: SynchronousCompositorOutputSurface() must only be used by
62 // embedders that supply their own compositor loop via 122 // embedders that supply their own compositor loop via
63 // OverrideCompositorMessageLoop(). 123 // OverrideCompositorMessageLoop().
64 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 124 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
65 return base::MessageLoop::current() && (base::MessageLoop::current() == 125 return base::MessageLoop::current() && (base::MessageLoop::current() ==
66 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); 126 GetContentClient()->renderer()->OverrideCompositorMessageLoop());
67 } 127 }
68 128
69 } // namespace content 129 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698