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

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: Style 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 return SynchronousCompositor::Frame(); 130 return SynchronousCompositor::Frame();
131 } 131 }
132 132
133 ProcessCommonParams(common_renderer_params); 133 ProcessCommonParams(common_renderer_params);
134 134
135 if (!compositor_frame)
136 return SynchronousCompositor::Frame();
137
135 return ProcessHardwareFrame(compositor_frame_sink_id, 138 return ProcessHardwareFrame(compositor_frame_sink_id,
136 std::move(compositor_frame)); 139 std::move(*compositor_frame));
137 } 140 }
138 141
139 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame( 142 SynchronousCompositor::Frame SynchronousCompositorHost::ProcessHardwareFrame(
140 uint32_t compositor_frame_sink_id, 143 uint32_t compositor_frame_sink_id,
141 cc::CompositorFrame compositor_frame) { 144 cc::CompositorFrame compositor_frame) {
142 SynchronousCompositor::Frame frame; 145 SynchronousCompositor::Frame frame;
143 frame.frame.reset(new cc::CompositorFrame); 146 frame.frame.reset(new cc::CompositorFrame);
144 frame.compositor_frame_sink_id = compositor_frame_sink_id; 147 frame.compositor_frame_sink_id = compositor_frame_sink_id;
145 *frame.frame = std::move(compositor_frame); 148 *frame.frame = std::move(compositor_frame);
146 if (!frame.frame->delegated_frame_data) { 149 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; 150 return frame;
154 } 151 }
155 152
156 void SynchronousCompositorHost::UpdateFrameMetaData( 153 void SynchronousCompositorHost::UpdateFrameMetaData(
157 cc::CompositorFrameMetadata frame_metadata) { 154 cc::CompositorFrameMetadata frame_metadata) {
158 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata)); 155 rwhva_->SynchronousFrameMetadata(std::move(frame_metadata));
159 } 156 }
160 157
161 SynchronousCompositorBrowserFilter* SynchronousCompositorHost::GetFilter() { 158 SynchronousCompositorBrowserFilter* SynchronousCompositorHost::GetFilter() {
162 return static_cast<RenderProcessHostImpl*>( 159 return static_cast<RenderProcessHostImpl*>(
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (params.page_scale_factor) { 412 if (params.page_scale_factor) {
416 client_->UpdateRootLayerState( 413 client_->UpdateRootLayerState(
417 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset), 414 this, gfx::ScrollOffsetToVector2dF(params.total_scroll_offset),
418 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset), 415 gfx::ScrollOffsetToVector2dF(params.max_scroll_offset),
419 params.scrollable_size, params.page_scale_factor, 416 params.scrollable_size, params.page_scale_factor,
420 params.min_page_scale_factor, params.max_page_scale_factor); 417 params.min_page_scale_factor, params.max_page_scale_factor);
421 } 418 }
422 } 419 }
423 420
424 } // namespace content 421 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/synchronous_compositor_browser_filter.cc ('k') | content/common/android/sync_compositor_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698