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

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

Issue 16304003: Unified OutputSurface::SwapBuffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to 205473 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 device_viewport_damage_rect.Union(viewport_damage_rect_); 926 device_viewport_damage_rect.Union(viewport_damage_rect_);
927 viewport_damage_rect_ = gfx::Rect(); 927 viewport_damage_rect_ = gfx::Rect();
928 928
929 active_tree_->root_layer()->render_surface()->damage_tracker()-> 929 active_tree_->root_layer()->render_surface()->damage_tracker()->
930 AddDamageNextUpdate(device_viewport_damage_rect); 930 AddDamageNextUpdate(device_viewport_damage_rect);
931 } 931 }
932 932
933 if (!CalculateRenderPasses(frame)) 933 if (!CalculateRenderPasses(frame))
934 return false; 934 return false;
935 935
936 frame->latency_info = active_tree_->GetLatencyInfo();
937
938 // If we return true, then we expect DrawLayers() to be called before this 936 // If we return true, then we expect DrawLayers() to be called before this
939 // function is called again. 937 // function is called again.
940 return true; 938 return true;
941 } 939 }
942 940
943 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( 941 void LayerTreeHostImpl::EnforceManagedMemoryPolicy(
944 const ManagedMemoryPolicy& policy) { 942 const ManagedMemoryPolicy& policy) {
945 943
946 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread( 944 bool evicted_resources = client_->ReduceContentsTextureMemoryOnImplThread(
947 visible_ ? policy.bytes_limit_when_visible 945 visible_ ? policy.bytes_limit_when_visible
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1059
1062 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, 1060 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase,
1063 base::TimeDelta interval) { 1061 base::TimeDelta interval) {
1064 client_->OnVSyncParametersChanged(timebase, interval); 1062 client_->OnVSyncParametersChanged(timebase, interval);
1065 } 1063 }
1066 1064
1067 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) { 1065 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) {
1068 client_->BeginFrameOnImplThread(frame_time); 1066 client_->BeginFrameOnImplThread(frame_time);
1069 } 1067 }
1070 1068
1071 void LayerTreeHostImpl::OnSendFrameToParentCompositorAck( 1069 void LayerTreeHostImpl::OnSwapBuffersComplete(
1072 const CompositorFrameAck& ack) { 1070 const CompositorFrameAck* ack) {
1073 if (!renderer_)
1074 return;
1075
1076 // TODO(piman): We may need to do some validation on this ack before 1071 // TODO(piman): We may need to do some validation on this ack before
1077 // processing it. 1072 // processing it.
1078 renderer_->ReceiveCompositorFrameAck(ack); 1073 if (ack && renderer_)
1074 renderer_->ReceiveSwapBuffersAck(*ack);
1079 1075
1080 // When using compositor frame data, the ack doubles as a swap complete ack. 1076 client_->OnSwapBuffersCompleteOnImplThread();
1081 OnSwapBuffersComplete();
1082 } 1077 }
1083 1078
1084 void LayerTreeHostImpl::OnCanDrawStateChangedForTree() { 1079 void LayerTreeHostImpl::OnCanDrawStateChangedForTree() {
1085 client_->OnCanDrawStateChanged(CanDraw()); 1080 client_->OnCanDrawStateChanged(CanDraw());
1086 } 1081 }
1087 1082
1088 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { 1083 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
1089 CompositorFrameMetadata metadata; 1084 CompositorFrameMetadata metadata;
1090 metadata.device_scale_factor = device_scale_factor_; 1085 metadata.device_scale_factor = device_scale_factor_;
1091 metadata.page_scale_factor = active_tree_->total_page_scale_factor(); 1086 metadata.page_scale_factor = active_tree_->total_page_scale_factor();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 return renderer_ && renderer_->IsContextLost(); 1218 return renderer_ && renderer_->IsContextLost();
1224 } 1219 }
1225 1220
1226 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { 1221 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const {
1227 return renderer_->Capabilities(); 1222 return renderer_->Capabilities();
1228 } 1223 }
1229 1224
1230 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { 1225 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
1231 if (frame.has_no_damage) 1226 if (frame.has_no_damage)
1232 return false; 1227 return false;
1233 renderer_->SwapBuffers(frame.latency_info); 1228 renderer_->SwapBuffers();
1234 active_tree_->ClearLatencyInfo(); 1229 active_tree_->ClearLatencyInfo();
1235 return true; 1230 return true;
1236 } 1231 }
1237 1232
1238 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { 1233 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
1239 if (output_surface_) 1234 if (output_surface_)
1240 output_surface_->SetNeedsBeginFrame(enable); 1235 output_surface_->SetNeedsBeginFrame(enable);
1241 } 1236 }
1242 1237
1243 float LayerTreeHostImpl::DeviceScaleFactor() const { 1238 float LayerTreeHostImpl::DeviceScaleFactor() const {
(...skipping 22 matching lines...) Expand all
1266 } 1261 }
1267 1262
1268 void LayerTreeHostImpl::DidLoseOutputSurface() { 1263 void LayerTreeHostImpl::DidLoseOutputSurface() {
1269 // TODO(jamesr): The renderer_ check is needed to make some of the 1264 // TODO(jamesr): The renderer_ check is needed to make some of the
1270 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or 1265 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or
1271 // important) in production. We should adjust the test to not need this. 1266 // important) in production. We should adjust the test to not need this.
1272 if (renderer_) 1267 if (renderer_)
1273 client_->DidLoseOutputSurfaceOnImplThread(); 1268 client_->DidLoseOutputSurfaceOnImplThread();
1274 } 1269 }
1275 1270
1276 void LayerTreeHostImpl::OnSwapBuffersComplete() {
1277 client_->OnSwapBuffersCompleteOnImplThread();
1278 }
1279
1280 void LayerTreeHostImpl::Readback(void* pixels, 1271 void LayerTreeHostImpl::Readback(void* pixels,
1281 gfx::Rect rect_in_device_viewport) { 1272 gfx::Rect rect_in_device_viewport) {
1282 DCHECK(renderer_); 1273 DCHECK(renderer_);
1283 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); 1274 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport);
1284 } 1275 }
1285 1276
1286 bool LayerTreeHostImpl::HaveRootScrollLayer() const { 1277 bool LayerTreeHostImpl::HaveRootScrollLayer() const {
1287 return !!RootScrollLayer(); 1278 return !!RootScrollLayer();
1288 } 1279 }
1289 1280
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 !is_deferred_init) { 1467 !is_deferred_init) {
1477 // TODO(joth): Defer creating the Renderer too, until GL is initialized. 1468 // TODO(joth): Defer creating the Renderer too, until GL is initialized.
1478 // See http://crbug.com/230197 1469 // See http://crbug.com/230197
1479 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); 1470 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL);
1480 } else { 1471 } else {
1481 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( 1472 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create(
1482 output_surface.get(), settings_.highp_threshold_min); 1473 output_surface.get(), settings_.highp_threshold_min);
1483 if (!resource_provider) 1474 if (!resource_provider)
1484 return false; 1475 return false;
1485 1476
1486 if (output_surface->capabilities().has_parent_compositor) { 1477 if (output_surface->capabilities().delegated_rendering) {
1487 renderer_ = DelegatingRenderer::Create(this, output_surface.get(), 1478 renderer_ = DelegatingRenderer::Create(this, output_surface.get(),
1488 resource_provider.get()); 1479 resource_provider.get());
1489 } else if (output_surface->context3d()) { 1480 } else if (output_surface->context3d()) {
1490 renderer_ = GLRenderer::Create(this, 1481 renderer_ = GLRenderer::Create(this,
1491 output_surface.get(), 1482 output_surface.get(),
1492 resource_provider.get(), 1483 resource_provider.get(),
1493 settings_.highp_threshold_min, 1484 settings_.highp_threshold_min,
1494 settings_.force_direct_layer_drawing); 1485 settings_.force_direct_layer_drawing);
1495 } else if (output_surface->software_device()) { 1486 } else if (output_surface->software_device()) {
1496 renderer_ = SoftwareRenderer::Create(this, 1487 renderer_ = SoftwareRenderer::Create(this,
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 } 2308 }
2318 2309
2319 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2310 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2320 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2311 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2321 paint_time_counter_->ClearHistory(); 2312 paint_time_counter_->ClearHistory();
2322 2313
2323 debug_state_ = debug_state; 2314 debug_state_ = debug_state;
2324 } 2315 }
2325 2316
2326 } // namespace cc 2317 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698