| 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 19 matching lines...) Expand all Loading... |
| 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 "modules/canvas2d/CanvasGradient.h" | 35 #include "modules/canvas2d/CanvasGradient.h" |
| 36 #include "modules/canvas2d/CanvasPattern.h" | 36 #include "modules/canvas2d/CanvasPattern.h" |
| 37 #include "platform/graphics/skia/SkiaUtils.h" | 37 #include "platform/graphics/skia/SkiaUtils.h" |
| 38 #include "third_party/skia/include/core/SkShader.h" | 38 #include "third_party/skia/include/core/SkShader.h" |
| 39 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 40 #include "skia/ext/cdl_paint.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 enum ColorParseResult { | 44 enum ColorParseResult { |
| 44 ParsedRGBA, | 45 ParsedRGBA, |
| 45 ParsedCurrentColor, | 46 ParsedCurrentColor, |
| 46 ParsedSystemColor, | 47 ParsedSystemColor, |
| 47 ParseFailed | 48 ParseFailed |
| 48 }; | 49 }; |
| 49 | 50 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 CanvasStyle* CanvasStyle::createFromGradient(CanvasGradient* gradient) { | 99 CanvasStyle* CanvasStyle::createFromGradient(CanvasGradient* gradient) { |
| 99 ASSERT(gradient); | 100 ASSERT(gradient); |
| 100 return new CanvasStyle(gradient); | 101 return new CanvasStyle(gradient); |
| 101 } | 102 } |
| 102 | 103 |
| 103 CanvasStyle* CanvasStyle::createFromPattern(CanvasPattern* pattern) { | 104 CanvasStyle* CanvasStyle::createFromPattern(CanvasPattern* pattern) { |
| 104 ASSERT(pattern); | 105 ASSERT(pattern); |
| 105 return new CanvasStyle(pattern); | 106 return new CanvasStyle(pattern); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void CanvasStyle::applyToPaint(SkPaint& paint) const { | 109 void CanvasStyle::applyToPaint(CdlPaint& paint) const { |
| 109 switch (m_type) { | 110 switch (m_type) { |
| 110 case ColorRGBA: | 111 case ColorRGBA: |
| 111 paint.setShader(nullptr); | 112 paint.setShader(nullptr); |
| 112 break; | 113 break; |
| 113 case Gradient: | 114 case Gradient: |
| 114 getCanvasGradient()->getGradient()->applyToPaint(paint, SkMatrix::I()); | 115 getCanvasGradient()->getGradient()->applyToPaint(paint, SkMatrix::I()); |
| 115 break; | 116 break; |
| 116 case ImagePattern: | 117 case ImagePattern: |
| 117 getCanvasPattern()->getPattern()->applyToPaint( | 118 getCanvasPattern()->getPattern()->applyToPaint( |
| 118 paint, affineTransformToSkMatrix(getCanvasPattern()->getTransform())); | 119 paint, affineTransformToSkMatrix(getCanvasPattern()->getTransform())); |
| 119 break; | 120 break; |
| 120 default: | 121 default: |
| 121 ASSERT_NOT_REACHED(); | 122 ASSERT_NOT_REACHED(); |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 | 125 |
| 125 RGBA32 CanvasStyle::paintColor() const { | 126 RGBA32 CanvasStyle::paintColor() const { |
| 126 if (m_type == ColorRGBA) | 127 if (m_type == ColorRGBA) |
| 127 return m_rgba; | 128 return m_rgba; |
| 128 ASSERT(m_type == Gradient || m_type == ImagePattern); | 129 ASSERT(m_type == Gradient || m_type == ImagePattern); |
| 129 return Color::black; | 130 return Color::black; |
| 130 } | 131 } |
| 131 | 132 |
| 132 DEFINE_TRACE(CanvasStyle) { | 133 DEFINE_TRACE(CanvasStyle) { |
| 133 visitor->trace(m_gradient); | 134 visitor->trace(m_gradient); |
| 134 visitor->trace(m_pattern); | 135 visitor->trace(m_pattern); |
| 135 } | 136 } |
| 136 | 137 |
| 137 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |