| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/ink_drop_painted_layer_delegates.h" | 5 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkDrawLooper.h" | 7 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
| 9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
| 10 #include "ui/compositor/paint_recorder.h" | 10 #include "ui/compositor/paint_recorder.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 total_rect.Inset(gfx::ShadowValue::GetMargin(shadows_)); | 146 total_rect.Inset(gfx::ShadowValue::GetMargin(shadows_)); |
| 147 return total_rect; | 147 return total_rect; |
| 148 } | 148 } |
| 149 | 149 |
| 150 gfx::Vector2dF BorderShadowLayerDelegate::GetCenteringOffset() const { | 150 gfx::Vector2dF BorderShadowLayerDelegate::GetCenteringOffset() const { |
| 151 return gfx::RectF(bounds_).CenterPoint().OffsetFromOrigin(); | 151 return gfx::RectF(bounds_).CenterPoint().OffsetFromOrigin(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void BorderShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { | 154 void BorderShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { |
| 155 SkPaint paint; | 155 SkPaint paint; |
| 156 paint.setLooper(gfx::CreateShadowDrawLooper(shadows_)); | 156 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows_)); |
| 157 paint.setStyle(SkPaint::kStrokeAndFill_Style); | 157 paint.setStyle(SkPaint::kStrokeAndFill_Style); |
| 158 paint.setAntiAlias(true); | 158 paint.setAntiAlias(true); |
| 159 paint.setColor(SK_ColorTRANSPARENT); | 159 paint.setColor(SK_ColorTRANSPARENT); |
| 160 paint.setStrokeJoin(SkPaint::kRound_Join); | 160 paint.setStrokeJoin(SkPaint::kRound_Join); |
| 161 gfx::RectF bounds(bounds_); | 161 SkRect path_bounds = gfx::RectFToSkRect( |
| 162 bounds -= GetPaintedBounds().OffsetFromOrigin(); | 162 gfx::RectF(bounds_ - GetPaintedBounds().OffsetFromOrigin())); |
| 163 gfx::RectF stroke_bounds = bounds; | |
| 164 stroke_bounds.Inset(-gfx::InsetsF(0.5f)); | |
| 165 | 163 |
| 166 ui::PaintRecorder recorder(context, GetPaintedBounds().size()); | 164 ui::PaintRecorder recorder(context, GetPaintedBounds().size()); |
| 167 const SkScalar corner = SkFloatToScalar(corner_radius_); | 165 const SkScalar corner = SkFloatToScalar(corner_radius_); |
| 168 SkPath path; | 166 SkPath path; |
| 169 path.addRoundRect(gfx::RectFToSkRect(stroke_bounds), corner, corner, | 167 path.addRoundRect(path_bounds, corner, corner, SkPath::kCCW_Direction); |
| 170 SkPath::kCCW_Direction); | |
| 171 recorder.canvas()->DrawPath(path, paint); | 168 recorder.canvas()->DrawPath(path, paint); |
| 172 | 169 |
| 173 SkPaint clear_paint; | 170 SkPaint clear_paint; |
| 174 clear_paint.setAntiAlias(true); | 171 clear_paint.setAntiAlias(true); |
| 175 clear_paint.setXfermodeMode(SkXfermode::kClear_Mode); | 172 clear_paint.setXfermodeMode(SkXfermode::kClear_Mode); |
| 176 recorder.canvas()->sk_canvas()->drawRoundRect(gfx::RectFToSkRect(bounds), | 173 recorder.canvas()->sk_canvas()->drawRoundRect(path_bounds, corner, corner, |
| 177 corner, corner, clear_paint); | 174 clear_paint); |
| 178 } | 175 } |
| 179 | 176 |
| 180 } // namespace views | 177 } // namespace views |
| OLD | NEW |