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

Side by Side Diff: ui/compositor/compositor.cc

Issue 10798006: Implement WebCompositorOutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 4 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
« no previous file with comments | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/images/SkImageEncoder.h" 12 #include "third_party/skia/include/images/SkImageEncoder.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h" 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositor.h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput Surface.h"
17 #include "ui/compositor/compositor_observer.h" 18 #include "ui/compositor/compositor_observer.h"
18 #include "ui/compositor/compositor_switches.h" 19 #include "ui/compositor/compositor_switches.h"
19 #include "ui/compositor/dip_util.h" 20 #include "ui/compositor/dip_util.h"
20 #include "ui/compositor/layer.h" 21 #include "ui/compositor/layer.h"
21 #include "ui/compositor/test_web_graphics_context_3d.h" 22 #include "ui/compositor/test_web_graphics_context_3d.h"
22 #include "ui/gl/gl_context.h" 23 #include "ui/gl/gl_context.h"
23 #include "ui/gl/gl_implementation.h" 24 #include "ui/gl/gl_implementation.h"
24 #include "ui/gl/gl_surface.h" 25 #include "ui/gl/gl_surface.h"
25 #include "webkit/glue/webthread_impl.h" 26 #include "webkit/glue/webthread_impl.h"
26 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 27 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 disable_schedule_composite_ = true; 322 disable_schedule_composite_ = true;
322 if (root_layer_) 323 if (root_layer_)
323 root_layer_->SendDamagedRects(); 324 root_layer_->SendDamagedRects();
324 disable_schedule_composite_ = false; 325 disable_schedule_composite_ = false;
325 } 326 }
326 327
327 void Compositor::applyScrollAndScale(const WebKit::WebSize& scrollDelta, 328 void Compositor::applyScrollAndScale(const WebKit::WebSize& scrollDelta,
328 float scaleFactor) { 329 float scaleFactor) {
329 } 330 }
330 331
331 WebKit::WebGraphicsContext3D* Compositor::createContext3D() { 332 // Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface.
333 class WebGraphicsContextToOutputSurfaceAdapter :
334 public WebKit::WebCompositorOutputSurface {
335 public:
336 explicit WebGraphicsContextToOutputSurfaceAdapter(
337 WebKit::WebGraphicsContext3D* context)
338 : m_context3D(context)
339 , m_client(0)
340 {
341 }
342
343 virtual bool bindToClient(
344 WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE
345 {
346 DCHECK(client);
347 if (!m_context3D->makeContextCurrent())
348 return false;
349 m_client = client;
350 return true;
351 }
352
353 virtual const Capabilities& capabilities() const OVERRIDE
354 {
355 return m_capabilities;
356 }
357
358 virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE
359 {
360 return m_context3D.get();
361 }
362
363 virtual void sendFrameToParentCompositor(
364 const WebKit::WebCompositorFrame&) OVERRIDE
365 {
366 }
367
368 private:
369 scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D;
370 Capabilities m_capabilities;
371 WebKit::WebCompositorOutputSurfaceClient* m_client;
372 };
373
374 WebKit::WebCompositorOutputSurface* Compositor::createOutputSurface() {
332 if (test_compositor_enabled) { 375 if (test_compositor_enabled) {
333 ui::TestWebGraphicsContext3D* test_context = 376 ui::TestWebGraphicsContext3D* test_context =
334 new ui::TestWebGraphicsContext3D(); 377 new ui::TestWebGraphicsContext3D();
335 test_context->Initialize(); 378 test_context->Initialize();
336 return test_context; 379 return new WebGraphicsContextToOutputSurfaceAdapter(test_context);
337 } else { 380 } else {
338 return ContextFactory::GetInstance()->CreateContext(this); 381 return new WebGraphicsContextToOutputSurfaceAdapter(
382 ContextFactory::GetInstance()->CreateContext(this));
339 } 383 }
340 } 384 }
341 385
342 void Compositor::didRebindGraphicsContext(bool success) { 386 void Compositor::didRecreateOutputSurface(bool success) {
343 } 387 }
344 388
345 // Called once per draw in single-threaded compositor mode and potentially 389 // Called once per draw in single-threaded compositor mode and potentially
346 // many times between draws in the multi-threaded compositor mode. 390 // many times between draws in the multi-threaded compositor mode.
347 void Compositor::didCommit() { 391 void Compositor::didCommit() {
348 FOR_EACH_OBSERVER(CompositorObserver, 392 FOR_EACH_OBSERVER(CompositorObserver,
349 observer_list_, 393 observer_list_,
350 OnCompositingDidCommit(this)); 394 OnCompositingDidCommit(this));
351 } 395 }
352 396
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 460
417 COMPOSITOR_EXPORT void DisableTestCompositor() { 461 COMPOSITOR_EXPORT void DisableTestCompositor() {
418 test_compositor_enabled = false; 462 test_compositor_enabled = false;
419 } 463 }
420 464
421 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 465 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
422 return test_compositor_enabled; 466 return test_compositor_enabled;
423 } 467 }
424 468
425 } // namespace ui 469 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698