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