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

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

Issue 15851006: Move synchronous compositor into content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/browser/android/in_process/synchronous_compositor_impl.h"
14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 15 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
16 #include "content/public/browser/android/synchronous_compositor_client.h"
17 #include "content/public/browser/browser_thread.h"
15 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
16 #include "content/public/renderer/android/synchronous_compositor_client.h"
17 #include "content/public/renderer/content_renderer_client.h"
18 #include "skia/ext/refptr.h" 19 #include "skia/ext/refptr.h"
19 #include "third_party/skia/include/core/SkCanvas.h" 20 #include "third_party/skia/include/core/SkCanvas.h"
20 #include "third_party/skia/include/core/SkDevice.h" 21 #include "third_party/skia/include/core/SkDevice.h"
21 #include "third_party/skia/include/core/SkPicture.h" 22 #include "third_party/skia/include/core/SkPicture.h"
22 #include "ui/gfx/rect_conversions.h" 23 #include "ui/gfx/rect_conversions.h"
23 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/transform.h" 25 #include "ui/gfx/transform.h"
25 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 26 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
26 27
27 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 28 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 private: 82 private:
82 SynchronousCompositorOutputSurface* surface_; 83 SynchronousCompositorOutputSurface* surface_;
83 SkDevice null_device_; 84 SkDevice null_device_;
84 SkCanvas null_canvas_; 85 SkCanvas null_canvas_;
85 86
86 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice); 87 DISALLOW_COPY_AND_ASSIGN(SoftwareDevice);
87 }; 88 };
88 89
89 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface( 90 SynchronousCompositorOutputSurface::SynchronousCompositorOutputSurface(
90 SynchronousCompositorOutputSurfaceDelegate* delegate) 91 int routing_id)
91 : cc::OutputSurface( 92 : cc::OutputSurface(
92 CreateWebGraphicsContext3D(), 93 CreateWebGraphicsContext3D(),
93 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), 94 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
94 delegate_(delegate), 95 routing_id_(routing_id),
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;
100 // Cannot call out to GetDelegate() here as the output surface is not
101 // constructed on the correct thread.
99 } 102 }
100 103
101 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() { 104 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {
102 DCHECK(CalledOnValidThread()); 105 DCHECK(CalledOnValidThread());
103 delegate_->DidDestroySynchronousOutputSurface(); 106 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
107 if (delegate)
108 delegate->DidDestroySynchronousOutputSurface(this);
104 } 109 }
105 110
106 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const { 111 bool SynchronousCompositorOutputSurface::ForcedDrawToSoftwareDevice() const {
107 return current_sw_canvas_ != NULL; 112 return current_sw_canvas_ != NULL;
108 } 113 }
109 114
110 bool SynchronousCompositorOutputSurface::BindToClient( 115 bool SynchronousCompositorOutputSurface::BindToClient(
111 cc::OutputSurfaceClient* surface_client) { 116 cc::OutputSurfaceClient* surface_client) {
112 DCHECK(CalledOnValidThread()); 117 DCHECK(CalledOnValidThread());
113 if (!cc::OutputSurface::BindToClient(surface_client)) 118 if (!cc::OutputSurface::BindToClient(surface_client))
114 return false; 119 return false;
115 delegate_->DidCreateSynchronousOutputSurface(); 120 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
121 if (delegate)
122 delegate->DidBindOutputSurface(this);
116 return true; 123 return true;
117 } 124 }
118 125
119 void SynchronousCompositorOutputSurface::Reshape( 126 void SynchronousCompositorOutputSurface::Reshape(
120 gfx::Size size, float scale_factor) { 127 gfx::Size size, float scale_factor) {
121 // Intentional no-op: surface size is controlled by the embedder. 128 // Intentional no-op: surface size is controlled by the embedder.
122 } 129 }
123 130
124 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor( 131 void SynchronousCompositorOutputSurface::SendFrameToParentCompositor(
125 cc::CompositorFrame* frame) { 132 cc::CompositorFrame* frame) {
126 NOTREACHED(); 133 NOTREACHED();
127 // TODO(joth): Route page scale to the client, see http://crbug.com/237006 134 // TODO(joth): Route page scale to the client, see http://crbug.com/237006
128 } 135 }
129 136
130 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame( 137 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(
131 bool enable) { 138 bool enable) {
132 DCHECK(CalledOnValidThread()); 139 DCHECK(CalledOnValidThread());
133 needs_begin_frame_ = enable; 140 needs_begin_frame_ = enable;
134 delegate_->SetContinuousInvalidate(needs_begin_frame_); 141 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
142 if (delegate)
143 delegate->SetContinuousInvalidate(needs_begin_frame_);
135 } 144 }
136 145
137 void SynchronousCompositorOutputSurface::SwapBuffers( 146 void SynchronousCompositorOutputSurface::SwapBuffers(
138 const ui::LatencyInfo& info) { 147 const ui::LatencyInfo& info) {
139 context3d()->shallowFlushCHROMIUM(); 148 context3d()->shallowFlushCHROMIUM();
140 did_swap_buffer_ = true; 149 did_swap_buffer_ = true;
141 } 150 }
142 151
143 bool SynchronousCompositorOutputSurface::IsHwReady() { 152 bool SynchronousCompositorOutputSurface::IsHwReady() {
144 return context3d() != NULL; 153 return context3d() != NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 const gfx::Transform& transform, 195 const gfx::Transform& transform,
187 gfx::Rect damage_area) { 196 gfx::Rect damage_area) {
188 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the 197 // TODO(boliu): This assumes |transform| is identity and |damage_area| is the
189 // whole view. Tracking bug to implement this: crbug.com/230463. 198 // whole view. Tracking bug to implement this: crbug.com/230463.
190 client_->SetNeedsRedrawRect(damage_area); 199 client_->SetNeedsRedrawRect(damage_area);
191 if (needs_begin_frame_) 200 if (needs_begin_frame_)
192 client_->BeginFrame(base::TimeTicks::Now()); 201 client_->BeginFrame(base::TimeTicks::Now());
193 } 202 }
194 203
195 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 204 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
196 // requirement: SynchronousCompositorOutputSurface() must only be used by 205 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI
197 // embedders that supply their own compositor loop via 206 // thread.
198 // OverrideCompositorMessageLoop().
199 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 207 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
200 return base::MessageLoop::current() && (base::MessageLoop::current() == 208 return BrowserThread::CurrentlyOn(BrowserThread::UI);
201 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); 209 }
210
211 SynchronousCompositorOutputSurfaceDelegate*
212 SynchronousCompositorOutputSurface::GetDelegate() {
213 return SynchronousCompositorImpl::FromRoutingID(routing_id_);
202 } 214 }
203 215
204 } // namespace content 216 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/in_process/synchronous_compositor_output_surface.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698