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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp

Issue 2644653003: Make OffscreenCanvas animation in sync with its placeholder canvas's parent frame rate (Closed)
Patch Set: safeguard Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/CanvasSurfaceLayerBridge.h" 5 #include "platform/graphics/CanvasSurfaceLayerBridge.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/layers/solid_color_layer.h" 8 #include "cc/layers/solid_color_layer.h"
9 #include "cc/layers/surface_layer.h" 9 #include "cc/layers/surface_layer.h"
10 #include "cc/surfaces/sequence_surface_reference_factory.h" 10 #include "cc/surfaces/sequence_surface_reference_factory.h"
11 #include "cc/surfaces/surface_id.h" 11 #include "cc/surfaces/surface_id.h"
12 #include "cc/surfaces/surface_info.h" 12 #include "cc/surfaces/surface_info.h"
13 #include "cc/surfaces/surface_sequence.h" 13 #include "cc/surfaces/surface_sequence.h"
14 #include "platform/graphics/GraphicsLayer.h" 14 #include "platform/graphics/GraphicsLayer.h"
15 #include "platform/mojo/MojoHelper.h" 15 #include "platform/mojo/MojoHelper.h"
16 #include "public/platform/InterfaceProvider.h" 16 #include "public/platform/InterfaceProvider.h"
17 #include "public/platform/Platform.h" 17 #include "public/platform/Platform.h"
18 #include "public/platform/WebCompositorSupport.h" 18 #include "public/platform/WebCompositorSupport.h"
19 #include "public/platform/WebLayer.h" 19 #include "public/platform/WebLayer.h"
20 #include "public/platform/WebLayerTreeView.h"
20 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h" 21 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h"
21 #include "ui/gfx/geometry/size.h" 22 #include "ui/gfx/geometry/size.h"
22 #include "wtf/Functional.h" 23 #include "wtf/Functional.h"
23 24
24 namespace blink { 25 namespace blink {
25 26
26 namespace { 27 namespace {
27 28
28 class OffscreenCanvasSurfaceReferenceFactory 29 class OffscreenCanvasSurfaceReferenceFactory
29 : public cc::SequenceSurfaceReferenceFactory { 30 : public cc::SequenceSurfaceReferenceFactory {
(...skipping 18 matching lines...) Expand all
48 } 49 }
49 50
50 base::WeakPtr<CanvasSurfaceLayerBridge> m_bridge; 51 base::WeakPtr<CanvasSurfaceLayerBridge> m_bridge;
51 52
52 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceReferenceFactory); 53 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceReferenceFactory);
53 }; 54 };
54 55
55 } // namespace 56 } // namespace
56 57
57 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge( 58 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(
58 CanvasSurfaceLayerBridgeObserver* observer) 59 CanvasSurfaceLayerBridgeObserver* observer,
60 WebLayerTreeView* layerTreeView)
59 : m_weakFactory(this), 61 : m_weakFactory(this),
60 m_observer(observer), 62 m_observer(observer),
61 m_binding(this), 63 m_binding(this),
62 m_frameSinkId(Platform::current()->generateFrameSinkId()) { 64 m_frameSinkId(Platform::current()->generateFrameSinkId()) {
63 m_refFactory = 65 m_refFactory =
64 new OffscreenCanvasSurfaceReferenceFactory(m_weakFactory.GetWeakPtr()); 66 new OffscreenCanvasSurfaceReferenceFactory(m_weakFactory.GetWeakPtr());
65 67
66 DCHECK(!m_service.is_bound()); 68 DCHECK(!m_service.is_bound());
67 mojom::blink::OffscreenCanvasSurfaceFactoryPtr serviceFactory; 69 mojom::blink::OffscreenCanvasSurfaceFactoryPtr serviceFactory;
68 Platform::current()->interfaceProvider()->getInterface( 70 Platform::current()->interfaceProvider()->getInterface(
69 mojo::MakeRequest(&serviceFactory)); 71 mojo::MakeRequest(&serviceFactory));
72 if (layerTreeView) {
Fady Samuel 2017/01/19 04:05:43 Is there any reason why this might be null?
xlai (Olivia) 2017/01/19 16:43:56 This variable is passed from HTMLCanvasElement. I'
dcheng 2017/01/20 08:44:12 Out of curiosity, how do we create this object if
xlai (Olivia) 2017/01/20 16:36:21 Just double check with junov@. This variable can b
73 m_parentFrameSinkId = layerTreeView->getFrameSinkId();
74 }
70 serviceFactory->CreateOffscreenCanvasSurface( 75 serviceFactory->CreateOffscreenCanvasSurface(
71 m_frameSinkId, m_binding.CreateInterfacePtrAndBind(), 76 m_parentFrameSinkId, m_frameSinkId, m_binding.CreateInterfacePtrAndBind(),
72 mojo::MakeRequest(&m_service)); 77 mojo::MakeRequest(&m_service));
73 } 78 }
74 79
75 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() { 80 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() {
76 m_observer = nullptr; 81 m_observer = nullptr;
77 } 82 }
78 83
79 void CanvasSurfaceLayerBridge::createSolidColorLayer() { 84 void CanvasSurfaceLayerBridge::createSolidColorLayer() {
80 m_CCLayer = cc::SolidColorLayer::Create(); 85 m_CCLayer = cc::SolidColorLayer::Create();
81 m_CCLayer->SetBackgroundColor(SK_ColorTRANSPARENT); 86 m_CCLayer->SetBackgroundColor(SK_ColorTRANSPARENT);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 m_service->Satisfy(sequence); 125 m_service->Satisfy(sequence);
121 } 126 }
122 127
123 void CanvasSurfaceLayerBridge::requireCallback( 128 void CanvasSurfaceLayerBridge::requireCallback(
124 const cc::SurfaceId& surfaceId, 129 const cc::SurfaceId& surfaceId,
125 const cc::SurfaceSequence& sequence) { 130 const cc::SurfaceSequence& sequence) {
126 m_service->Require(surfaceId, sequence); 131 m_service->Require(surfaceId, sequence);
127 } 132 }
128 133
129 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698