| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/renderer_host/delegated_frame_host.h" | 5 #include "content/browser/renderer_host/delegated_frame_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 void DelegatedFrameHost::WasResized() { | 249 void DelegatedFrameHost::WasResized() { |
| 250 if (client_->DelegatedFrameHostDesiredSizeInDIP() != | 250 if (client_->DelegatedFrameHostDesiredSizeInDIP() != |
| 251 current_frame_size_in_dip_ && | 251 current_frame_size_in_dip_ && |
| 252 !client_->DelegatedFrameHostIsVisible()) | 252 !client_->DelegatedFrameHostIsVisible()) |
| 253 EvictDelegatedFrame(); | 253 EvictDelegatedFrame(); |
| 254 MaybeCreateResizeLock(); | 254 MaybeCreateResizeLock(); |
| 255 UpdateGutters(); | 255 UpdateGutters(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 SkColor DelegatedFrameHost::GetGutterColor() const { |
| 259 // In fullscreen mode resizing is uncommon, so it makes more sense to |
| 260 // make the initial switch to fullscreen mode look better by using black as |
| 261 // the gutter color. |
| 262 return client_->DelegatedFrameHostGetGutterColor(background_color_); |
| 263 } |
| 264 |
| 258 void DelegatedFrameHost::UpdateGutters() { | 265 void DelegatedFrameHost::UpdateGutters() { |
| 259 if (surface_id_.is_null()) { | 266 if (surface_id_.is_null()) { |
| 260 right_gutter_.reset(); | 267 right_gutter_.reset(); |
| 261 bottom_gutter_.reset(); | 268 bottom_gutter_.reset(); |
| 262 return; | 269 return; |
| 263 } | 270 } |
| 271 |
| 264 if (current_frame_size_in_dip_.width() < | 272 if (current_frame_size_in_dip_.width() < |
| 265 client_->DelegatedFrameHostDesiredSizeInDIP().width()) { | 273 client_->DelegatedFrameHostDesiredSizeInDIP().width()) { |
| 266 right_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 274 right_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 267 right_gutter_->SetColor(background_color_); | 275 right_gutter_->SetColor(GetGutterColor()); |
| 268 int width = client_->DelegatedFrameHostDesiredSizeInDIP().width() - | 276 int width = client_->DelegatedFrameHostDesiredSizeInDIP().width() - |
| 269 current_frame_size_in_dip_.width(); | 277 current_frame_size_in_dip_.width(); |
| 270 // The right gutter also includes the bottom-right corner, if necessary. | 278 // The right gutter also includes the bottom-right corner, if necessary. |
| 271 int height = client_->DelegatedFrameHostDesiredSizeInDIP().height(); | 279 int height = client_->DelegatedFrameHostDesiredSizeInDIP().height(); |
| 272 right_gutter_->SetBounds( | 280 right_gutter_->SetBounds( |
| 273 gfx::Rect(current_frame_size_in_dip_.width(), 0, width, height)); | 281 gfx::Rect(current_frame_size_in_dip_.width(), 0, width, height)); |
| 274 | 282 |
| 275 client_->DelegatedFrameHostGetLayer()->Add(right_gutter_.get()); | 283 client_->DelegatedFrameHostGetLayer()->Add(right_gutter_.get()); |
| 276 } else { | 284 } else { |
| 277 right_gutter_.reset(); | 285 right_gutter_.reset(); |
| 278 } | 286 } |
| 279 | 287 |
| 280 if (current_frame_size_in_dip_.height() < | 288 if (current_frame_size_in_dip_.height() < |
| 281 client_->DelegatedFrameHostDesiredSizeInDIP().height()) { | 289 client_->DelegatedFrameHostDesiredSizeInDIP().height()) { |
| 282 bottom_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 290 bottom_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 283 bottom_gutter_->SetColor(background_color_); | 291 bottom_gutter_->SetColor(GetGutterColor()); |
| 284 int width = current_frame_size_in_dip_.width(); | 292 int width = current_frame_size_in_dip_.width(); |
| 285 int height = client_->DelegatedFrameHostDesiredSizeInDIP().height() - | 293 int height = client_->DelegatedFrameHostDesiredSizeInDIP().height() - |
| 286 current_frame_size_in_dip_.height(); | 294 current_frame_size_in_dip_.height(); |
| 287 bottom_gutter_->SetBounds( | 295 bottom_gutter_->SetBounds( |
| 288 gfx::Rect(0, current_frame_size_in_dip_.height(), width, height)); | 296 gfx::Rect(0, current_frame_size_in_dip_.height(), width, height)); |
| 289 client_->DelegatedFrameHostGetLayer()->Add(bottom_gutter_.get()); | 297 client_->DelegatedFrameHostGetLayer()->Add(bottom_gutter_.get()); |
| 290 | 298 |
| 291 } else { | 299 } else { |
| 292 bottom_gutter_.reset(); | 300 bottom_gutter_.reset(); |
| 293 } | 301 } |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 894 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 887 new_layer->SetShowSurface( | 895 new_layer->SetShowSurface( |
| 888 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 896 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 889 base::Bind(&RequireCallback, base::Unretained(manager)), | 897 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 890 current_surface_size_, current_scale_factor_, | 898 current_surface_size_, current_scale_factor_, |
| 891 current_frame_size_in_dip_); | 899 current_frame_size_in_dip_); |
| 892 } | 900 } |
| 893 } | 901 } |
| 894 | 902 |
| 895 } // namespace content | 903 } // namespace content |
| OLD | NEW |