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

Unified Diff: third_party/WebKit/Source/platform/graphics/Gradient.cpp

Issue 1789063005: Add sk_sp helpers and switch Blink SkShader clients to the new APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove rval refs from comments Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/Gradient.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Gradient.cpp b/third_party/WebKit/Source/platform/graphics/Gradient.cpp
index 9736e023b34a5b6db7b8510a48288c9f8ecedcb6..fb7de8c3125da650f9620f2d624e7b757c3928fd 100644
--- a/third_party/WebKit/Source/platform/graphics/Gradient.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Gradient.cpp
@@ -189,10 +189,10 @@ static void fillStops(const Gradient::ColorStop* stopData,
}
}
-SkShader* Gradient::shader()
+PassRefPtr<SkShader> Gradient::refShader()
{
if (m_gradient)
- return m_gradient.get();
+ return m_gradient;
sortStopsIfNecessary();
ASSERT(m_stopsSorted);
@@ -233,32 +233,33 @@ SkShader* Gradient::shader()
// Since the two-point radial gradient is slower than the plain radial,
// only use it if we have to.
if (m_p0 == m_p1 && m_r0 <= 0.0f) {
- m_gradient = adoptRef(SkGradientShader::CreateRadial(m_p1.data(), m_r1, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix));
+ m_gradient = adoptRef(SkGradientShader::MakeRadial(m_p1.data(), m_r1, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix));
} else {
// The radii we give to Skia must be positive. If we're given a
// negative radius, ask for zero instead.
SkScalar radius0 = m_r0 >= 0.0f ? WebCoreFloatToSkScalar(m_r0) : 0;
SkScalar radius1 = m_r1 >= 0.0f ? WebCoreFloatToSkScalar(m_r1) : 0;
- m_gradient = adoptRef(SkGradientShader::CreateTwoPointConical(m_p0.data(), radius0, m_p1.data(), radius1, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix));
+ m_gradient = adoptRef(SkGradientShader::MakeTwoPointConical(m_p0.data(), radius0, m_p1.data(), radius1, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix));
}
} else {
SkPoint pts[2] = { m_p0.data(), m_p1.data() };
SkMatrix localMatrix = affineTransformToSkMatrix(m_gradientSpaceTransformation);
- m_gradient = adoptRef(SkGradientShader::CreateLinear(pts, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix));
+ m_gradient = adoptRef(SkGradientShader::MakeLinear(pts, colors.data(), pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix));
}
if (!m_gradient) {
// use last color, since our "geometry" was degenerate (e.g. radius==0)
- m_gradient = adoptRef(SkShader::CreateColorShader(colors[countUsed - 1]));
+ m_gradient = adoptRef(SkShader::MakeColorShader(colors[countUsed - 1]));
}
- return m_gradient.get();
+ return m_gradient;
}
void Gradient::applyToPaint(SkPaint& paint)
{
- paint.setShader(shader());
+ paint.setShader(adoptSkSp<SkShader>(refShader()));
jbroman 2016/03/16 17:47:02 Does this not work without the explicit type param
f(malita) 2016/03/16 18:17:43 Doh, it sure does for PassRefPtr. I got carried a
// Legacy behavior: gradients are always dithered.
paint.setDither(true);
}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Gradient.h ('k') | third_party/WebKit/Source/platform/graphics/GraphicsContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698