Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 : fbo_id_(0), | 37 : fbo_id_(0), |
| 38 front_(0), | 38 front_(0), |
| 39 stub_destroyed_(false), | 39 stub_destroyed_(false), |
| 40 backbuffer_suggested_allocation_(true), | 40 backbuffer_suggested_allocation_(true), |
| 41 frontbuffer_suggested_allocation_(true), | 41 frontbuffer_suggested_allocation_(true), |
| 42 frontbuffer_is_protected_(true), | 42 frontbuffer_is_protected_(true), |
| 43 protection_state_id_(0), | 43 protection_state_id_(0), |
| 44 handle_(handle), | 44 handle_(handle), |
| 45 parent_stub_(NULL), | 45 parent_stub_(NULL), |
| 46 is_swap_buffers_pending_(false), | 46 is_swap_buffers_pending_(false), |
| 47 did_unschedule_(false) { | 47 did_unschedule_(false), |
| 48 did_flip_(false) { | |
| 48 helper_.reset(new ImageTransportHelper(this, | 49 helper_.reset(new ImageTransportHelper(this, |
| 49 manager, | 50 manager, |
| 50 stub, | 51 stub, |
| 51 gfx::kNullPluginWindow)); | 52 gfx::kNullPluginWindow)); |
| 52 } | 53 } |
| 53 | 54 |
| 54 TextureImageTransportSurface::~TextureImageTransportSurface() { | 55 TextureImageTransportSurface::~TextureImageTransportSurface() { |
| 55 DCHECK(stub_destroyed_); | 56 DCHECK(stub_destroyed_); |
| 56 Destroy(); | 57 Destroy(); |
| 57 } | 58 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 content::ScopedTextureBinder texture_binder(back_texture_service_id); | 315 content::ScopedTextureBinder texture_binder(back_texture_service_id); |
| 315 | 316 |
| 316 for (size_t i = 0; i < regions_to_copy.size(); ++i) { | 317 for (size_t i = 0; i < regions_to_copy.size(); ++i) { |
| 317 const gfx::Rect& region_to_copy = regions_to_copy[i]; | 318 const gfx::Rect& region_to_copy = regions_to_copy[i]; |
| 318 if (!region_to_copy.IsEmpty()) { | 319 if (!region_to_copy.IsEmpty()) { |
| 319 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, region_to_copy.x(), | 320 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, region_to_copy.x(), |
| 320 region_to_copy.y(), region_to_copy.x(), region_to_copy.y(), | 321 region_to_copy.y(), region_to_copy.x(), region_to_copy.y(), |
| 321 region_to_copy.width(), region_to_copy.height()); | 322 region_to_copy.width(), region_to_copy.height()); |
| 322 } | 323 } |
| 323 } | 324 } |
| 324 } else { | 325 } else if (!surfaces_same_size && did_flip_) { |
| 325 DCHECK(new_damage_rect == gfx::Rect(expected_size)); | 326 DCHECK(new_damage_rect == gfx::Rect(expected_size)); |
| 326 } | 327 } |
| 327 | 328 |
| 328 glFlush(); | 329 glFlush(); |
| 329 front_ = back(); | 330 front_ = back(); |
| 330 previous_damage_rect_ = new_damage_rect; | 331 previous_damage_rect_ = new_damage_rect; |
| 331 | 332 |
| 332 DCHECK(textures_[front()].client_id); | 333 DCHECK(textures_[front()].client_id); |
| 333 | 334 |
| 334 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 335 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 if (is_protected && textures_[front()].info->service_id() && | 383 if (is_protected && textures_[front()].info->service_id() && |
| 383 textures_[front()].sent_to_client) { | 384 textures_[front()].sent_to_client) { |
| 384 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 385 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 385 params.surface_handle = textures_[front()].client_id; | 386 params.surface_handle = textures_[front()].client_id; |
| 386 params.protection_state_id = protection_state_id_; | 387 params.protection_state_id = protection_state_id_; |
| 387 params.skip_ack = true; | 388 params.skip_ack = true; |
| 388 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 389 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 389 } | 390 } |
| 390 } | 391 } |
| 391 | 392 |
| 392 void TextureImageTransportSurface::OnBufferPresented(uint32 sync_point) { | 393 void TextureImageTransportSurface::OnBufferPresented(bool presented, |
| 394 uint32 sync_point) { | |
| 393 if (sync_point == 0) { | 395 if (sync_point == 0) { |
| 394 BufferPresentedImpl(); | 396 BufferPresentedImpl(presented); |
| 395 } else { | 397 } else { |
| 396 helper_->manager()->sync_point_manager()->AddSyncPointCallback( | 398 helper_->manager()->sync_point_manager()->AddSyncPointCallback( |
| 397 sync_point, | 399 sync_point, |
| 398 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, | 400 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, |
| 399 this->AsWeakPtr())); | 401 this->AsWeakPtr(), |
| 402 presented)); | |
| 400 } | 403 } |
| 401 } | 404 } |
| 402 | 405 |
| 403 void TextureImageTransportSurface::BufferPresentedImpl() { | 406 void TextureImageTransportSurface::BufferPresentedImpl(bool presented) { |
| 404 DCHECK(is_swap_buffers_pending_); | 407 DCHECK(is_swap_buffers_pending_); |
| 405 is_swap_buffers_pending_ = false; | 408 is_swap_buffers_pending_ = false; |
| 406 | 409 |
| 410 if (presented) { | |
| 411 // If we had not flipped, the two frame damage tracking is inconsistent. | |
| 412 // So conservatively take the whole frame. | |
| 413 if (!did_flip_) | |
| 414 previous_damage_rect_ = gfx::Rect(textures_[front()].size); | |
| 415 } else { | |
| 416 front_ = back(); | |
| 417 previous_damage_rect_ = gfx::Rect(0, 0, 0, 0); | |
| 418 } | |
|
piman
2012/10/17 21:26:32
Just a suggestion: would it help to move the 2 lin
jonathan.backer
2012/10/18 20:20:35
I was motivated by a comment you made on an earlie
| |
| 419 | |
| 420 did_flip_ = presented; | |
| 421 | |
| 407 // We're relying on the fact that the parent context is | 422 // We're relying on the fact that the parent context is |
| 408 // finished with it's context when it inserts the sync point that | 423 // finished with it's context when it inserts the sync point that |
| 409 // triggers this callback. | 424 // triggers this callback. |
| 410 if (helper_->MakeCurrent()) { | 425 if (helper_->MakeCurrent()) { |
| 411 if (textures_[front()].size != textures_[back()].size || | 426 if (textures_[front()].size != textures_[back()].size || |
| 412 !textures_[back()].info->service_id() || | 427 !textures_[back()].info->service_id() || |
| 413 !textures_[back()].sent_to_client) { | 428 !textures_[back()].sent_to_client) { |
| 414 // We may get an ACK from a stale swap just to reschedule. In that case, | 429 // We may get an ACK from a stale swap just to reschedule. In that case, |
| 415 // we may not have a backbuffer suggestion and should not recreate one. | 430 // we may not have a backbuffer suggestion and should not recreate one. |
| 416 if (backbuffer_suggested_allocation_) | 431 if (backbuffer_suggested_allocation_) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 Texture& texture = textures_[i]; | 554 Texture& texture = textures_[i]; |
| 540 texture.info = NULL; | 555 texture.info = NULL; |
| 541 if (!texture.sent_to_client) | 556 if (!texture.sent_to_client) |
| 542 continue; | 557 continue; |
| 543 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 558 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
| 544 params.identifier = texture.client_id; | 559 params.identifier = texture.client_id; |
| 545 helper_->SendAcceleratedSurfaceRelease(params); | 560 helper_->SendAcceleratedSurfaceRelease(params); |
| 546 } | 561 } |
| 547 parent_stub_ = NULL; | 562 parent_stub_ = NULL; |
| 548 } | 563 } |
| OLD | NEW |