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

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: rebase 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()),
65 m_parentFrameSinkId(layerTreeView ? layerTreeView->getFrameSinkId()
dcheng 2017/01/24 22:31:37 With the latest PS, do we still need a null check
xlai (Olivia) 2017/01/24 22:57:12 Yes, in EmptyChromeClient or Unit test, layertreev
xlai (Olivia) 2017/01/24 23:15:39 I took away the nullity check. I look through the
66 : cc::FrameSinkId()) {
63 m_refFactory = 67 m_refFactory =
64 new OffscreenCanvasSurfaceReferenceFactory(m_weakFactory.GetWeakPtr()); 68 new OffscreenCanvasSurfaceReferenceFactory(m_weakFactory.GetWeakPtr());
65 69
66 DCHECK(!m_service.is_bound()); 70 DCHECK(!m_service.is_bound());
67 mojom::blink::OffscreenCanvasSurfaceFactoryPtr serviceFactory; 71 mojom::blink::OffscreenCanvasSurfaceFactoryPtr serviceFactory;
68 Platform::current()->interfaceProvider()->getInterface( 72 Platform::current()->interfaceProvider()->getInterface(
69 mojo::MakeRequest(&serviceFactory)); 73 mojo::MakeRequest(&serviceFactory));
74 // TODO(xlai): Ensure OffscreenCanvas commit() is still functional when a
75 // frame-less HTML canvas's document is reparenting under another frame.
76 // See crbug.com/683172.
70 serviceFactory->CreateOffscreenCanvasSurface( 77 serviceFactory->CreateOffscreenCanvasSurface(
71 m_frameSinkId, m_binding.CreateInterfacePtrAndBind(), 78 m_parentFrameSinkId, m_frameSinkId, m_binding.CreateInterfacePtrAndBind(),
72 mojo::MakeRequest(&m_service)); 79 mojo::MakeRequest(&m_service));
73 } 80 }
74 81
75 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() { 82 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() {
76 m_observer = nullptr; 83 m_observer = nullptr;
77 } 84 }
78 85
79 void CanvasSurfaceLayerBridge::createSolidColorLayer() { 86 void CanvasSurfaceLayerBridge::createSolidColorLayer() {
80 m_CCLayer = cc::SolidColorLayer::Create(); 87 m_CCLayer = cc::SolidColorLayer::Create();
81 m_CCLayer->SetBackgroundColor(SK_ColorTRANSPARENT); 88 m_CCLayer->SetBackgroundColor(SK_ColorTRANSPARENT);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 m_service->Satisfy(sequence); 127 m_service->Satisfy(sequence);
121 } 128 }
122 129
123 void CanvasSurfaceLayerBridge::requireCallback( 130 void CanvasSurfaceLayerBridge::requireCallback(
124 const cc::SurfaceId& surfaceId, 131 const cc::SurfaceId& surfaceId,
125 const cc::SurfaceSequence& sequence) { 132 const cc::SurfaceSequence& sequence) {
126 m_service->Require(surfaceId, sequence); 133 m_service->Require(surfaceId, sequence);
127 } 134 }
128 135
129 } // namespace blink 136 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698