OLD | NEW |
---|---|
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/texture_image_transport_surface.h" | 5 #include "content/common/gpu/texture_image_transport_surface.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 bool TextureImageTransportSurface::SwapBuffers() { | 225 bool TextureImageTransportSurface::SwapBuffers() { |
226 DCHECK(backbuffer_suggested_allocation_); | 226 DCHECK(backbuffer_suggested_allocation_); |
227 if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_) | 227 if (!frontbuffer_suggested_allocation_ || !frontbuffer_is_protected_) |
228 return true; | 228 return true; |
229 if (!parent_stub_) { | 229 if (!parent_stub_) { |
230 LOG(ERROR) << "SwapBuffers failed because no parent stub."; | 230 LOG(ERROR) << "SwapBuffers failed because no parent stub."; |
231 return false; | 231 return false; |
232 } | 232 } |
233 | 233 |
234 glFlush(); | 234 glFlush(); |
235 front_ = back(); | 235 previous_damage_rect_ = gfx::Rect(textures_[back()].size); |
236 previous_damage_rect_ = gfx::Rect(textures_[front()].size); | |
237 | |
238 DCHECK(textures_[front()].client_id != 0); | |
239 | 236 |
240 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 237 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
241 params.surface_handle = textures_[front()].client_id; | 238 params.surface_handle = textures_[back()].client_id; |
242 params.protection_state_id = protection_state_id_; | 239 params.protection_state_id = protection_state_id_; |
243 params.skip_ack = false; | 240 params.skip_ack = false; |
244 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 241 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
245 helper_->SetScheduled(false); | 242 helper_->SetScheduled(false); |
246 return true; | 243 return true; |
247 } | 244 } |
248 | 245 |
249 bool TextureImageTransportSurface::PostSubBuffer( | 246 bool TextureImageTransportSurface::PostSubBuffer( |
250 int x, int y, int width, int height) { | 247 int x, int y, int width, int height) { |
251 DCHECK(backbuffer_suggested_allocation_); | 248 DCHECK(backbuffer_suggested_allocation_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, region_to_copy.x(), | 288 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, region_to_copy.x(), |
292 region_to_copy.y(), region_to_copy.x(), region_to_copy.y(), | 289 region_to_copy.y(), region_to_copy.x(), region_to_copy.y(), |
293 region_to_copy.width(), region_to_copy.height()); | 290 region_to_copy.width(), region_to_copy.height()); |
294 } | 291 } |
295 } | 292 } |
296 } else { | 293 } else { |
297 DCHECK(new_damage_rect == gfx::Rect(expected_size)); | 294 DCHECK(new_damage_rect == gfx::Rect(expected_size)); |
298 } | 295 } |
299 | 296 |
300 glFlush(); | 297 glFlush(); |
301 front_ = back(); | |
302 previous_damage_rect_ = new_damage_rect; | 298 previous_damage_rect_ = new_damage_rect; |
303 | 299 |
304 DCHECK(textures_[front()].client_id); | |
305 | |
306 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 300 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
307 params.surface_handle = textures_[front()].client_id; | 301 params.surface_handle = textures_[back()].client_id; |
308 params.x = x; | 302 params.x = x; |
309 params.y = y; | 303 params.y = y; |
310 params.width = width; | 304 params.width = width; |
311 params.height = height; | 305 params.height = height; |
312 params.protection_state_id = protection_state_id_; | 306 params.protection_state_id = protection_state_id_; |
313 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 307 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
314 helper_->SetScheduled(false); | 308 helper_->SetScheduled(false); |
315 return true; | 309 return true; |
316 } | 310 } |
317 | 311 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 348 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
355 params.surface_handle = textures_[front()].client_id; | 349 params.surface_handle = textures_[front()].client_id; |
356 params.protection_state_id = protection_state_id_; | 350 params.protection_state_id = protection_state_id_; |
357 params.skip_ack = true; | 351 params.skip_ack = true; |
358 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 352 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
359 } | 353 } |
360 } | 354 } |
361 | 355 |
362 void TextureImageTransportSurface::OnBufferPresented(uint32 sync_point) { | 356 void TextureImageTransportSurface::OnBufferPresented(uint32 sync_point) { |
363 if (sync_point == 0) { | 357 if (sync_point == 0) { |
364 BufferPresentedImpl(); | 358 // We could do this many times in a row, so play it safe with the damage. |
359 // No real performance hit because we're typically fast tracking resize | |
360 // where damage tracking is a no-op. | |
361 previous_damage_rect_ = gfx::Rect(textures_[front_].size); | |
362 AttachBackTextureToFBO(); | |
363 helper_->SetScheduled(true); | |
365 } else { | 364 } else { |
366 helper_->manager()->sync_point_manager()->AddSyncPointCallback( | 365 helper_->manager()->sync_point_manager()->AddSyncPointCallback( |
367 sync_point, | 366 sync_point, |
368 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, | 367 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, |
369 this->AsWeakPtr())); | 368 this->AsWeakPtr())); |
370 } | 369 } |
371 } | 370 } |
372 | 371 |
373 void TextureImageTransportSurface::BufferPresentedImpl() { | 372 void TextureImageTransportSurface::BufferPresentedImpl() { |
373 front_ = back(); | |
piman
2012/07/31 23:42:17
Mmh, is it ok to move this here wrt e.g. dropping
jonathan.backer
2012/08/01 17:22:43
Done.
| |
374 DCHECK(textures_[front()].client_id); | |
375 | |
374 // We're relying on the fact that the parent context is | 376 // We're relying on the fact that the parent context is |
375 // finished with it's context when it inserts the sync point that | 377 // finished with it's context when it inserts the sync point that |
376 // triggers this callback. | 378 // triggers this callback. |
377 if (helper_->MakeCurrent()) { | 379 if (helper_->MakeCurrent()) { |
378 if (textures_[front()].size != textures_[back()].size || | 380 if (textures_[front()].size != textures_[back()].size || |
379 !textures_[back()].info->service_id() || | 381 !textures_[back()].info->service_id() || |
380 !textures_[back()].sent_to_client) { | 382 !textures_[back()].sent_to_client) { |
381 // We may get an ACK from a stale swap just to reschedule. In that case, | 383 // We may get an ACK from a stale swap just to reschedule. In that case, |
382 // we may not have a backbuffer suggestion and should not recreate one. | 384 // we may not have a backbuffer suggestion and should not recreate one. |
383 if (backbuffer_suggested_allocation_) | 385 if (backbuffer_suggested_allocation_) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 Texture& texture = textures_[i]; | 505 Texture& texture = textures_[i]; |
504 texture.info = NULL; | 506 texture.info = NULL; |
505 if (!texture.sent_to_client) | 507 if (!texture.sent_to_client) |
506 continue; | 508 continue; |
507 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 509 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
508 params.identifier = texture.client_id; | 510 params.identifier = texture.client_id; |
509 helper_->SendAcceleratedSurfaceRelease(params); | 511 helper_->SendAcceleratedSurfaceRelease(params); |
510 } | 512 } |
511 parent_stub_ = NULL; | 513 parent_stub_ = NULL; |
512 } | 514 } |
OLD | NEW |