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

Side by Side Diff: ui/views/bubble/tray_bubble_view.cc

Issue 1064133003: ui: Use a PaintRecorder to access the Canvas for painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ui-recorder: . Created 5 years, 8 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 | « ui/snapshot/snapshot_aura_unittest.cc ('k') | ui/views/view.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 "ui/views/bubble/tray_bubble_view.h" 5 #include "ui/views/bubble/tray_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
11 #include "third_party/skia/include/core/SkPaint.h" 11 #include "third_party/skia/include/core/SkPaint.h"
12 #include "third_party/skia/include/core/SkPath.h" 12 #include "third_party/skia/include/core/SkPath.h"
13 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 13 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
14 #include "ui/accessibility/ax_view_state.h" 14 #include "ui/accessibility/ax_view_state.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/compositor/layer.h" 16 #include "ui/compositor/layer.h"
17 #include "ui/compositor/layer_delegate.h" 17 #include "ui/compositor/layer_delegate.h"
18 #include "ui/compositor/paint_context.h" 18 #include "ui/compositor/paint_recorder.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/geometry/insets.h" 21 #include "ui/gfx/geometry/insets.h"
22 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
23 #include "ui/gfx/path.h" 23 #include "ui/gfx/path.h"
24 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
25 #include "ui/views/bubble/bubble_frame_view.h" 25 #include "ui/views/bubble/bubble_frame_view.h"
26 #include "ui/views/bubble/bubble_window_targeter.h" 26 #include "ui/views/bubble/bubble_window_targeter.h"
27 #include "ui/views/layout/box_layout.h" 27 #include "ui/views/layout/box_layout.h"
28 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 : layer_(ui::LAYER_TEXTURED), 199 : layer_(ui::LAYER_TEXTURED),
200 corner_radius_(corner_radius) { 200 corner_radius_(corner_radius) {
201 layer_.set_delegate(this); 201 layer_.set_delegate(this);
202 } 202 }
203 203
204 TrayBubbleContentMask::~TrayBubbleContentMask() { 204 TrayBubbleContentMask::~TrayBubbleContentMask() {
205 layer_.set_delegate(NULL); 205 layer_.set_delegate(NULL);
206 } 206 }
207 207
208 void TrayBubbleContentMask::OnPaintLayer(const ui::PaintContext& context) { 208 void TrayBubbleContentMask::OnPaintLayer(const ui::PaintContext& context) {
209 ui::PaintRecorder recorder(context);
209 SkPaint paint; 210 SkPaint paint;
210 paint.setAlpha(255); 211 paint.setAlpha(255);
211 paint.setStyle(SkPaint::kFill_Style); 212 paint.setStyle(SkPaint::kFill_Style);
212 gfx::Rect rect(layer()->bounds().size()); 213 gfx::Rect rect(layer()->bounds().size());
213 context.canvas()->DrawRoundRect(rect, corner_radius_, paint); 214 recorder.canvas()->DrawRoundRect(rect, corner_radius_, paint);
214 } 215 }
215 216
216 void TrayBubbleContentMask::OnDeviceScaleFactorChanged( 217 void TrayBubbleContentMask::OnDeviceScaleFactorChanged(
217 float device_scale_factor) { 218 float device_scale_factor) {
218 // Redrawing will take care of scale factor change. 219 // Redrawing will take care of scale factor change.
219 } 220 }
220 221
221 base::Closure TrayBubbleContentMask::PrepareForLayerBoundsChange() { 222 base::Closure TrayBubbleContentMask::PrepareForLayerBoundsChange() {
222 return base::Closure(); 223 return base::Closure();
223 } 224 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 void TrayBubbleView::ViewHierarchyChanged( 500 void TrayBubbleView::ViewHierarchyChanged(
500 const ViewHierarchyChangedDetails& details) { 501 const ViewHierarchyChangedDetails& details) {
501 if (details.is_add && details.child == this) { 502 if (details.is_add && details.child == this) {
502 details.parent->SetPaintToLayer(true); 503 details.parent->SetPaintToLayer(true);
503 details.parent->SetFillsBoundsOpaquely(true); 504 details.parent->SetFillsBoundsOpaquely(true);
504 details.parent->layer()->SetMasksToBounds(true); 505 details.parent->layer()->SetMasksToBounds(true);
505 } 506 }
506 } 507 }
507 508
508 } // namespace views 509 } // namespace views
OLDNEW
« no previous file with comments | « ui/snapshot/snapshot_aura_unittest.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698