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

Side by Side Diff: ash/common/wm/overview/scoped_transform_overview_window.cc

Issue 2125133002: [BUG REPRO ONLY] Demonstrates texture reuse for mask layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/wm/overview/scoped_transform_overview_window.h" 5 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
11 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" 11 #include "ash/common/wm/overview/scoped_overview_animation_settings.h"
12 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" 12 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h"
13 #include "ash/common/wm/overview/window_selector_item.h" 13 #include "ash/common/wm/overview/window_selector_item.h"
14 #include "ash/common/wm/window_state.h" 14 #include "ash/common/wm/window_state.h"
15 #include "ash/common/wm_window.h" 15 #include "ash/common/wm_window.h"
16 #include "ash/common/wm_window_property.h" 16 #include "ash/common/wm_window_property.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
20 #include "third_party/skia/include/core/SkPaint.h" 21 #include "third_party/skia/include/core/SkPaint.h"
21 #include "third_party/skia/include/core/SkPath.h" 22 #include "third_party/skia/include/core/SkPath.h"
22 #include "third_party/skia/include/core/SkRect.h" 23 #include "third_party/skia/include/core/SkRect.h"
23 #include "ui/compositor/layer.h" 24 #include "ui/compositor/layer.h"
24 #include "ui/compositor/layer_delegate.h" 25 #include "ui/compositor/layer_delegate.h"
25 #include "ui/compositor/paint_recorder.h" 26 #include "ui/compositor/paint_recorder.h"
26 #include "ui/gfx/geometry/rect.h" 27 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/geometry/safe_integer_conversions.h" 28 #include "ui/gfx/geometry/safe_integer_conversions.h"
28 #include "ui/gfx/transform_util.h" 29 #include "ui/gfx/transform_util.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 layer_.set_delegate(this); 207 layer_.set_delegate(this);
207 } 208 }
208 209
209 ScopedTransformOverviewWindow::OverviewContentMask::~OverviewContentMask() { 210 ScopedTransformOverviewWindow::OverviewContentMask::~OverviewContentMask() {
210 layer_.set_delegate(nullptr); 211 layer_.set_delegate(nullptr);
211 } 212 }
212 213
213 void ScopedTransformOverviewWindow::OverviewContentMask::OnPaintLayer( 214 void ScopedTransformOverviewWindow::OverviewContentMask::OnPaintLayer(
214 const ui::PaintContext& context) { 215 const ui::PaintContext& context) {
215 ui::PaintRecorder recorder(context, layer()->size()); 216 ui::PaintRecorder recorder(context, layer()->size());
216 gfx::Rect bounds(layer()->bounds().size());
217 bounds.Inset(0, inset_, 0, 0);
218 217
219 // Tile a window into an area, rounding the bottom corners. 218 (void)inset_;
220 const SkRect rect = gfx::RectToSkRect(bounds); 219 (void)radius_;
221 const SkScalar corner_radius_scalar = SkIntToScalar(radius_); 220 (void)kOverviewContentMaskAlpha;
222 SkScalar radii[8] = {0,
223 0, // top-left
224 0,
225 0, // top-right
226 corner_radius_scalar,
227 corner_radius_scalar, // bottom-right
228 corner_radius_scalar,
229 corner_radius_scalar}; // bottom-left
230 SkPath path;
231 path.addRoundRect(rect, radii, SkPath::kCW_Direction);
232 221
233 // Set a mask. 222 LOG(ERROR) << __FUNCTION__ << " id=" << layer_.cc_layer_for_testing()->id();
234 SkPaint paint; 223 gfx::Rect bounds(50, 10 * (layer_.cc_layer_for_testing()->id() % 10), 100,
235 paint.setAlpha(kOverviewContentMaskAlpha); 224 100);
236 paint.setStyle(SkPaint::kFill_Style); 225 std::string txt = std::to_string(layer_.cc_layer_for_testing()->id());
237 paint.setAntiAlias(true); 226 base::string16 text(base::UTF8ToUTF16(txt));
238 recorder.canvas()->DrawPath(path, paint); 227 recorder.canvas()->DrawStringRect(text, gfx::FontList(), SK_ColorWHITE,
228 bounds);
239 } 229 }
240 230
241 void ScopedTransformOverviewWindow::OverviewContentMask:: 231 void ScopedTransformOverviewWindow::OverviewContentMask::
242 OnDeviceScaleFactorChanged(float device_scale_factor) { 232 OnDeviceScaleFactorChanged(float device_scale_factor) {
243 // Redrawing will take care of scale factor change. 233 // Redrawing will take care of scale factor change.
244 } 234 }
245 235
246 base::Closure ScopedTransformOverviewWindow::OverviewContentMask:: 236 base::Closure ScopedTransformOverviewWindow::OverviewContentMask::
247 PrepareForLayerBoundsChange() { 237 PrepareForLayerBoundsChange() {
248 return base::Closure(); 238 return base::Closure();
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 if (parent_window) 438 if (parent_window)
449 parent_window->CloseWidget(); 439 parent_window->CloseWidget();
450 } 440 }
451 441
452 // static 442 // static
453 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { 443 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() {
454 immediate_close_for_tests = true; 444 immediate_close_for_tests = true;
455 } 445 }
456 446
457 } // namespace ash 447 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698