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

Side by Side Diff: content/common/gpu/image_transport_surface.cc

Issue 797843005: Add support to delay sending SwapbufferAck as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add SwapBufferCallBack in Helper. Created 6 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/gpu/image_transport_surface.h" 5 #include "content/common/gpu/image_transport_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); 112 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
113 } 113 }
114 114
115 void ImageTransportHelper::SendUpdateVSyncParameters( 115 void ImageTransportHelper::SendUpdateVSyncParameters(
116 base::TimeTicks timebase, base::TimeDelta interval) { 116 base::TimeTicks timebase, base::TimeDelta interval) {
117 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(), 117 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(),
118 timebase, 118 timebase,
119 interval)); 119 interval));
120 } 120 }
121 121
122 void ImageTransportHelper::SwapBuffersCompleted( 122 void ImageTransportHelper::SwapBuffersCallBack() {
123 const std::vector<ui::LatencyInfo>& latency_info) { 123 for (size_t i = 0; i < latency_info_.size(); i++) {
124 stub_->SwapBuffersCompleted(latency_info); 124 latency_info_[i].AddLatencyNumber(
125 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
126 }
127
128 stub_->SwapBuffersCompleted(latency_info_);
129 latency_info_.clear();
125 } 130 }
126 131
127 void ImageTransportHelper::SetPreemptByFlag( 132 void ImageTransportHelper::SetPreemptByFlag(
128 scoped_refptr<gpu::PreemptionFlag> preemption_flag) { 133 scoped_refptr<gpu::PreemptionFlag> preemption_flag) {
129 stub_->channel()->SetPreemptByFlag(preemption_flag); 134 stub_->channel()->SetPreemptByFlag(preemption_flag);
130 } 135 }
131 136
132 bool ImageTransportHelper::MakeCurrent() { 137 bool ImageTransportHelper::MakeCurrent() {
133 gpu::gles2::GLES2Decoder* decoder = Decoder(); 138 gpu::gles2::GLES2Decoder* decoder = Decoder();
134 if (!decoder) 139 if (!decoder)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 surface_->OnResize(size, scale_factor); 177 surface_->OnResize(size, scale_factor);
173 178
174 #if defined(OS_ANDROID) 179 #if defined(OS_ANDROID)
175 manager_->gpu_memory_manager()->ScheduleManage( 180 manager_->gpu_memory_manager()->ScheduleManage(
176 GpuMemoryManager::kScheduleManageNow); 181 GpuMemoryManager::kScheduleManageNow);
177 #endif 182 #endif
178 } 183 }
179 184
180 void ImageTransportHelper::SetLatencyInfo( 185 void ImageTransportHelper::SetLatencyInfo(
181 const std::vector<ui::LatencyInfo>& latency_info) { 186 const std::vector<ui::LatencyInfo>& latency_info) {
182 surface_->SetLatencyInfo(latency_info); 187 for (size_t i = 0; i < latency_info.size(); i++)
piman 2014/12/22 20:53:15 Why this change? I don't understand... It will bre
kalyank 2014/12/23 09:12:32 ImageTransportSurfaceAndroid inherits base::Suppor
kalyank 2014/12/23 11:22:42 Added ImageTransportHelperAndroid, which will be u
188 latency_info_.push_back(latency_info[i]);
183 } 189 }
184 190
185 PassThroughImageTransportSurface::PassThroughImageTransportSurface( 191 PassThroughImageTransportSurface::PassThroughImageTransportSurface(
186 GpuChannelManager* manager, 192 GpuChannelManager* manager,
187 GpuCommandBufferStub* stub, 193 GpuCommandBufferStub* stub,
188 gfx::GLSurface* surface) 194 gfx::GLSurface* surface)
189 : GLSurfaceAdapter(surface), 195 : GLSurfaceAdapter(surface),
190 did_set_swap_interval_(false) { 196 did_set_swap_interval_(false) {
191 helper_.reset(new ImageTransportHelper(this, 197 helper_.reset(new ImageTransportHelper(this,
192 manager, 198 manager,
193 stub, 199 stub,
194 gfx::kNullPluginWindow)); 200 gfx::kNullPluginWindow));
195 } 201 }
196 202
197 bool PassThroughImageTransportSurface::Initialize() { 203 bool PassThroughImageTransportSurface::Initialize() {
198 // The surface is assumed to have already been initialized. 204 // The surface is assumed to have already been initialized.
199 return helper_->Initialize(); 205 return helper_->Initialize();
200 } 206 }
201 207
202 void PassThroughImageTransportSurface::Destroy() { 208 void PassThroughImageTransportSurface::Destroy() {
203 GLSurfaceAdapter::Destroy(); 209 GLSurfaceAdapter::Destroy();
204 } 210 }
205 211
206 void PassThroughImageTransportSurface::SetLatencyInfo( 212 void PassThroughImageTransportSurface::SetLatencyInfo(
207 const std::vector<ui::LatencyInfo>& latency_info) { 213 const std::vector<ui::LatencyInfo>& latency_info) {
208 for (size_t i = 0; i < latency_info.size(); i++) 214 helper_->SetLatencyInfo(latency_info);
209 latency_info_.push_back(latency_info[i]);
210 } 215 }
211 216
212 bool PassThroughImageTransportSurface::SwapBuffers() { 217 bool PassThroughImageTransportSurface::SwapBuffers() {
213 // GetVsyncValues before SwapBuffers to work around Mali driver bug: 218 // GetVsyncValues before SwapBuffers to work around Mali driver bug:
214 // crbug.com/223558. 219 // crbug.com/223558.
215 SendVSyncUpdateIfAvailable(); 220 SendVSyncUpdateIfAvailable();
216 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); 221 // We use WeakPtr here to avoid manual management of life time of an instance
217 for (size_t i = 0; i < latency_info_.size(); i++) { 222 // of this class. Callback will not be called once the instance of this class
218 latency_info_[i].AddLatencyNumber( 223 // is destroyed. However, this also means that the callback can be run on
219 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); 224 // GPUMainThread only.
220 } 225 return gfx::GLSurfaceAdapter::SwapBuffersAsync(
221 226 base::Bind(&ImageTransportHelper::SwapBuffersCallBack,
222 helper_->SwapBuffersCompleted(latency_info_); 227 helper_->AsWeakPtr()));
223 latency_info_.clear();
224 return result;
225 } 228 }
226 229
227 bool PassThroughImageTransportSurface::PostSubBuffer( 230 bool PassThroughImageTransportSurface::PostSubBuffer(
228 int x, int y, int width, int height) { 231 int x, int y, int width, int height) {
229 SendVSyncUpdateIfAvailable(); 232 SendVSyncUpdateIfAvailable();
230 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); 233 // We use WeakPtr here to avoid manual management of life time of an instance
231 for (size_t i = 0; i < latency_info_.size(); i++) { 234 // of this class. Callback will not be called once the instance of this class
232 latency_info_[i].AddLatencyNumber( 235 // is destroyed. However, this also means that the callback can be run on
233 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); 236 // GPUMainThread only.
234 } 237 return gfx::GLSurfaceAdapter::PostSubBufferAsync(x, y, width, height,
235 238 base::Bind(&ImageTransportHelper::SwapBuffersCallBack,
236 helper_->SwapBuffersCompleted(latency_info_); 239 helper_->AsWeakPtr()));
237 latency_info_.clear();
238 return result;
239 } 240 }
240 241
241 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { 242 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
242 if (!did_set_swap_interval_) { 243 if (!did_set_swap_interval_) {
243 ImageTransportHelper::SetSwapInterval(context); 244 ImageTransportHelper::SetSwapInterval(context);
244 did_set_swap_interval_ = true; 245 did_set_swap_interval_ = true;
245 } 246 }
246 return true; 247 return true;
247 } 248 }
248 249
(...skipping 22 matching lines...) Expand all
271 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { 272 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() {
272 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); 273 gfx::VSyncProvider* vsync_provider = GetVSyncProvider();
273 if (vsync_provider) { 274 if (vsync_provider) {
274 vsync_provider->GetVSyncParameters( 275 vsync_provider->GetVSyncParameters(
275 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, 276 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters,
276 helper_->AsWeakPtr())); 277 helper_->AsWeakPtr()));
277 } 278 }
278 } 279 }
279 280
280 } // namespace content 281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698