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

Side by Side Diff: content/browser/android/synchronous_compositor_host.cc

Issue 2458743002: Switching to base::Optional<CompositorFrame> in Android's synchronous compositor IPC messages (Closed)
Patch Set: Created 4 years, 1 month 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 "content/browser/android/synchronous_compositor_host.h" 5 #include "content/browser/android/synchronous_compositor_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw( 116 SynchronousCompositor::Frame SynchronousCompositorHost::DemandDrawHw(
117 const gfx::Size& viewport_size, 117 const gfx::Size& viewport_size,
118 const gfx::Rect& viewport_rect_for_tile_priority, 118 const gfx::Rect& viewport_rect_for_tile_priority,
119 const gfx::Transform& transform_for_tile_priority) { 119 const gfx::Transform& transform_for_tile_priority) {
120 SyncCompositorDemandDrawHwParams params(viewport_size, 120 SyncCompositorDemandDrawHwParams params(viewport_size,
121 viewport_rect_for_tile_priority, 121 viewport_rect_for_tile_priority,
122 transform_for_tile_priority); 122 transform_for_tile_priority);
123 uint32_t compositor_frame_sink_id; 123 uint32_t compositor_frame_sink_id;
124 cc::CompositorFrame compositor_frame; 124 cc::CompositorFrame compositor_frame;
125 SyncCompositorCommonRendererParams common_renderer_params; 125 SyncCompositorCommonRendererParams common_renderer_params;
126 bool has_swapped;
boliu 2016/10/27 18:11:46 initialize to false
126 127
127 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( 128 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw(
128 routing_id_, params, &common_renderer_params, 129 routing_id_, params, &common_renderer_params,
129 &compositor_frame_sink_id, &compositor_frame))) { 130 &compositor_frame_sink_id, &compositor_frame, &has_swapped))) {
130 return SynchronousCompositor::Frame(); 131 return SynchronousCompositor::Frame();
131 } 132 }
132 133
133 ProcessCommonParams(common_renderer_params); 134 ProcessCommonParams(common_renderer_params);
134 135
135 return ProcessHardwareFrame(compositor_frame_sink_id, 136 return ProcessHardwareFrame(compositor_frame_sink_id,
boliu 2016/10/27 18:11:46 just return empty frame if false, rather than pass
136 std::move(compositor_frame)); 137 std::move(compositor_frame), has_swapped);
137 } 138 }
138 139
139 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame( 140 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame(
140 uint32_t compositor_frame_sink_id, 141 uint32_t compositor_frame_sink_id,
141 cc::CompositorFrame compositor_frame) { 142 cc::CompositorFrame compositor_frame,
143 bool has_swapped) {
142 SynchronousCompositor::Frame frame; 144 SynchronousCompositor::Frame frame;
143 frame.frame.reset(new cc::CompositorFrame); 145 frame.frame.reset(new cc::CompositorFrame);
144 frame.compositor_frame_sink_id = compositor_frame_sink_id; 146 frame.compositor_frame_sink_id = compositor_frame_sink_id;
145 *frame.frame = std::move(compositor_frame); 147 *frame.frame = std::move(compositor_frame);
146 if (!frame.frame->delegated_frame_data) { 148 if (has_swapped)
147 // This can happen if compositor did not swap in this draw. 149 UpdateFrameMetaData(frame.frame->metadata.Clone());
150 else
148 frame.frame.reset(); 151 frame.frame.reset();
149 }
150 if (frame.frame) {
151 UpdateFrameMetaData(frame.frame->metadata.Clone());
152 }
153 return frame; 152 return frame;
154 } 153 }
155 154
156 void SynchronousCompositorHost::UpdateFrameMetaData( 155 void SynchronousCompositorHost::UpdateFrameMetaData(
157 cc::CompositorFrameMetadata frame_metadata) { 156 cc::CompositorFrameMetadata frame_metadata) {
158 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); 157 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata));
159 } 158 }
160 159
161 SynchronousCompositorBrowserFilter* SynchronousCompositorHost::GetFilter() { 160 SynchronousCompositorBrowserFilter* SynchronousCompositorHost::GetFilter() {
162 return static_cast<RenderProcessHostImpl*>( 161 return static_cast<RenderProcessHostImpl*>(
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (params.page_scale_factor) { 414 if (params.page_scale_factor) {
416 client_->UpdateRootLayerState( 415 client_->UpdateRootLayerState(
417 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), 416 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset),
418 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), 417 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset),
419 params.scrollable_size, params.page_scale_factor, 418 params.scrollable_size, params.page_scale_factor,
420 params.min_page_scale_factor, params.max_page_scale_factor); 419 params.min_page_scale_factor, params.max_page_scale_factor);
421 } 420 }
422 } 421 }
423 422
424 } // namespace content 423 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698