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

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: Turn on fuzzy comparator for new SoftwareRenderer 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1033 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1034 } else { 1034 } else {
1035 DCHECK(proxy_->IsImplThread()); 1035 DCHECK(proxy_->IsImplThread());
1036 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1036 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1037 } 1037 }
1038 1038
1039 if (needs_commit) 1039 if (needs_commit)
1040 client_->SetNeedsCommitOnImplThread(); 1040 client_->SetNeedsCommitOnImplThread();
1041 } 1041 }
1042 1042
1043 void LayerTreeHostImpl::SetExternalDrawConstraints(
1044 const gfx::Transform& transform,
1045 gfx::Rect viewport) {
1046 external_transform_ = transform;
1047 external_viewport_ = viewport;
1048 }
1049
1043 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) { 1050 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) {
1044 client_->SetNeedsRedrawRectOnImplThread(damage_rect); 1051 client_->SetNeedsRedrawRectOnImplThread(damage_rect);
1045 } 1052 }
1046 1053
1047 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, 1054 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase,
1048 base::TimeDelta interval) { 1055 base::TimeDelta interval) {
1049 client_->OnVSyncParametersChanged(timebase, interval); 1056 client_->OnVSyncParametersChanged(timebase, interval);
1050 } 1057 }
1051 1058
1052 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) { 1059 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 renderer_->SwapBuffers(frame.latency_info); 1221 renderer_->SwapBuffers(frame.latency_info);
1215 active_tree_->ClearLatencyInfo(); 1222 active_tree_->ClearLatencyInfo();
1216 return true; 1223 return true;
1217 } 1224 }
1218 1225
1219 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { 1226 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
1220 if (output_surface_) 1227 if (output_surface_)
1221 output_surface_->SetNeedsBeginFrame(enable); 1228 output_surface_->SetNeedsBeginFrame(enable);
1222 } 1229 }
1223 1230
1224 gfx::Size LayerTreeHostImpl::DeviceViewportSize() const {
1225 return device_viewport_size();
1226 }
1227
1228 float LayerTreeHostImpl::DeviceScaleFactor() const { 1231 float LayerTreeHostImpl::DeviceScaleFactor() const {
1229 return device_scale_factor_; 1232 return device_scale_factor_;
1230 } 1233 }
1231 1234
1232 gfx::SizeF LayerTreeHostImpl::VisibleViewportSize() const { 1235 gfx::SizeF LayerTreeHostImpl::VisibleViewportSize() const {
1233 gfx::SizeF dip_size = 1236 gfx::SizeF dip_size =
1234 gfx::ScaleSize(DeviceViewportSize(), 1.f / device_scale_factor()); 1237 gfx::ScaleSize(device_viewport_size(), 1.f / device_scale_factor());
1235 1238
1236 // The clip layer should be used if non-overlay scrollbars may exist since 1239 // The clip layer should be used if non-overlay scrollbars may exist since
1237 // it adjusts for them. 1240 // it adjusts for them.
1238 LayerImpl* clip_layer = active_tree_->RootClipLayer(); 1241 LayerImpl* clip_layer = active_tree_->RootClipLayer();
1239 if (!Settings().solid_color_scrollbars && clip_layer && 1242 if (!Settings().solid_color_scrollbars && clip_layer &&
1240 clip_layer->masks_to_bounds()) 1243 clip_layer->masks_to_bounds())
1241 dip_size = clip_layer->bounds(); 1244 dip_size = clip_layer->bounds();
1242 1245
1243 float top_offset = 1246 float top_offset =
1244 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; 1247 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 return; 1549 return;
1547 device_scale_factor_ = device_scale_factor; 1550 device_scale_factor_ = device_scale_factor;
1548 1551
1549 if (renderer_) 1552 if (renderer_)
1550 renderer_->ViewportChanged(); 1553 renderer_->ViewportChanged();
1551 1554
1552 UpdateMaxScrollOffset(); 1555 UpdateMaxScrollOffset();
1553 SetFullRootLayerDamage(); 1556 SetFullRootLayerDamage();
1554 } 1557 }
1555 1558
1559 gfx::Rect LayerTreeHostImpl::DeviceViewport() const {
1560 if (external_viewport_.IsEmpty())
1561 return gfx::Rect(device_viewport_size_);
1562
1563 return external_viewport_;
1564 }
1565
1566 const gfx::Transform& LayerTreeHostImpl::DeviceTransform() const {
1567 return external_transform_;
1568 }
1569
1556 void LayerTreeHostImpl::UpdateMaxScrollOffset() { 1570 void LayerTreeHostImpl::UpdateMaxScrollOffset() {
1557 active_tree_->UpdateMaxScrollOffset(); 1571 active_tree_->UpdateMaxScrollOffset();
1558 } 1572 }
1559 1573
1560 void LayerTreeHostImpl::DidChangeTopControlsPosition() { 1574 void LayerTreeHostImpl::DidChangeTopControlsPosition() {
1561 client_->SetNeedsRedrawOnImplThread(); 1575 client_->SetNeedsRedrawOnImplThread();
1562 active_tree_->set_needs_update_draw_properties(); 1576 active_tree_->set_needs_update_draw_properties();
1563 SetFullRootLayerDamage(); 1577 SetFullRootLayerDamage();
1564 } 1578 }
1565 1579
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 } 2276 }
2263 2277
2264 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2278 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2265 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2279 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2266 paint_time_counter_->ClearHistory(); 2280 paint_time_counter_->ClearHistory();
2267 2281
2268 debug_state_ = debug_state; 2282 debug_state_ = debug_state;
2269 } 2283 }
2270 2284
2271 } // namespace cc 2285 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698