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

Side by Side Diff: content/browser/renderer_host/image_transport_factory.cc

Issue 11348371: cc: Move WebCompositorOutputSurface and related classes into cc/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding6 Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/image_transport_factory.h" 5 #include "content/browser/renderer_host/image_transport_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "cc/output_surface.h"
16 #include "cc/output_surface_client.h"
15 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 17 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
16 #include "content/browser/gpu/gpu_data_manager_impl.h" 18 #include "content/browser/gpu/gpu_data_manager_impl.h"
17 #include "content/browser/gpu/gpu_process_host.h" 19 #include "content/browser/gpu/gpu_process_host.h"
18 #include "content/browser/gpu/gpu_surface_tracker.h" 20 #include "content/browser/gpu/gpu_surface_tracker.h"
19 #include "content/common/gpu/client/gl_helper.h" 21 #include "content/common/gpu/client/gl_helper.h"
20 #include "content/common/gpu/client/gpu_channel_host.h" 22 #include "content/common/gpu/client/gpu_channel_host.h"
21 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
22 #include "content/common/gpu/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
23 #include "content/common/gpu/gpu_process_launch_causes.h" 25 #include "content/common/gpu/gpu_process_launch_causes.h"
24 #include "content/common/webkitplatformsupport_impl.h" 26 #include "content/common/webkitplatformsupport_impl.h"
25 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
26 #include "gpu/ipc/command_buffer_proxy.h" 28 #include "gpu/ipc/command_buffer_proxy.h"
27 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h"
28 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput SurfaceClient.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
30 #include "ui/compositor/compositor.h" 30 #include "ui/compositor/compositor.h"
31 #include "ui/compositor/compositor_setup.h" 31 #include "ui/compositor/compositor_setup.h"
32 #include "ui/compositor/test_web_graphics_context_3d.h" 32 #include "ui/compositor/test_web_graphics_context_3d.h"
33 #include "ui/gfx/native_widget_types.h" 33 #include "ui/gfx/native_widget_types.h"
34 #include "ui/gfx/size.h" 34 #include "ui/gfx/size.h"
35 35
36 #if defined(OS_WIN) 36 #if defined(OS_WIN)
37 #include "ui/surface/accelerated_surface_win.h" 37 #include "ui/surface/accelerated_surface_win.h"
38 #endif 38 #endif
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 base::RefCountedThreadSafe<BrowserCompositorOutputSurfaceProxy>; 263 base::RefCountedThreadSafe<BrowserCompositorOutputSurfaceProxy>;
264 ~BrowserCompositorOutputSurfaceProxy() {} 264 ~BrowserCompositorOutputSurfaceProxy() {}
265 IDMap<BrowserCompositorOutputSurface> surface_map_; 265 IDMap<BrowserCompositorOutputSurface> surface_map_;
266 bool message_handler_set_; 266 bool message_handler_set_;
267 267
268 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurfaceProxy); 268 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurfaceProxy);
269 }; 269 };
270 270
271 271
272 // Adapts a WebGraphicsContext3DCommandBufferImpl into a 272 // Adapts a WebGraphicsContext3DCommandBufferImpl into a
273 // WebCompositorOutputSurface that also handles vsync parameter updates 273 // cc::OutputSurface that also handles vsync parameter updates
274 // arriving from the GPU process. 274 // arriving from the GPU process.
275 class BrowserCompositorOutputSurface : 275 class BrowserCompositorOutputSurface :
276 public WebKit::WebCompositorOutputSurface, 276 public cc::OutputSurface,
277 public base::NonThreadSafe { 277 public base::NonThreadSafe {
278 public: 278 public:
279 explicit BrowserCompositorOutputSurface( 279 explicit BrowserCompositorOutputSurface(
280 WebGraphicsContext3DCommandBufferImpl* context, 280 WebGraphicsContext3DCommandBufferImpl* context,
281 int surface_id, 281 int surface_id,
282 BrowserCompositorOutputSurfaceProxy* output_surface_proxy) 282 BrowserCompositorOutputSurfaceProxy* output_surface_proxy)
283 : context3D_(context), 283 : context3D_(context),
284 surface_id_(surface_id), 284 surface_id_(surface_id),
285 client_(NULL), 285 client_(NULL),
286 output_surface_proxy_(output_surface_proxy) { 286 output_surface_proxy_(output_surface_proxy) {
287 DetachFromThread(); 287 DetachFromThread();
288 } 288 }
289 289
290 virtual ~BrowserCompositorOutputSurface() { 290 virtual ~BrowserCompositorOutputSurface() {
291 DCHECK(CalledOnValidThread()); 291 DCHECK(CalledOnValidThread());
292 if (!client_) 292 if (!client_)
293 return; 293 return;
294 output_surface_proxy_->RemoveSurface(surface_id_); 294 output_surface_proxy_->RemoveSurface(surface_id_);
295 } 295 }
296 296
297 virtual bool bindToClient( 297 virtual bool BindToClient(
298 WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE { 298 cc::OutputSurfaceClient* client) OVERRIDE {
299 DCHECK(CalledOnValidThread()); 299 DCHECK(CalledOnValidThread());
300 DCHECK(client); 300 DCHECK(client);
301 DCHECK(!client_); 301 DCHECK(!client_);
302 if (context3D_.get()) { 302 if (context3D_.get()) {
303 if (!context3D_->makeContextCurrent()) 303 if (!context3D_->makeContextCurrent())
304 return false; 304 return false;
305 } 305 }
306 306
307 client_ = client; 307 client_ = client;
308 output_surface_proxy_->AddSurface(this, surface_id_); 308 output_surface_proxy_->AddSurface(this, surface_id_);
309 return true; 309 return true;
310 } 310 }
311 311
312 virtual const Capabilities& capabilities() const OVERRIDE { 312 virtual const struct Capabilities& Capabilities() const OVERRIDE {
313 DCHECK(CalledOnValidThread()); 313 DCHECK(CalledOnValidThread());
314 return capabilities_; 314 return capabilities_;
315 } 315 }
316 316
317 virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE { 317 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE {
318 DCHECK(CalledOnValidThread()); 318 DCHECK(CalledOnValidThread());
319 return context3D_.get(); 319 return context3D_.get();
320 } 320 }
321 321
322 virtual void sendFrameToParentCompositor( 322 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE {
323 const WebKit::WebCompositorFrame&) OVERRIDE { 323 DCHECK(CalledOnValidThread());
324 return NULL;
325 }
326
327 virtual void SendFrameToParentCompositor(
328 const cc::CompositorFrame&) OVERRIDE {
324 } 329 }
325 330
326 void OnUpdateVSyncParameters( 331 void OnUpdateVSyncParameters(
327 base::TimeTicks timebase, base::TimeDelta interval) { 332 base::TimeTicks timebase, base::TimeDelta interval) {
328 DCHECK(CalledOnValidThread()); 333 DCHECK(CalledOnValidThread());
329 DCHECK(client_); 334 DCHECK(client_);
330 double monotonicTimebase = timebase.ToInternalValue() / 335 client_->OnVSyncParametersChanged(timebase, interval);
331 static_cast<double>(base::Time::kMicrosecondsPerSecond);
332 double intervalInSeconds = interval.ToInternalValue() /
333 static_cast<double>(base::Time::kMicrosecondsPerSecond);
334 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds);
335 } 336 }
336 337
337 private: 338 private:
338 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3D_; 339 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3D_;
339 int surface_id_; 340 int surface_id_;
340 Capabilities capabilities_; 341 struct Capabilities capabilities_;
341 WebKit::WebCompositorOutputSurfaceClient* client_; 342 cc::OutputSurfaceClient* client_;
342 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; 343 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_;
343 }; 344 };
344 345
345 void BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParameters( 346 void BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParameters(
346 int surface_id, base::TimeTicks timebase, base::TimeDelta interval) { 347 int surface_id, base::TimeTicks timebase, base::TimeDelta interval) {
347 BrowserCompositorOutputSurface* surface = surface_map_.Lookup(surface_id); 348 BrowserCompositorOutputSurface* surface = surface_map_.Lookup(surface_id);
348 if (surface) 349 if (surface)
349 surface->OnUpdateVSyncParameters(timebase, interval); 350 surface->OnUpdateVSyncParameters(timebase, interval);
350 } 351 }
351 352
(...skipping 10 matching lines...) Expand all
362 virtual ~GpuProcessTransportFactory() { 363 virtual ~GpuProcessTransportFactory() {
363 DCHECK(per_compositor_data_.empty()); 364 DCHECK(per_compositor_data_.empty());
364 } 365 }
365 366
366 virtual WebGraphicsContext3DCommandBufferImpl* CreateOffscreenContext() 367 virtual WebGraphicsContext3DCommandBufferImpl* CreateOffscreenContext()
367 OVERRIDE { 368 OVERRIDE {
368 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; 369 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
369 return CreateContextCommon(swap_client, 0); 370 return CreateContextCommon(swap_client, 0);
370 } 371 }
371 372
372 virtual WebKit::WebCompositorOutputSurface* CreateOutputSurface( 373 virtual cc::OutputSurface* CreateOutputSurface(
373 ui::Compositor* compositor) OVERRIDE { 374 ui::Compositor* compositor) OVERRIDE {
374 PerCompositorData* data = per_compositor_data_[compositor]; 375 PerCompositorData* data = per_compositor_data_[compositor];
375 if (!data) 376 if (!data)
376 data = CreatePerCompositorData(compositor); 377 data = CreatePerCompositorData(compositor);
377 WebGraphicsContext3DCommandBufferImpl* context = 378 WebGraphicsContext3DCommandBufferImpl* context =
378 CreateContextCommon(data->swap_client->AsWeakPtr(), 379 CreateContextCommon(data->swap_client->AsWeakPtr(),
379 data->surface_id); 380 data->surface_id);
380 return new BrowserCompositorOutputSurface( 381 return new BrowserCompositorOutputSurface(
381 context, 382 context,
382 per_compositor_data_[compositor]->surface_id, 383 per_compositor_data_[compositor]->surface_id,
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 delete g_factory; 640 delete g_factory;
640 g_factory = NULL; 641 g_factory = NULL;
641 } 642 }
642 643
643 // static 644 // static
644 ImageTransportFactory* ImageTransportFactory::GetInstance() { 645 ImageTransportFactory* ImageTransportFactory::GetInstance() {
645 return g_factory; 646 return g_factory;
646 } 647 }
647 648
648 } // namespace content 649 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.cc ('k') | content/renderer/gpu/compositor_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698