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

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

Issue 16119003: Move SynchronousCompositor into content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/browser/android/in_process/synchronous_compositor_output_surfa ce.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"
11 #include "cc/output/compositor_frame_ack.h" 11 #include "cc/output/compositor_frame_ack.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/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 #include "content/public/renderer/android/synchronous_compositor_client.h" 17 #include "content/public/renderer/android/synchronous_compositor_client.h"
17 #include "content/public/renderer/content_renderer_client.h"
18 #include "skia/ext/refptr.h" 18 #include "skia/ext/refptr.h"
19 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
20 #include "third_party/skia/include/core/SkDevice.h" 20 #include "third_party/skia/include/core/SkDevice.h"
21 #include "third_party/skia/include/core/SkPicture.h" 21 #include "third_party/skia/include/core/SkPicture.h"
22 #include "ui/gfx/rect_conversions.h" 22 #include "ui/gfx/rect_conversions.h"
23 #include "ui/gfx/skia_util.h" 23 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
25 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 25 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
26 26
27 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 27 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
(...skipping 52 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 SynchronousCompositorOutputSurfaceDelegate* delegate) 90 int routing_id)
91 : cc::OutputSurface( 91 : cc::OutputSurface(
92 CreateWebGraphicsContext3D(), 92 CreateWebGraphicsContext3D(),
93 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), 93 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
94 delegate_(delegate), 94 routing_id_(routing_id),
95 delegate_(NULL),
95 needs_begin_frame_(false), 96 needs_begin_frame_(false),
96 did_swap_buffer_(false), 97 did_swap_buffer_(false),
97 current_sw_canvas_(NULL) { 98 current_sw_canvas_(NULL) {
98 capabilities_.deferred_gl_initialization = true; 99 capabilities_.deferred_gl_initialization = true;
joth 2013/05/29 06:05:10 // Do not call out to SynchronousCompositorImpl he
joth 2013/05/29 20:19:08 Done.
99 } 100 }
100 101
101 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { 102 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
102 DCHECK(CalledOnValidThread()); 103 DCHECK(CalledOnValidThread());
103 delegate_->DidDestroySynchronousOutputSurface(); 104 if (delegate_)
105 delegate_->DidDestroySynchronousOutputSurface();
joth 2013/05/29 06:05:10 pass |this| for consistency with the DidBindOutput
mkosiba (inactive) 2013/05/29 15:31:58 sounds like a good idea. we can add a DCHECK to ch
joth 2013/05/29 20:19:08 Done.
104 } 106 }
105 107
106 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const { 108 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
107 return current_sw_canvas_ != NULL; 109 return current_sw_canvas_ != NULL;
108 } 110 }
109 111
110 bool SynchronousCompositorOutputSurface::BindToClient( 112 bool SynchronousCompositorOutputSurface::BindToClient(
111 cc::OutputSurfaceClient* surface_client) { 113 cc::OutputSurfaceClient* surface_client) {
112 DCHECK(CalledOnValidThread()); 114 DCHECK(CalledOnValidThread());
113 if (!cc::OutputSurface::BindToClient(surface_client)) 115 if (!cc::OutputSurface::BindToClient(surface_client))
114 return false; 116 return false;
115 delegate_->DidCreateSynchronousOutputSurface(); 117 // TODO(joth): The SynchronousCompositorOutputSurfaceDelegate is fairly
118 // pointless if we're statically calling out to SynchronousCompositorImpl
119 // here.
joth 2013/05/29 06:05:10 My current thinking is to delete the SynchronousCo
mkosiba (inactive) 2013/05/29 15:31:58 Umm.. SynchronousCompositorImpl will end up contai
joth 2013/05/29 20:19:08 Done.
120 SynchronousCompositorImpl::DidBindOutputSurface(routing_id_, this);
joth 2013/05/29 06:05:10 this could be SynchronousCompositorImpl::FromRout
joth 2013/05/29 20:19:08 (obsolete)
116 return true; 121 return true;
117 } 122 }
118 123
119 void SynchronousCompositorOutputSurface::Reshape( 124 void SynchronousCompositorOutputSurface::Reshape(
120 gfx::Size size, float scale_factor) { 125 gfx::Size size, float scale_factor) {
121 // Intentional no-op: surface size is controlled by the embedder. 126 // Intentional no-op: surface size is controlled by the embedder.
122 } 127 }
123 128
124 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( 129 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor(
125 cc::CompositorFrame* frame) { 130 cc::CompositorFrame* frame) {
126 NOTREACHED(); 131 NOTREACHED();
127 // TODO(joth): Route page scale to the client, see http://crbug.com/237006 132 // TODO(joth): Route page scale to the client, see http://crbug.com/237006
128 } 133 }
129 134
130 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame( 135 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(
131 bool enable) { 136 bool enable) {
132 DCHECK(CalledOnValidThread()); 137 DCHECK(CalledOnValidThread());
133 needs_begin_frame_ = enable; 138 needs_begin_frame_ = enable;
134 delegate_->SetContinuousInvalidate(needs_begin_frame_); 139 if (delegate_)
140 delegate_->SetContinuousInvalidate(needs_begin_frame_);
135 } 141 }
136 142
137 void SynchronousCompositorOutputSurface::SwapBuffers( 143 void SynchronousCompositorOutputSurface::SwapBuffers(
138 const cc::LatencyInfo& info) { 144 const cc::LatencyInfo& info) {
139 context3d()->shallowFlushCHROMIUM(); 145 context3d()->shallowFlushCHROMIUM();
140 did_swap_buffer_ = true; 146 did_swap_buffer_ = true;
141 } 147 }
142 148
143 bool SynchronousCompositorOutputSurface::IsHwReady() { 149 bool SynchronousCompositorOutputSurface::IsHwReady() {
144 return context3d() != NULL; 150 return context3d() != NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 const gfx::Transform& transform, 192 const gfx::Transform& transform,
187 gfx::Rect damage_area) { 193 gfx::Rect damage_area) {
188 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the 194 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the
189 // whole view. Tracking bug to implement this: crbug.com/230463. 195 // whole view. Tracking bug to implement this: crbug.com/230463.
190 client_->SetNeedsRedrawRect(damage_area); 196 client_->SetNeedsRedrawRect(damage_area);
191 if (needs_begin_frame_) 197 if (needs_begin_frame_)
192 client_->BeginFrame(base::TimeTicks::Now()); 198 client_->BeginFrame(base::TimeTicks::Now());
193 } 199 }
194 200
195 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 201 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
196 // requirement: SynchronousCompositorOutputSurface() must only be used by 202 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI
197 // embedders that supply their own compositor loop via 203 // thread.
198 // OverrideCompositorMessageLoop().
199 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 204 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
200 return base::MessageLoop::current() && (base::MessageLoop::current() == 205 return BrowserThread::CurrentlyOn(BrowserThread::UI);
201 GetContentClient()->renderer()->OverrideCompositorMessageLoop());
202 } 206 }
203 207
204 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/in_process/synchronous_compositor_output_surface.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698