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

Side by Side Diff: third_party/WebKit/Source/core/dom/CompositorProxy.cpp

Issue 2765053002: Avoid exposing cc::Layer tree to CompositorProxy (Closed)
Patch Set: Rebase onto blink reformat Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/dom/CompositorProxy.h" 5 #include "core/dom/CompositorProxy.h"
6 6
7 #include "bindings/core/v8/ExceptionMessages.h" 7 #include "bindings/core/v8/ExceptionMessages.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/CompositorWorkerProxyClient.h" 9 #include "core/dom/CompositorWorkerProxyClient.h"
10 #include "core/dom/DOMNodeIds.h" 10 #include "core/dom/DOMNodeIds.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
13 #include "core/workers/WorkerClients.h" 13 #include "core/workers/WorkerClients.h"
14 #include "core/workers/WorkerGlobalScope.h" 14 #include "core/workers/WorkerGlobalScope.h"
15 #include "platform/CrossThreadFunctional.h" 15 #include "platform/CrossThreadFunctional.h"
16 #include "platform/graphics/CompositorMutableProperties.h" 16 #include "platform/graphics/CompositorMutableProperties.h"
17 #include "public/platform/Platform.h" 17 #include "public/platform/Platform.h"
18 #include "public/platform/WebTraceLocation.h" 18 #include "public/platform/WebTraceLocation.h"
19 #include <algorithm> 19 #include <algorithm>
20 20
21 namespace blink { 21 namespace blink {
22 namespace {
23 // An identifier for CompositorProxy objects. Will be unique across all proxies
24 // created in the same thread.
25 uint64_t g_unique_id = 0;
26 } // namespace
22 27
23 static const struct { 28 static const struct {
24 const char* name; 29 const char* name;
25 uint32_t property; 30 uint32_t property;
26 } kAllowedProperties[] = { 31 } kAllowedProperties[] = {
27 {"opacity", CompositorMutableProperty::kOpacity}, 32 {"opacity", CompositorMutableProperty::kOpacity},
28 {"scrollleft", CompositorMutableProperty::kScrollLeft}, 33 {"scrollleft", CompositorMutableProperty::kScrollLeft},
29 {"scrolltop", CompositorMutableProperty::kScrollTop}, 34 {"scrolltop", CompositorMutableProperty::kScrollTop},
30 {"transform", CompositorMutableProperty::kTransform}, 35 {"transform", CompositorMutableProperty::kTransform},
31 }; 36 };
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 CompositorWorkerProxyClient::From(clients); 135 CompositorWorkerProxyClient::From(clients);
131 return new CompositorProxy(element_id, compositor_mutable_properties, 136 return new CompositorProxy(element_id, compositor_mutable_properties,
132 client->GetCompositorProxyClient()); 137 client->GetCompositorProxyClient());
133 } 138 }
134 139
135 return new CompositorProxy(element_id, compositor_mutable_properties); 140 return new CompositorProxy(element_id, compositor_mutable_properties);
136 } 141 }
137 142
138 CompositorProxy::CompositorProxy(uint64_t element_id, 143 CompositorProxy::CompositorProxy(uint64_t element_id,
139 uint32_t compositor_mutable_properties) 144 uint32_t compositor_mutable_properties)
140 : element_id_(element_id), 145 : proxy_id_(g_unique_id++),
146 element_id_(element_id),
141 compositor_mutable_properties_(compositor_mutable_properties), 147 compositor_mutable_properties_(compositor_mutable_properties),
142 client_(nullptr) { 148 client_(nullptr) {
143 DCHECK(compositor_mutable_properties_); 149 DCHECK(compositor_mutable_properties_);
144 #if DCHECK_IS_ON() 150 #if DCHECK_IS_ON()
145 DCHECK(SanityCheckMutableProperties(compositor_mutable_properties_)); 151 DCHECK(SanityCheckMutableProperties(compositor_mutable_properties_));
146 #endif 152 #endif
147 153
148 if (IsMainThread()) { 154 if (IsMainThread()) {
flackr 2017/04/11 17:51:36 This check implies that this constructor can be ca
smcgruer 2017/04/19 15:38:38 Hrm, you are correct. I think the correct thing to
flackr 2017/04/20 06:54:14 Yes, this SGTM
149 IncrementCompositorProxiedPropertiesForElement( 155 IncrementCompositorProxiedPropertiesForElement(
150 element_id_, compositor_mutable_properties_); 156 element_id_, compositor_mutable_properties_);
151 } else { 157 } else {
152 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask( 158 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask(
153 BLINK_FROM_HERE, 159 BLINK_FROM_HERE,
154 CrossThreadBind(&IncrementCompositorProxiedPropertiesForElement, 160 CrossThreadBind(&IncrementCompositorProxiedPropertiesForElement,
155 element_id_, compositor_mutable_properties_)); 161 element_id_, compositor_mutable_properties_));
156 } 162 }
157 } 163 }
158 164
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 element_id_, compositor_mutable_properties_); 311 element_id_, compositor_mutable_properties_);
306 } else { 312 } else {
307 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask( 313 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask(
308 BLINK_FROM_HERE, 314 BLINK_FROM_HERE,
309 CrossThreadBind(&DecrementCompositorProxiedPropertiesForElement, 315 CrossThreadBind(&DecrementCompositorProxiedPropertiesForElement,
310 element_id_, compositor_mutable_properties_)); 316 element_id_, compositor_mutable_properties_));
311 } 317 }
312 } 318 }
313 319
314 } // namespace blink 320 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698