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

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: Using base::Optional instead of boolean 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
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 base::Optional<cc::CompositorFrame> compositor_frame;
125 SyncCompositorCommonRendererParams common_renderer_params; 125 SyncCompositorCommonRendererParams common_renderer_params;
126 126
127 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw( 127 if (!sender_->Send(new SyncCompositorMsg_DemandDrawHw(
128 routing_id_, params, &common_renderer_params, 128 routing_id_, params, &common_renderer_params,
129 &compositor_frame_sink_id, &compositor_frame))) { 129 &compositor_frame_sink_id, &compositor_frame)) ||
130 !compositor_frame) {
boliu 2016/10/27 19:52:15 not quite the same. ProcessHardwareFrame can be sk
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,
136 std::move(compositor_frame)); 137 std::move(*compositor_frame));
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) {
142 SynchronousCompositor::Frame frame; 143 SynchronousCompositor::Frame frame;
143 frame.frame.reset(new cc::CompositorFrame); 144 frame.frame.reset(new cc::CompositorFrame);
144 frame.compositor_frame_sink_id = compositor_frame_sink_id; 145 frame.compositor_frame_sink_id = compositor_frame_sink_id;
145 *frame.frame = std::move(compositor_frame); 146 *frame.frame = std::move(compositor_frame);
146 if (!frame.frame->delegated_frame_data) { 147 UpdateFrameMetaData(frame.frame->metadata.Clone());
147 // This can happen if compositor did not swap in this draw.
148 frame.frame.reset();
149 }
150 if (frame.frame) {
151 UpdateFrameMetaData(frame.frame->metadata.Clone());
152 }
153 return frame; 148 return frame;
154 } 149 }
155 150
156 void SynchronousCompositorHost::UpdateFrameMetaData( 151 void SynchronousCompositorHost::UpdateFrameMetaData(
157 cc::CompositorFrameMetadata frame_metadata) { 152 cc::CompositorFrameMetadata frame_metadata) {
158 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); 153 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata));
159 } 154 }
160 155
161 SynchronousCompositorBrowserFilter* SynchronousCompositorHost::GetFilter() { 156 SynchronousCompositorBrowserFilter* SynchronousCompositorHost::GetFilter() {
162 return static_cast<RenderProcessHostImpl*>( 157 return static_cast<RenderProcessHostImpl*>(
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (params.page_scale_factor) { 410 if (params.page_scale_factor) {
416 client_->UpdateRootLayerState( 411 client_->UpdateRootLayerState(
417 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), 412 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset),
418 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), 413 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset),
419 params.scrollable_size, params.page_scale_factor, 414 params.scrollable_size, params.page_scale_factor,
420 params.min_page_scale_factor, params.max_page_scale_factor); 415 params.min_page_scale_factor, params.max_page_scale_factor);
421 } 416 }
422 } 417 }
423 418
424 } // namespace content 419 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698