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

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

Issue 1543593002: Forward fill and stroke styles from 2d canvas to canvas filters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 RGBA32 CanvasStyle::paintColor() const 130 RGBA32 CanvasStyle::paintColor() const
131 { 131 {
132 if (m_type == ColorRGBA) 132 if (m_type == ColorRGBA)
133 return m_rgba; 133 return m_rgba;
134 ASSERT(m_type == Gradient || m_type == ImagePattern); 134 ASSERT(m_type == Gradient || m_type == ImagePattern);
135 return Color::black; 135 return Color::black;
136 } 136 }
137 137
138 PassRefPtr<SkShader> CanvasStyle::asShader() const
139 {
140 switch (m_type) {
141 case ColorRGBA:
142 return adoptRef(SkShader::CreateColorShader(m_rgba));
143 case Gradient: {
144 SkPaint paint;
145 canvasGradient()->gradient()->applyToPaint(paint);
146 return paint.getShader();
147 }
148 case ImagePattern: {
149 SkPaint paint;
150 canvasPattern()->pattern()->applyToPaint(paint);
151 return paint.getShader();
152 }
153 default:
154 ASSERT_NOT_REACHED();
155 }
156 return nullptr;
157 }
158
138 DEFINE_TRACE(CanvasStyle) 159 DEFINE_TRACE(CanvasStyle)
139 { 160 {
140 visitor->trace(m_gradient); 161 visitor->trace(m_gradient);
141 visitor->trace(m_pattern); 162 visitor->trace(m_pattern);
142 } 163 }
143 164
144 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698