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

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

Issue 15002007: Delegate root layer scroll offset to android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 private: 81 private:
82 SynchronousCompositorOutputSurface* surface_; 82 SynchronousCompositorOutputSurface* surface_;
83 SkDevice null_device_; 83 SkDevice null_device_;
84 SkCanvas null_canvas_; 84 SkCanvas null_canvas_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); 86 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice);
87 }; 87 };
88 88
89 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( 89 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
90 int32 routing_id) 90 Delegate* delegate)
91 : cc::OutputSurface(CreateWebGraphicsContext3D(), 91 : cc::OutputSurface(
92 scoped_ptr<cc::SoftwareOutputDevice>( 92 CreateWebGraphicsContext3D(),
93 new SoftwareDevice(this))), 93 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
94 compositor_client_(NULL), 94 delegate_(delegate),
95 routing_id_(routing_id),
96 vsync_enabled_(false), 95 vsync_enabled_(false),
97 did_swap_buffer_(false), 96 did_swap_buffer_(false),
98 current_sw_canvas_(NULL) { 97 current_sw_canvas_(NULL) {
99 capabilities_.deferred_gl_initialization = true; 98 capabilities_.deferred_gl_initialization = true;
100 } 99 }
101 100
102 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { 101 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
103 DCHECK(CalledOnValidThread()); 102 DCHECK(CalledOnValidThread());
104 if (compositor_client_) 103 delegate_->DidDestroyCompositor();
105 compositor_client_->DidDestroyCompositor(this);
106 } 104 }
107 105
108 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const { 106 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
109 return current_sw_canvas_ != NULL; 107 return current_sw_canvas_ != NULL;
110 } 108 }
111 109
112 bool SynchronousCompositorOutputSurface::BindToClient( 110 bool SynchronousCompositorOutputSurface::BindToClient(
113 cc::OutputSurfaceClient* surface_client) { 111 cc::OutputSurfaceClient* surface_client) {
114 DCHECK(CalledOnValidThread()); 112 DCHECK(CalledOnValidThread());
115 if (!cc::OutputSurface::BindToClient(surface_client)) 113 if (!cc::OutputSurface::BindToClient(surface_client))
116 return false; 114 return false;
117 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, 115 delegate_->DidCreateSynchronousCompositor();
118 this);
119 return true; 116 return true;
120 } 117 }
121 118
122 void SynchronousCompositorOutputSurface::Reshape(gfx::Size size) { 119 void SynchronousCompositorOutputSurface::Reshape(gfx::Size size) {
123 // Intentional no-op: surface size is controlled by the embedder. 120 // Intentional no-op: surface size is controlled by the embedder.
124 } 121 }
125 122
126 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( 123 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor(
127 cc::CompositorFrame* frame) { 124 cc::CompositorFrame* frame) {
128 NOTREACHED(); 125 NOTREACHED();
129 // TODO(joth): Route page scale to the client, see http://crbug.com/237006 126 // TODO(joth): Route page scale to the client, see http://crbug.com/237006
130 } 127 }
131 128
132 void SynchronousCompositorOutputSurface::EnableVSyncNotification( 129 void SynchronousCompositorOutputSurface::EnableVSyncNotification(
133 bool enable_vsync) { 130 bool enable_vsync) {
134 DCHECK(CalledOnValidThread()); 131 DCHECK(CalledOnValidThread());
135 vsync_enabled_ = enable_vsync; 132 vsync_enabled_ = enable_vsync;
136 UpdateCompositorClientSettings(); 133 delegate_->SetContinuousInvalidate(enable_vsync);
137 } 134 }
138 135
139 void SynchronousCompositorOutputSurface::SwapBuffers( 136 void SynchronousCompositorOutputSurface::SwapBuffers(
140 const cc::LatencyInfo& info) { 137 const cc::LatencyInfo& info) {
141 context3d()->shallowFlushCHROMIUM(); 138 context3d()->shallowFlushCHROMIUM();
142 did_swap_buffer_ = true; 139 did_swap_buffer_ = true;
143 } 140 }
144 141
145 void SynchronousCompositorOutputSurface::SetClient(
146 SynchronousCompositorClient* compositor_client) {
147 DCHECK(CalledOnValidThread());
148 compositor_client_ = compositor_client;
149 UpdateCompositorClientSettings();
150 }
151
152 bool SynchronousCompositorOutputSurface::IsHwReady() { 142 bool SynchronousCompositorOutputSurface::IsHwReady() {
153 return context3d() != NULL; 143 return context3d() != NULL;
154 } 144 }
155 145
156 bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { 146 bool SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
157 DCHECK(CalledOnValidThread()); 147 DCHECK(CalledOnValidThread());
158 DCHECK(canvas); 148 DCHECK(canvas);
159 DCHECK(!current_sw_canvas_); 149 DCHECK(!current_sw_canvas_);
160 current_sw_canvas_ = canvas; 150 current_sw_canvas_ = canvas;
161 151
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void SynchronousCompositorOutputSurface::InvokeComposite( 184 void SynchronousCompositorOutputSurface::InvokeComposite(
195 const gfx::Transform& transform, 185 const gfx::Transform& transform,
196 gfx::Rect damage_area) { 186 gfx::Rect damage_area) {
197 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the 187 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the
198 // whole view. Tracking bug to implement this: crbug.com/230463. 188 // whole view. Tracking bug to implement this: crbug.com/230463.
199 client_->SetNeedsRedrawRect(damage_area); 189 client_->SetNeedsRedrawRect(damage_area);
200 if (vsync_enabled_) 190 if (vsync_enabled_)
201 client_->DidVSync(base::TimeTicks::Now()); 191 client_->DidVSync(base::TimeTicks::Now());
202 } 192 }
203 193
204 void SynchronousCompositorOutputSurface::UpdateCompositorClientSettings() {
205 if (compositor_client_) {
206 compositor_client_->SetContinuousInvalidate(vsync_enabled_);
207 }
208 }
209
210 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 194 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
211 // requirement: SynchronousCompositorOutputSurface() must only be used by 195 // requirement: SynchronousCompositorOutputSurface() must only be used by
212 // embedders that supply their own compositor loop via 196 // embedders that supply their own compositor loop via
213 // OverrideCompositorMessageLoop(). 197 // OverrideCompositorMessageLoop().
214 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 198 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
215 return base::MessageLoop::current() && (base::MessageLoop::current() == 199 return base::MessageLoop::current() && (base::MessageLoop::current() ==
216 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); 200 GetContentClient()->renderer()->OverrideCompositorMessageLoop());
217 } 201 }
218 202
219 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698