Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasStyle.cpp

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasStyle.h ('k') | third_party/WebKit/Source/modules/canvas2d/ClipList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698