| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "modules/canvas2d/CanvasStyle.h" | 29 #include "modules/canvas2d/CanvasStyle.h" |
| 30 | 30 |
| 31 #include "core/CSSPropertyNames.h" | 31 #include "core/CSSPropertyNames.h" |
| 32 #include "core/css/StylePropertySet.h" | 32 #include "core/css/StylePropertySet.h" |
| 33 #include "core/css/parser/CSSParser.h" | 33 #include "core/css/parser/CSSParser.h" |
| 34 #include "core/html/HTMLCanvasElement.h" | 34 #include "core/html/HTMLCanvasElement.h" |
| 35 #include "core/html/parser/HTMLParserIdioms.h" | 35 #include "core/html/parser/HTMLParserIdioms.h" |
| 36 #include "modules/canvas2d/CanvasGradient.h" | 36 #include "modules/canvas2d/CanvasGradient.h" |
| 37 #include "modules/canvas2d/CanvasPattern.h" | 37 #include "modules/canvas2d/CanvasPattern.h" |
| 38 #include "platform/graphics/paint/PaintFlags.h" |
| 38 #include "platform/graphics/skia/SkiaUtils.h" | 39 #include "platform/graphics/skia/SkiaUtils.h" |
| 39 #include "third_party/skia/include/core/SkShader.h" | 40 #include "third_party/skia/include/core/SkShader.h" |
| 40 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 enum ColorParseResult { | 45 enum ColorParseResult { |
| 45 ParsedRGBA, | 46 ParsedRGBA, |
| 46 ParsedCurrentColor, | 47 ParsedCurrentColor, |
| 47 ParsedSystemColor, | 48 ParsedSystemColor, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 CanvasStyle* CanvasStyle::createFromGradient(CanvasGradient* gradient) { | 101 CanvasStyle* CanvasStyle::createFromGradient(CanvasGradient* gradient) { |
| 101 ASSERT(gradient); | 102 ASSERT(gradient); |
| 102 return new CanvasStyle(gradient); | 103 return new CanvasStyle(gradient); |
| 103 } | 104 } |
| 104 | 105 |
| 105 CanvasStyle* CanvasStyle::createFromPattern(CanvasPattern* pattern) { | 106 CanvasStyle* CanvasStyle::createFromPattern(CanvasPattern* pattern) { |
| 106 ASSERT(pattern); | 107 ASSERT(pattern); |
| 107 return new CanvasStyle(pattern); | 108 return new CanvasStyle(pattern); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void CanvasStyle::applyToPaint(SkPaint& paint) const { | 111 void CanvasStyle::applyToPaint(PaintFlags& paint) const { |
| 111 switch (m_type) { | 112 switch (m_type) { |
| 112 case ColorRGBA: | 113 case ColorRGBA: |
| 113 paint.setShader(nullptr); | 114 paint.setShader(nullptr); |
| 114 break; | 115 break; |
| 115 case Gradient: | 116 case Gradient: |
| 116 getCanvasGradient()->getGradient()->applyToPaint(paint, SkMatrix::I()); | 117 getCanvasGradient()->getGradient()->applyToPaint(paint, SkMatrix::I()); |
| 117 break; | 118 break; |
| 118 case ImagePattern: | 119 case ImagePattern: |
| 119 getCanvasPattern()->getPattern()->applyToPaint( | 120 getCanvasPattern()->getPattern()->applyToPaint( |
| 120 paint, affineTransformToSkMatrix(getCanvasPattern()->getTransform())); | 121 paint, affineTransformToSkMatrix(getCanvasPattern()->getTransform())); |
| 121 break; | 122 break; |
| 122 default: | 123 default: |
| 123 ASSERT_NOT_REACHED(); | 124 ASSERT_NOT_REACHED(); |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 | 127 |
| 127 RGBA32 CanvasStyle::paintColor() const { | 128 RGBA32 CanvasStyle::paintColor() const { |
| 128 if (m_type == ColorRGBA) | 129 if (m_type == ColorRGBA) |
| 129 return m_rgba; | 130 return m_rgba; |
| 130 ASSERT(m_type == Gradient || m_type == ImagePattern); | 131 ASSERT(m_type == Gradient || m_type == ImagePattern); |
| 131 return Color::black; | 132 return Color::black; |
| 132 } | 133 } |
| 133 | 134 |
| 134 DEFINE_TRACE(CanvasStyle) { | 135 DEFINE_TRACE(CanvasStyle) { |
| 135 visitor->trace(m_gradient); | 136 visitor->trace(m_gradient); |
| 136 visitor->trace(m_pattern); | 137 visitor->trace(m_pattern); |
| 137 } | 138 } |
| 138 | 139 |
| 139 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |