| 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 "ui/wm/core/image_grid.h" | 5 #include "ui/wm/core/image_grid.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "third_party/skia/include/core/SkXfermode.h" | 10 #include "third_party/skia/include/core/SkXfermode.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const int top = min(base_top_row_height_, size_.height() / 2); | 139 const int top = min(base_top_row_height_, size_.height() / 2); |
| 140 const int bottom = min(base_bottom_row_height_, size_.height() - top); | 140 const int bottom = min(base_bottom_row_height_, size_.height() - top); |
| 141 | 141 |
| 142 // The remaining space goes to the center image. | 142 // The remaining space goes to the center image. |
| 143 int center_width = std::max(size.width() - left - right, 0); | 143 int center_width = std::max(size.width() - left - right, 0); |
| 144 int center_height = std::max(size.height() - top - bottom, 0); | 144 int center_height = std::max(size.height() - top - bottom, 0); |
| 145 | 145 |
| 146 // At non-integer scale factors, the ratio of dimensions in DIP is not | 146 // At non-integer scale factors, the ratio of dimensions in DIP is not |
| 147 // necessarily the same as the ratio in physical pixels due to rounding. Set | 147 // necessarily the same as the ratio in physical pixels due to rounding. Set |
| 148 // the transform on each of the layers based on dimensions in pixels. | 148 // the transform on each of the layers based on dimensions in pixels. |
| 149 gfx::Size center_size_in_pixels = gfx::ToFlooredSize(gfx::ScaleSize( | 149 gfx::Size center_size_in_pixels = gfx::ScaleToFlooredSize( |
| 150 gfx::Size(center_width, center_height), layer_->device_scale_factor())); | 150 gfx::Size(center_width, center_height), layer_->device_scale_factor()); |
| 151 | 151 |
| 152 if (top_layer_.get()) { | 152 if (top_layer_.get()) { |
| 153 if (center_width > 0) { | 153 if (center_width > 0) { |
| 154 gfx::Transform transform; | 154 gfx::Transform transform; |
| 155 transform.Translate(left, 0); | 155 transform.Translate(left, 0); |
| 156 ScaleWidth(center_size_in_pixels, top_layer_.get(), transform); | 156 ScaleWidth(center_size_in_pixels, top_layer_.get(), transform); |
| 157 top_layer_->SetTransform(transform); | 157 top_layer_->SetTransform(transform); |
| 158 } | 158 } |
| 159 top_layer_->SetVisible(center_width > 0); | 159 top_layer_->SetVisible(center_width > 0); |
| 160 } | 160 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 layer_ptr->get()->SetBounds(gfx::Rect(0, 0, size.width(), size.height())); | 336 layer_ptr->get()->SetBounds(gfx::Rect(0, 0, size.width(), size.height())); |
| 337 | 337 |
| 338 painter_ptr->reset(new ImagePainter(image_skia)); | 338 painter_ptr->reset(new ImagePainter(image_skia)); |
| 339 layer_ptr->get()->set_delegate(painter_ptr->get()); | 339 layer_ptr->get()->set_delegate(painter_ptr->get()); |
| 340 layer_ptr->get()->SetFillsBoundsOpaquely(false); | 340 layer_ptr->get()->SetFillsBoundsOpaquely(false); |
| 341 layer_ptr->get()->SetVisible(true); | 341 layer_ptr->get()->SetVisible(true); |
| 342 layer_->Add(layer_ptr->get()); | 342 layer_->Add(layer_ptr->get()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace wm | 345 } // namespace wm |
| OLD | NEW |