Index: components/exo/surface.cc |
diff --git a/components/exo/surface.cc b/components/exo/surface.cc |
index 08b8a187655d5653b73feec064e77f19ba1b565a..8b9389252da75ee759bcb4a3e658929f8d82762a 100644 |
--- a/components/exo/surface.cc |
+++ b/components/exo/surface.cc |
@@ -388,13 +388,21 @@ void Surface::PlaceSubSurfaceBelow(Surface* sub_surface, Surface* sibling) { |
void Surface::SetViewport(const gfx::Size& viewport) { |
TRACE_EVENT1("exo", "Surface::SetViewport", "viewport", viewport.ToString()); |
+ if (pending_viewport_ == viewport) |
+ return; |
+ |
pending_viewport_ = viewport; |
+ changed_viewport_or_crop_ = true; |
} |
void Surface::SetCrop(const gfx::RectF& crop) { |
TRACE_EVENT1("exo", "Surface::SetCrop", "crop", crop.ToString()); |
+ if (pending_crop_ == crop) |
+ return; |
+ |
pending_crop_ = crop; |
+ changed_viewport_or_crop_ = true; |
} |
void Surface::SetOnlyVisibleOnSecureOutput(bool only_visible_on_secure_output) { |
@@ -512,26 +520,45 @@ void Surface::CommitLayerContents() { |
void Surface::CommitSurfaceContents() { |
// We update contents if Attach() has been called since last commit. |
if (has_pending_contents_) { |
- has_pending_contents_ = false; |
- |
current_buffer_ = pending_buffer_; |
pending_buffer_.reset(); |
- bool secure_output_only = pending_only_visible_on_secure_output_; |
- pending_only_visible_on_secure_output_ = false; |
- |
- cc::TextureMailbox texture_mailbox; |
- std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; |
if (current_buffer_) { |
+ std::unique_ptr<cc::SingleReleaseCallback> |
+ texture_mailbox_release_callback; |
+ |
+ cc::TextureMailbox texture_mailbox; |
texture_mailbox_release_callback = current_buffer_->ProduceTextureMailbox( |
- &texture_mailbox, secure_output_only, false); |
+ &texture_mailbox, pending_only_visible_on_secure_output_, false); |
+ cc::TransferableResource resource; |
+ resource.id = next_resource_id_++; |
+ resource.format = cc::RGBA_8888; |
+ resource.filter = |
+ texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; |
+ resource.size = texture_mailbox.size_in_pixels(); |
+ resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), |
+ texture_mailbox.sync_token(), |
+ texture_mailbox.target()); |
+ resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate(); |
+ |
+ factory_owner_->release_callbacks_[resource.id] = std::make_pair( |
+ factory_owner_, std::move(texture_mailbox_release_callback)); |
+ current_resource_ = resource; |
+ } else { |
+ current_resource_.id = 0; |
+ current_resource_.size = gfx::Size(); |
} |
+ } |
+ |
+ if (has_pending_contents_ || changed_viewport_or_crop_) { |
reveman
2016/06/03 19:06:51
Do we need this if statement and the new changed_v
|
+ has_pending_contents_ = false; |
+ changed_viewport_or_crop_ = false; |
cc::SurfaceId old_surface_id = surface_id_; |
surface_id_ = factory_owner_->id_allocator_->GenerateId(); |
factory_owner_->surface_factory_->Create(surface_id_); |
- gfx::Size buffer_size = texture_mailbox.size_in_pixels(); |
+ gfx::Size buffer_size = current_resource_.size; |
gfx::SizeF scaled_buffer_size( |
gfx::ScaleSize(gfx::SizeF(buffer_size), 1.0f / pending_buffer_scale_)); |
@@ -585,18 +612,7 @@ void Surface::CommitSurfaceContents() { |
std::unique_ptr<cc::DelegatedFrameData> delegated_frame( |
new cc::DelegatedFrameData); |
- if (texture_mailbox_release_callback) { |
- cc::TransferableResource resource; |
- resource.id = next_resource_id_++; |
- resource.format = cc::RGBA_8888; |
- resource.filter = |
- texture_mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR; |
- resource.size = texture_mailbox.size_in_pixels(); |
- resource.mailbox_holder = gpu::MailboxHolder(texture_mailbox.mailbox(), |
- texture_mailbox.sync_token(), |
- texture_mailbox.target()); |
- resource.is_overlay_candidate = texture_mailbox.is_overlay_candidate(); |
- |
+ if (current_resource_.id) { |
cc::TextureDrawQuad* texture_quad = |
render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; |
@@ -610,14 +626,11 @@ void Surface::CommitSurfaceContents() { |
opaque_rect = gfx::SkIRectToRect(pending_opaque_region_.getBounds()); |
} |
- texture_quad->SetNew(quad_state, quad_rect, opaque_rect, quad_rect, |
- resource.id, true, uv_top_left, uv_bottom_right, |
- SK_ColorTRANSPARENT, vertex_opacity, false, false, |
- secure_output_only); |
- |
- factory_owner_->release_callbacks_[resource.id] = std::make_pair( |
- factory_owner_, std::move(texture_mailbox_release_callback)); |
- delegated_frame->resource_list.push_back(resource); |
+ texture_quad->SetNew( |
+ quad_state, quad_rect, opaque_rect, quad_rect, current_resource_.id, |
+ true, uv_top_left, uv_bottom_right, SK_ColorTRANSPARENT, |
+ vertex_opacity, false, false, pending_only_visible_on_secure_output_); |
+ delegated_frame->resource_list.push_back(current_resource_); |
} else { |
cc::SolidColorDrawQuad* solid_quad = |
render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
@@ -650,6 +663,10 @@ void Surface::CommitSurfaceContents() { |
// Reset damage. |
pending_damage_.setEmpty(); |
} |
+ |
+ if (current_resource_.id) |
reveman
2016/06/03 19:06:50
nit: please include this in the DCHECK, DCHECK(!cu
|
+ DCHECK(factory_owner_->release_callbacks_.count(current_resource_.id)); |
+ |
// Move pending frame callbacks to the end of active_frame_callbacks_ |
active_frame_callbacks_.splice(active_frame_callbacks_.end(), |
pending_frame_callbacks_); |