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

Side by Side Diff: ash/wm/image_grid.cc

Issue 11145005: Migrate ui::Transform to gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Hopefully should work this time Created 8 years, 2 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 unified diff | Download patch
« no previous file with comments | « ash/wm/gestures/long_press_affordance_handler.cc ('k') | ash/wm/session_state_animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/wm/image_grid.h" 5 #include "ash/wm/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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const int right = min(base_right_column_width_, size_.width() - left); 98 const int right = min(base_right_column_width_, size_.width() - left);
99 const int top = min(base_top_row_height_, size_.height() / 2); 99 const int top = min(base_top_row_height_, size_.height() / 2);
100 const int bottom = min(base_bottom_row_height_, size_.height() - top); 100 const int bottom = min(base_bottom_row_height_, size_.height() - top);
101 101
102 // The remaining space goes to the center image. 102 // The remaining space goes to the center image.
103 int center_width = std::max(size.width() - left - right, 0); 103 int center_width = std::max(size.width() - left - right, 0);
104 int center_height = std::max(size.height() - top - bottom, 0); 104 int center_height = std::max(size.height() - top - bottom, 0);
105 105
106 if (top_layer_.get()) { 106 if (top_layer_.get()) {
107 if (center_width > 0) { 107 if (center_width > 0) {
108 ui::Transform transform; 108 gfx::Transform transform;
109 transform.SetScaleX( 109 transform.SetScaleX(
110 static_cast<float>(center_width) / top_layer_->bounds().width()); 110 static_cast<float>(center_width) / top_layer_->bounds().width());
111 transform.ConcatTranslate(left, 0); 111 transform.ConcatTranslate(left, 0);
112 top_layer_->SetTransform(transform); 112 top_layer_->SetTransform(transform);
113 } 113 }
114 top_layer_->SetVisible(center_width > 0); 114 top_layer_->SetVisible(center_width > 0);
115 } 115 }
116 if (bottom_layer_.get()) { 116 if (bottom_layer_.get()) {
117 if (center_width > 0) { 117 if (center_width > 0) {
118 ui::Transform transform; 118 gfx::Transform transform;
119 transform.SetScaleX( 119 transform.SetScaleX(
120 static_cast<float>(center_width) / bottom_layer_->bounds().width()); 120 static_cast<float>(center_width) / bottom_layer_->bounds().width());
121 transform.ConcatTranslate( 121 transform.ConcatTranslate(
122 left, size.height() - bottom_layer_->bounds().height()); 122 left, size.height() - bottom_layer_->bounds().height());
123 bottom_layer_->SetTransform(transform); 123 bottom_layer_->SetTransform(transform);
124 } 124 }
125 bottom_layer_->SetVisible(center_width > 0); 125 bottom_layer_->SetVisible(center_width > 0);
126 } 126 }
127 if (left_layer_.get()) { 127 if (left_layer_.get()) {
128 if (center_height > 0) { 128 if (center_height > 0) {
129 ui::Transform transform; 129 gfx::Transform transform;
130 transform.SetScaleY( 130 transform.SetScaleY(
131 (static_cast<float>(center_height) / left_layer_->bounds().height())); 131 (static_cast<float>(center_height) / left_layer_->bounds().height()));
132 transform.ConcatTranslate(0, top); 132 transform.ConcatTranslate(0, top);
133 left_layer_->SetTransform(transform); 133 left_layer_->SetTransform(transform);
134 } 134 }
135 left_layer_->SetVisible(center_height > 0); 135 left_layer_->SetVisible(center_height > 0);
136 } 136 }
137 if (right_layer_.get()) { 137 if (right_layer_.get()) {
138 if (center_height > 0) { 138 if (center_height > 0) {
139 ui::Transform transform; 139 gfx::Transform transform;
140 transform.SetScaleY( 140 transform.SetScaleY(
141 static_cast<float>(center_height) / right_layer_->bounds().height()); 141 static_cast<float>(center_height) / right_layer_->bounds().height());
142 transform.ConcatTranslate( 142 transform.ConcatTranslate(
143 size.width() - right_layer_->bounds().width(), top); 143 size.width() - right_layer_->bounds().width(), top);
144 right_layer_->SetTransform(transform); 144 right_layer_->SetTransform(transform);
145 } 145 }
146 right_layer_->SetVisible(center_height > 0); 146 right_layer_->SetVisible(center_height > 0);
147 } 147 }
148 148
149 if (top_left_layer_.get()) { 149 if (top_left_layer_.get()) {
150 // No transformation needed; it should be at (0, 0) and unscaled. 150 // No transformation needed; it should be at (0, 0) and unscaled.
151 top_left_painter_->SetClipRect( 151 top_left_painter_->SetClipRect(
152 LayerExceedsSize(top_left_layer_.get(), gfx::Size(left, top)) ? 152 LayerExceedsSize(top_left_layer_.get(), gfx::Size(left, top)) ?
153 gfx::Rect(gfx::Rect(0, 0, left, top)) : 153 gfx::Rect(gfx::Rect(0, 0, left, top)) :
154 gfx::Rect(), 154 gfx::Rect(),
155 top_left_layer_.get()); 155 top_left_layer_.get());
156 } 156 }
157 if (top_right_layer_.get()) { 157 if (top_right_layer_.get()) {
158 ui::Transform transform; 158 gfx::Transform transform;
159 transform.SetTranslateX(size.width() - top_right_layer_->bounds().width()); 159 transform.SetTranslateX(size.width() - top_right_layer_->bounds().width());
160 top_right_layer_->SetTransform(transform); 160 top_right_layer_->SetTransform(transform);
161 top_right_painter_->SetClipRect( 161 top_right_painter_->SetClipRect(
162 LayerExceedsSize(top_right_layer_.get(), gfx::Size(right, top)) ? 162 LayerExceedsSize(top_right_layer_.get(), gfx::Size(right, top)) ?
163 gfx::Rect(top_right_layer_->bounds().width() - right, 0, 163 gfx::Rect(top_right_layer_->bounds().width() - right, 0,
164 right, top) : 164 right, top) :
165 gfx::Rect(), 165 gfx::Rect(),
166 top_right_layer_.get()); 166 top_right_layer_.get());
167 } 167 }
168 if (bottom_left_layer_.get()) { 168 if (bottom_left_layer_.get()) {
169 ui::Transform transform; 169 gfx::Transform transform;
170 transform.SetTranslateY( 170 transform.SetTranslateY(
171 size.height() - bottom_left_layer_->bounds().height()); 171 size.height() - bottom_left_layer_->bounds().height());
172 bottom_left_layer_->SetTransform(transform); 172 bottom_left_layer_->SetTransform(transform);
173 bottom_left_painter_->SetClipRect( 173 bottom_left_painter_->SetClipRect(
174 LayerExceedsSize(bottom_left_layer_.get(), gfx::Size(left, bottom)) ? 174 LayerExceedsSize(bottom_left_layer_.get(), gfx::Size(left, bottom)) ?
175 gfx::Rect(0, bottom_left_layer_->bounds().height() - bottom, 175 gfx::Rect(0, bottom_left_layer_->bounds().height() - bottom,
176 left, bottom) : 176 left, bottom) :
177 gfx::Rect(), 177 gfx::Rect(),
178 bottom_left_layer_.get()); 178 bottom_left_layer_.get());
179 } 179 }
180 if (bottom_right_layer_.get()) { 180 if (bottom_right_layer_.get()) {
181 ui::Transform transform; 181 gfx::Transform transform;
182 transform.SetTranslate( 182 transform.SetTranslate(
183 size.width() - bottom_right_layer_->bounds().width(), 183 size.width() - bottom_right_layer_->bounds().width(),
184 size.height() - bottom_right_layer_->bounds().height()); 184 size.height() - bottom_right_layer_->bounds().height());
185 bottom_right_layer_->SetTransform(transform); 185 bottom_right_layer_->SetTransform(transform);
186 bottom_right_painter_->SetClipRect( 186 bottom_right_painter_->SetClipRect(
187 LayerExceedsSize(bottom_right_layer_.get(), gfx::Size(right, bottom)) ? 187 LayerExceedsSize(bottom_right_layer_.get(), gfx::Size(right, bottom)) ?
188 gfx::Rect(bottom_right_layer_->bounds().width() - right, 188 gfx::Rect(bottom_right_layer_->bounds().width() - right,
189 bottom_right_layer_->bounds().height() - bottom, 189 bottom_right_layer_->bounds().height() - bottom,
190 right, bottom) : 190 right, bottom) :
191 gfx::Rect(), 191 gfx::Rect(),
192 bottom_right_layer_.get()); 192 bottom_right_layer_.get());
193 } 193 }
194 194
195 if (center_layer_.get()) { 195 if (center_layer_.get()) {
196 if (center_width > 0 && center_height > 0) { 196 if (center_width > 0 && center_height > 0) {
197 ui::Transform transform; 197 gfx::Transform transform;
198 transform.SetScale(center_width / center_layer_->bounds().width(), 198 transform.SetScale(center_width / center_layer_->bounds().width(),
199 center_height / center_layer_->bounds().height()); 199 center_height / center_layer_->bounds().height());
200 transform.ConcatTranslate(left, top); 200 transform.ConcatTranslate(left, top);
201 center_layer_->SetTransform(transform); 201 center_layer_->SetTransform(transform);
202 } 202 }
203 center_layer_->SetVisible(center_width > 0 && center_height > 0); 203 center_layer_->SetVisible(center_width > 0 && center_height > 0);
204 } 204 }
205 } 205 }
206 206
207 void ImageGrid::SetContentBounds(const gfx::Rect& content_bounds) { 207 void ImageGrid::SetContentBounds(const gfx::Rect& content_bounds) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 painter_ptr->reset(new ImagePainter(image)); 275 painter_ptr->reset(new ImagePainter(image));
276 layer_ptr->get()->set_delegate(painter_ptr->get()); 276 layer_ptr->get()->set_delegate(painter_ptr->get());
277 layer_ptr->get()->SetFillsBoundsOpaquely(false); 277 layer_ptr->get()->SetFillsBoundsOpaquely(false);
278 layer_ptr->get()->SetVisible(true); 278 layer_ptr->get()->SetVisible(true);
279 layer_->Add(layer_ptr->get()); 279 layer_->Add(layer_ptr->get());
280 } 280 }
281 281
282 } // namespace internal 282 } // namespace internal
283 } // namespace ash 283 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/gestures/long_press_affordance_handler.cc ('k') | ash/wm/session_state_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698