OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkSVGAttribute.h" | 9 #include "SkSVGAttribute.h" |
10 #include "SkSVGRenderContext.h" | 10 #include "SkSVGRenderContext.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 ApplyLazyInheritedAttribute(Fill); | 218 ApplyLazyInheritedAttribute(Fill); |
219 ApplyLazyInheritedAttribute(FillOpacity); | 219 ApplyLazyInheritedAttribute(FillOpacity); |
220 ApplyLazyInheritedAttribute(Stroke); | 220 ApplyLazyInheritedAttribute(Stroke); |
221 ApplyLazyInheritedAttribute(StrokeLineCap); | 221 ApplyLazyInheritedAttribute(StrokeLineCap); |
222 ApplyLazyInheritedAttribute(StrokeLineJoin); | 222 ApplyLazyInheritedAttribute(StrokeLineJoin); |
223 ApplyLazyInheritedAttribute(StrokeOpacity); | 223 ApplyLazyInheritedAttribute(StrokeOpacity); |
224 ApplyLazyInheritedAttribute(StrokeWidth); | 224 ApplyLazyInheritedAttribute(StrokeWidth); |
225 | 225 |
226 #undef ApplyLazyInheritedAttribute | 226 #undef ApplyLazyInheritedAttribute |
| 227 |
| 228 // Uninherited attributes. Only apply to the current context. |
| 229 |
| 230 if (auto* opacity = attrs.fOpacity.getMaybeNull()) { |
| 231 SkPaint opacityPaint; |
| 232 opacityPaint.setAlpha(static_cast<uint8_t>(opacity->value() * 255)); |
| 233 // Balanced in the destructor, via restoreToCount(). |
| 234 fCanvas->saveLayer(nullptr, &opacityPaint); |
| 235 } |
227 } | 236 } |
228 | 237 |
229 const SkPaint* SkSVGRenderContext::fillPaint() const { | 238 const SkPaint* SkSVGRenderContext::fillPaint() const { |
230 const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fFill.ge
t()->type(); | 239 const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fFill.ge
t()->type(); |
231 return paintType != SkSVGPaint::Type::kNone ? &fPresentationContext->fFillPa
int : nullptr; | 240 return paintType != SkSVGPaint::Type::kNone ? &fPresentationContext->fFillPa
int : nullptr; |
232 } | 241 } |
233 | 242 |
234 const SkPaint* SkSVGRenderContext::strokePaint() const { | 243 const SkPaint* SkSVGRenderContext::strokePaint() const { |
235 const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fStroke.
get()->type(); | 244 const SkSVGPaint::Type paintType = fPresentationContext->fInherited.fStroke.
get()->type(); |
236 return paintType != SkSVGPaint::Type::kNone ? &fPresentationContext->fStroke
Paint : nullptr; | 245 return paintType != SkSVGPaint::Type::kNone ? &fPresentationContext->fStroke
Paint : nullptr; |
237 } | 246 } |
OLD | NEW |