| OLD | NEW |
| 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 "ui/views/shadow_border.h" | 5 #include "ui/views/shadow_border.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkDrawLooper.h" | 7 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/geometry/insets.h" | 9 #include "ui/gfx/geometry/insets.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 shadow_value_(shadow), | 28 shadow_value_(shadow), |
| 29 insets_(GetInsetsFromShadowValue(shadow)) { | 29 insets_(GetInsetsFromShadowValue(shadow)) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 ShadowBorder::~ShadowBorder() { | 32 ShadowBorder::~ShadowBorder() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 // TODO(sidharthms): Re-painting a shadow looper on every paint call may yield | 35 // TODO(sidharthms): Re-painting a shadow looper on every paint call may yield |
| 36 // poor performance. Ideally we should be caching the border to bitmaps. | 36 // poor performance. Ideally we should be caching the border to bitmaps. |
| 37 void ShadowBorder::Paint(const views::View& view, gfx::Canvas* canvas) { | 37 void ShadowBorder::Paint(const views::View& view, gfx::Canvas* canvas) { |
| 38 cc::PaintFlags paint; | 38 cc::PaintFlags flags; |
| 39 std::vector<gfx::ShadowValue> shadows; | 39 std::vector<gfx::ShadowValue> shadows; |
| 40 shadows.push_back(shadow_value_); | 40 shadows.push_back(shadow_value_); |
| 41 paint.setLooper(gfx::CreateShadowDrawLooper(shadows)); | 41 flags.setLooper(gfx::CreateShadowDrawLooper(shadows)); |
| 42 paint.setColor(SK_ColorTRANSPARENT); | 42 flags.setColor(SK_ColorTRANSPARENT); |
| 43 paint.setStrokeJoin(cc::PaintFlags::kRound_Join); | 43 flags.setStrokeJoin(cc::PaintFlags::kRound_Join); |
| 44 gfx::Rect bounds(view.size()); | 44 gfx::Rect bounds(view.size()); |
| 45 bounds.Inset(-gfx::ShadowValue::GetMargin(shadows)); | 45 bounds.Inset(-gfx::ShadowValue::GetMargin(shadows)); |
| 46 canvas->DrawRect(bounds, paint); | 46 canvas->DrawRect(bounds, flags); |
| 47 } | 47 } |
| 48 | 48 |
| 49 gfx::Insets ShadowBorder::GetInsets() const { | 49 gfx::Insets ShadowBorder::GetInsets() const { |
| 50 return insets_; | 50 return insets_; |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::Size ShadowBorder::GetMinimumSize() const { | 53 gfx::Size ShadowBorder::GetMinimumSize() const { |
| 54 return gfx::Size(shadow_value_.blur(), shadow_value_.blur()); | 54 return gfx::Size(shadow_value_.blur(), shadow_value_.blur()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace views | 57 } // namespace views |
| OLD | NEW |