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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 15579002: Implement transform/clip support for Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests Created 7 years, 6 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Proxy* proxy, 158 Proxy* proxy,
159 RenderingStatsInstrumentation* rendering_stats_instrumentation) 159 RenderingStatsInstrumentation* rendering_stats_instrumentation)
160 : client_(client), 160 : client_(client),
161 proxy_(proxy), 161 proxy_(proxy),
162 input_handler_client_(NULL), 162 input_handler_client_(NULL),
163 did_lock_scrolling_layer_(false), 163 did_lock_scrolling_layer_(false),
164 should_bubble_scrolls_(false), 164 should_bubble_scrolls_(false),
165 wheel_scrolling_(false), 165 wheel_scrolling_(false),
166 root_layer_scroll_offset_delegate_(NULL), 166 root_layer_scroll_offset_delegate_(NULL),
167 settings_(settings), 167 settings_(settings),
168 overdraw_bottom_height_(0.f),
169 device_scale_factor_(1.f),
170 visible_(true), 168 visible_(true),
171 managed_memory_policy_( 169 managed_memory_policy_(
172 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), 170 PrioritizedResourceManager::DefaultMemoryAllocationLimit(),
173 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, 171 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
174 0, 172 0,
175 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING), 173 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING),
176 pinch_gesture_active_(false), 174 pinch_gesture_active_(false),
177 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), 175 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())),
178 paint_time_counter_(PaintTimeCounter::Create()), 176 paint_time_counter_(PaintTimeCounter::Create()),
179 memory_history_(MemoryHistory::Create()), 177 memory_history_(MemoryHistory::Create()),
180 debug_rect_history_(DebugRectHistory::Create()), 178 debug_rect_history_(DebugRectHistory::Create()),
181 max_memory_needed_bytes_(0), 179 max_memory_needed_bytes_(0),
182 last_sent_memory_visible_bytes_(0), 180 last_sent_memory_visible_bytes_(0),
183 last_sent_memory_visible_and_nearby_bytes_(0), 181 last_sent_memory_visible_and_nearby_bytes_(0),
184 last_sent_memory_use_bytes_(0), 182 last_sent_memory_use_bytes_(0),
183 device_scale_factor_(1.f),
184 overdraw_bottom_height_(0.f),
185 animation_registrar_(AnimationRegistrar::Create()), 185 animation_registrar_(AnimationRegistrar::Create()),
186 rendering_stats_instrumentation_(rendering_stats_instrumentation) { 186 rendering_stats_instrumentation_(rendering_stats_instrumentation) {
187 DCHECK(proxy_->IsImplThread()); 187 DCHECK(proxy_->IsImplThread());
188 DidVisibilityChange(this, visible_); 188 DidVisibilityChange(this, visible_);
189 189
190 SetDebugState(settings.initial_debug_state); 190 SetDebugState(settings.initial_debug_state);
191 191
192 if (settings.calculate_top_controls_position) { 192 if (settings.calculate_top_controls_position) {
193 top_controls_manager_ = 193 top_controls_manager_ =
194 TopControlsManager::Create(this, 194 TopControlsManager::Create(this,
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1038 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1039 } else { 1039 } else {
1040 DCHECK(proxy_->IsImplThread()); 1040 DCHECK(proxy_->IsImplThread());
1041 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1041 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1042 } 1042 }
1043 1043
1044 if (needs_commit) 1044 if (needs_commit)
1045 client_->SetNeedsCommitOnImplThread(); 1045 client_->SetNeedsCommitOnImplThread();
1046 } 1046 }
1047 1047
1048 void LayerTreeHostImpl::SetExternalDrawConstraints(
1049 const gfx::Transform& transform,
1050 gfx::Rect viewport) {
1051 external_transform_ = transform;
1052 external_viewport_ = viewport;
1053 }
1054
1048 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) { 1055 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) {
1049 client_->SetNeedsRedrawRectOnImplThread(damage_rect); 1056 client_->SetNeedsRedrawRectOnImplThread(damage_rect);
1050 } 1057 }
1051 1058
1052 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, 1059 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase,
1053 base::TimeDelta interval) { 1060 base::TimeDelta interval) {
1054 client_->OnVSyncParametersChanged(timebase, interval); 1061 client_->OnVSyncParametersChanged(timebase, interval);
1055 } 1062 }
1056 1063
1057 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) { 1064 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 renderer_->SwapBuffers(frame.latency_info); 1211 renderer_->SwapBuffers(frame.latency_info);
1205 active_tree_->ClearLatencyInfo(); 1212 active_tree_->ClearLatencyInfo();
1206 return true; 1213 return true;
1207 } 1214 }
1208 1215
1209 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { 1216 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
1210 if (output_surface_) 1217 if (output_surface_)
1211 output_surface_->SetNeedsBeginFrame(enable); 1218 output_surface_->SetNeedsBeginFrame(enable);
1212 } 1219 }
1213 1220
1214 gfx::Size LayerTreeHostImpl::DeviceViewportSize() const {
1215 return device_viewport_size();
1216 }
1217
1218 float LayerTreeHostImpl::DeviceScaleFactor() const { 1221 float LayerTreeHostImpl::DeviceScaleFactor() const {
1219 return device_scale_factor_; 1222 return device_scale_factor_;
1220 } 1223 }
1221 1224
1222 gfx::SizeF LayerTreeHostImpl::VisibleViewportSize() const { 1225 gfx::SizeF LayerTreeHostImpl::VisibleViewportSize() const {
1223 gfx::SizeF dip_size = 1226 gfx::SizeF dip_size =
1224 gfx::ScaleSize(DeviceViewportSize(), 1.f / device_scale_factor()); 1227 gfx::ScaleSize(device_viewport_size(), 1.f / device_scale_factor());
1225 1228
1226 // The clip layer should be used if non-overlay scrollbars may exist since 1229 // The clip layer should be used if non-overlay scrollbars may exist since
1227 // it adjusts for them. 1230 // it adjusts for them.
1228 LayerImpl* clip_layer = active_tree_->RootClipLayer(); 1231 LayerImpl* clip_layer = active_tree_->RootClipLayer();
1229 if (!Settings().solid_color_scrollbars && clip_layer && 1232 if (!Settings().solid_color_scrollbars && clip_layer &&
1230 clip_layer->masks_to_bounds()) 1233 clip_layer->masks_to_bounds())
1231 dip_size = clip_layer->bounds(); 1234 dip_size = clip_layer->bounds();
1232 1235
1233 float top_offset = 1236 float top_offset =
1234 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; 1237 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 return; 1529 return;
1527 device_scale_factor_ = device_scale_factor; 1530 device_scale_factor_ = device_scale_factor;
1528 1531
1529 if (renderer_) 1532 if (renderer_)
1530 renderer_->ViewportChanged(); 1533 renderer_->ViewportChanged();
1531 1534
1532 UpdateMaxScrollOffset(); 1535 UpdateMaxScrollOffset();
1533 SetFullRootLayerDamage(); 1536 SetFullRootLayerDamage();
1534 } 1537 }
1535 1538
1539 gfx::Rect LayerTreeHostImpl::DeviceViewport() const {
1540 if (external_viewport_.IsEmpty())
1541 return gfx::Rect(device_viewport_size_);
1542
1543 return external_viewport_;
1544 }
1545
1546 const gfx::Transform& LayerTreeHostImpl::DeviceTransform() const {
1547 return external_transform_;
1548 }
1549
1536 void LayerTreeHostImpl::UpdateMaxScrollOffset() { 1550 void LayerTreeHostImpl::UpdateMaxScrollOffset() {
1537 active_tree_->UpdateMaxScrollOffset(); 1551 active_tree_->UpdateMaxScrollOffset();
1538 } 1552 }
1539 1553
1540 void LayerTreeHostImpl::DidChangeTopControlsPosition() { 1554 void LayerTreeHostImpl::DidChangeTopControlsPosition() {
1541 client_->SetNeedsRedrawOnImplThread(); 1555 client_->SetNeedsRedrawOnImplThread();
1542 active_tree_->set_needs_update_draw_properties(); 1556 active_tree_->set_needs_update_draw_properties();
1543 SetFullRootLayerDamage(); 1557 SetFullRootLayerDamage();
1544 } 1558 }
1545 1559
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 } 2267 }
2254 2268
2255 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2269 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2256 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2270 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2257 paint_time_counter_->ClearHistory(); 2271 paint_time_counter_->ClearHistory();
2258 2272
2259 debug_state_ = debug_state; 2273 debug_state_ = debug_state;
2260 } 2274 }
2261 2275
2262 } // namespace cc 2276 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698