Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/shadow_border.h" | |
| 6 | |
| 7 #include "ui/gfx/canvas.h" | |
| 8 #include "ui/gfx/insets.h" | |
| 9 #include "ui/gfx/shadow_value.h" | |
| 10 #include "ui/gfx/skia_util.h" | |
| 11 | |
| 12 namespace views { | |
| 13 | |
| 14 ShadowBorder::ShadowBorder(int blur, | |
| 15 SkColor color, | |
| 16 int vertical_offset, | |
| 17 int horizontal_offset) | |
| 18 : views::Border(), | |
| 19 blur_(blur), | |
| 20 color_(color), | |
| 21 vertical_offset_(vertical_offset), | |
| 22 horizontal_offset_(horizontal_offset) {} | |
| 23 | |
| 24 ShadowBorder::~ShadowBorder() {} | |
| 25 | |
| 26 void ShadowBorder::Paint(const views::View& view, gfx::Canvas* canvas) { | |
| 27 SkPaint paint; | |
|
msw
2013/07/13 01:21:36
Re-painting a shadow looper on every paint call ma
| |
| 28 std::vector<gfx::ShadowValue> shadows; | |
| 29 shadows.push_back(gfx::ShadowValue(gfx::Point(), blur_, color_)); | |
| 30 skia::RefPtr<SkDrawLooper> looper = gfx::CreateShadowDrawLooper(shadows); | |
| 31 paint.setLooper(looper.get()); | |
| 32 paint.setColor(SK_ColorTRANSPARENT); | |
| 33 paint.setStrokeJoin(SkPaint::kRound_Join); | |
| 34 gfx::Rect bounds(view.size()); | |
| 35 bounds.Inset(gfx::Insets(blur_ / 2, blur_ / 2, blur_ / 2, blur_ / 2)); | |
| 36 canvas->DrawRect(bounds, paint); | |
| 37 } | |
| 38 | |
| 39 gfx::Insets ShadowBorder::GetInsets() const { | |
| 40 return gfx::Insets(blur_ / 2 - vertical_offset_, | |
| 41 blur_ / 2 - horizontal_offset_, | |
| 42 blur_ / 2 + vertical_offset_, | |
| 43 blur_ / 2 + horizontal_offset_); | |
| 44 } | |
| 45 | |
| 46 } // namespace views | |
| OLD | NEW |