| 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/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" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 // Overridden from LayerDelegate. | 184 // Overridden from LayerDelegate. |
| 185 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 185 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
| 186 virtual void OnDelegatedFrameDamage( | 186 virtual void OnDelegatedFrameDamage( |
| 187 const gfx::Rect& damage_rect_in_dip) OVERRIDE {} | 187 const gfx::Rect& damage_rect_in_dip) OVERRIDE {} |
| 188 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | 188 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
| 189 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE; | 189 virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE; |
| 190 | 190 |
| 191 private: | 191 private: |
| 192 ui::Layer layer_; | 192 ui::Layer layer_; |
| 193 SkScalar corner_radius_; | 193 int corner_radius_; |
| 194 | 194 |
| 195 DISALLOW_COPY_AND_ASSIGN(TrayBubbleContentMask); | 195 DISALLOW_COPY_AND_ASSIGN(TrayBubbleContentMask); |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 TrayBubbleContentMask::TrayBubbleContentMask(int corner_radius) | 198 TrayBubbleContentMask::TrayBubbleContentMask(int corner_radius) |
| 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(gfx::Canvas* canvas) { | 208 void TrayBubbleContentMask::OnPaintLayer(gfx::Canvas* canvas) { |
| 209 SkPath path; | |
| 210 path.addRoundRect(gfx::RectToSkRect(gfx::Rect(layer()->bounds().size())), | |
| 211 corner_radius_, corner_radius_); | |
| 212 SkPaint paint; | 209 SkPaint paint; |
| 213 paint.setAlpha(255); | 210 paint.setAlpha(255); |
| 214 paint.setStyle(SkPaint::kFill_Style); | 211 paint.setStyle(SkPaint::kFill_Style); |
| 215 canvas->DrawPath(path, paint); | 212 gfx::Rect rect(layer()->bounds().size()); |
| 213 canvas->DrawRoundRect(rect, corner_radius_, paint); |
| 216 } | 214 } |
| 217 | 215 |
| 218 void TrayBubbleContentMask::OnDeviceScaleFactorChanged( | 216 void TrayBubbleContentMask::OnDeviceScaleFactorChanged( |
| 219 float device_scale_factor) { | 217 float device_scale_factor) { |
| 220 // Redrawing will take care of scale factor change. | 218 // Redrawing will take care of scale factor change. |
| 221 } | 219 } |
| 222 | 220 |
| 223 base::Closure TrayBubbleContentMask::PrepareForLayerBoundsChange() { | 221 base::Closure TrayBubbleContentMask::PrepareForLayerBoundsChange() { |
| 224 return base::Closure(); | 222 return base::Closure(); |
| 225 } | 223 } |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 void TrayBubbleView::ViewHierarchyChanged( | 499 void TrayBubbleView::ViewHierarchyChanged( |
| 502 const ViewHierarchyChangedDetails& details) { | 500 const ViewHierarchyChangedDetails& details) { |
| 503 if (details.is_add && details.child == this) { | 501 if (details.is_add && details.child == this) { |
| 504 details.parent->SetPaintToLayer(true); | 502 details.parent->SetPaintToLayer(true); |
| 505 details.parent->SetFillsBoundsOpaquely(true); | 503 details.parent->SetFillsBoundsOpaquely(true); |
| 506 details.parent->layer()->SetMasksToBounds(true); | 504 details.parent->layer()->SetMasksToBounds(true); |
| 507 } | 505 } |
| 508 } | 506 } |
| 509 | 507 |
| 510 } // namespace views | 508 } // namespace views |
| OLD | NEW |