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

Unified Diff: content/browser/compositor/delegated_frame_host.cc

Issue 1759323003: Add resize gutter layers to DelegatedFrameHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/compositor/delegated_frame_host.cc
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_host.cc
index 7686744da1db7e1e9299a28ce77d141c49f76bc1..14b4ff82f5b0b3c4dc17ac7e5e8889aa165464a6 100644
--- a/content/browser/compositor/delegated_frame_host.cc
+++ b/content/browser/compositor/delegated_frame_host.cc
@@ -69,6 +69,7 @@ DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client)
last_output_surface_id_(0),
pending_delegated_ack_count_(0),
skipped_frames_(false),
+ background_color_(SK_ColorWHITE),
danakj 2016/03/08 00:09:43 There's some work to be done to not show the wrong
jbauman 2016/03/08 01:45:29 Actually this initialization isn't really necessar
danakj 2016/03/10 22:53:18 Can you make it some more crazy noticeable color t
current_scale_factor_(1.f),
can_lock_compositor_(YES_CAN_LOCK),
delegated_frame_evictor_(new DelegatedFrameEvictor(this)) {
@@ -253,6 +254,45 @@ void DelegatedFrameHost::WasResized() {
!client_->DelegatedFrameHostIsVisible())
EvictDelegatedFrame();
MaybeCreateResizeLock();
+ UpdateGutters();
+}
+
+void DelegatedFrameHost::UpdateGutters() {
+ if (surface_id_.is_null()) {
+ right_gutter_.reset();
+ bottom_gutter_.reset();
+ return;
+ }
+ if (current_frame_size_in_dip_.width() <
+ client_->DelegatedFrameHostDesiredSizeInDIP().width()) {
+ // The right gutter also include the bottom-right corner, if necessary.
danakj 2016/03/08 00:09:44 includes
jbauman 2016/03/08 01:45:29 Done.
+ right_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
+ right_gutter_->SetColor(background_color_);
+ int width = client_->DelegatedFrameHostDesiredSizeInDIP().width() -
+ current_frame_size_in_dip_.width();
+ right_gutter_->SetBounds(
+ gfx::Rect(current_frame_size_in_dip_.width(), 0, width,
+ client_->DelegatedFrameHostDesiredSizeInDIP().height()));
danakj 2016/03/08 00:09:44 nit: put this value in a temp |height| and move th
jbauman 2016/03/08 01:45:29 Done.
+
+ client_->DelegatedFrameHostGetLayer()->Add(right_gutter_.get());
danakj 2016/03/08 00:09:43 One design question.. could cc::SurfaceLayer just
jbauman 2016/03/08 01:45:29 I've thought about it, but currently the SurfaceLa
+ } else {
+ right_gutter_.reset();
+ }
+
+ if (current_frame_size_in_dip_.height() <
+ client_->DelegatedFrameHostDesiredSizeInDIP().height()) {
+ bottom_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
+ bottom_gutter_->SetColor(background_color_);
+ int height = client_->DelegatedFrameHostDesiredSizeInDIP().height() -
+ current_frame_size_in_dip_.height();
+ bottom_gutter_->SetBounds(gfx::Rect(0, current_frame_size_in_dip_.height(),
+ current_frame_size_in_dip_.width(),
danakj 2016/03/08 00:09:43 nit: put this into a |width| var too, it's nice to
jbauman 2016/03/08 01:45:29 Done.
+ height));
+ client_->DelegatedFrameHostGetLayer()->Add(bottom_gutter_.get());
+
+ } else {
+ bottom_gutter_.reset();
+ }
}
gfx::Size DelegatedFrameHost::GetRequestedRendererSize() const {
@@ -400,6 +440,8 @@ void DelegatedFrameHost::SwapDelegatedFrame(
bool skip_frame = false;
pending_delegated_ack_count_++;
+ background_color_ = frame->metadata.root_background_color;
+
if (frame_size.IsEmpty()) {
DCHECK(frame_data->resource_list.empty());
EvictDelegatedFrame();
@@ -447,6 +489,8 @@ void DelegatedFrameHost::SwapDelegatedFrame(
current_frame_size_in_dip_ = frame_size_in_dip;
CheckResizeLock();
+ UpdateGutters();
+
if (!damage_rect_in_dip.IsEmpty())
client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage(
damage_rect_in_dip);
danakj 2016/03/08 00:09:43 When if ever should damage include the gutters?
jbauman 2016/03/08 01:45:29 Never, AFAIK. This is only supposed to use damage
@@ -524,6 +568,7 @@ void DelegatedFrameHost::EvictDelegatedFrame() {
surface_id_ = cc::SurfaceId();
}
delegated_frame_evictor_->DiscardedFrame();
+ UpdateGutters();
}
// static

Powered by Google App Engine
This is Rietveld 408576698