| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/gfx/shadow_util.h" | 5 #include "ui/gfx/shadow_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "third_party/skia/include/core/SkDrawLooper.h" | 11 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 12 #include "third_party/skia/include/core/SkRRect.h" | 12 #include "third_party/skia/include/core/SkRRect.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/geometry/insets.h" | 14 #include "ui/gfx/geometry/insets.h" |
| 15 #include "ui/gfx/image/canvas_image_source.h" | 15 #include "ui/gfx/image/canvas_image_source.h" |
| 16 #include "ui/gfx/shadow_value.h" | 16 #include "ui/gfx/shadow_value.h" |
| 17 #include "ui/gfx/skia_paint_util.h" |
| 17 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Creates an image with the given shadows painted around a round rect with | 23 // Creates an image with the given shadows painted around a round rect with |
| 23 // the given corner radius. The image will be just large enough to paint the | 24 // the given corner radius. The image will be just large enough to paint the |
| 24 // shadows appropriately with a 1px square region reserved for "content". | 25 // shadows appropriately with a 1px square region reserved for "content". |
| 25 class ShadowNineboxSource : public CanvasImageSource { | 26 class ShadowNineboxSource : public CanvasImageSource { |
| 26 public: | 27 public: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 SkColorSetA(SK_ColorBLACK, 0x1f)); | 105 SkColorSetA(SK_ColorBLACK, 0x1f)); |
| 105 // To see what this looks like for elevation 24, try this CSS: | 106 // To see what this looks like for elevation 24, try this CSS: |
| 106 // box-shadow: 0 24px 48px rgba(0, 0, 0, .24), | 107 // box-shadow: 0 24px 48px rgba(0, 0, 0, .24), |
| 107 // 0 0 24px rgba(0, 0, 0, .12); | 108 // 0 0 24px rgba(0, 0, 0, .12); |
| 108 auto source = new ShadowNineboxSource(shadow->values, corner_radius); | 109 auto source = new ShadowNineboxSource(shadow->values, corner_radius); |
| 109 shadow->ninebox_image = ImageSkia(source, source->size()); | 110 shadow->ninebox_image = ImageSkia(source, source->size()); |
| 110 return *shadow; | 111 return *shadow; |
| 111 } | 112 } |
| 112 | 113 |
| 113 } // namespace gfx | 114 } // namespace gfx |
| OLD | NEW |