1c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org/* 2c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org * Copyright 2014 Google Inc. 3c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org * 4c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 5c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org * found in the LICENSE file. 6c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org */ 783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org 8c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org#include "gm.h" 9c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org#include "SkGradientShader.h" 10c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 11c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgnamespace skiagm { 12c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 13c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstruct GradData { 14c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org int fCount; 15c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const SkColor* fColors; 16c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const SkScalar* fPos; 17c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 18c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 19c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const SkColor gColors[] = { 20c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK 21c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 22c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const SkScalar gPos0[] = { 0, SK_Scalar1 }; 23c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 }; 24c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const SkScalar gPos2[] = { 25c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1 26c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 27c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 28c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f}; 29c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const SkColor gColorClamp[] = { 30c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE 31c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 32c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 33c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const GradData gGradData[] = { 34c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { 2, gColors, gPos0 }, 35c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { 2, gColors, gPos1 }, 36c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { 5, gColors, gPos2 }, 37c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { 4, gColorClamp, gPosClamp } 38c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 39c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 40c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data, 4183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 42c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 4380ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; 4480ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 45c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 46c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 47c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 48c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 49c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 5083f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 51c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 52c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 53c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data, 5483f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 55c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 5680ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; 5780ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 58c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 59c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 60c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center1, radius1, 61c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0, radius0, 62c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 6383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 64c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 65c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 66c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalInside(const SkPoint pts[2], const GradData& data, 6783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 68c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 69c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 70c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 71c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 72c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 739c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7, 749c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center0, (pts[1].fX - pts[0].fX) / 2, 7583f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 769c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 77c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 78c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 79c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data, 8083f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 81c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 82c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 83c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 84c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 85c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 869c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 2, 879c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center1, (pts[1].fX - pts[0].fX) / 7, 8883f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 899c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 90c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 91c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 92c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data, 9383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 94c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 95c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 96c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 97c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 98c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 999c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 7, 1009c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center0, (pts[1].fX - pts[0].fX) / 2, 10183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 1029c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 103c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 104c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 105c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data, 10683f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 107c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 108c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 109c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 110c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 111c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 1129c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center1, 0.f, 1139c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center0, (pts[1].fX - pts[0].fX) / 2, 11483f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 1159c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 116c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 117c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 118c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data, 11983f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 120c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 121c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 122c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 123c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 124c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 1259c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 2, 1269c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center0, 0.f, 12783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 1289c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 129c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 130c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 131c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data, 13283f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 133c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 134c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 135c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 136c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 137c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 1389c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, 0.f, 1399c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center0, (pts[1].fX - pts[0].fX) / 2, 14083f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 1419c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 142c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 143c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 144c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data, 14583f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 146c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 14780894678ca7b54413ba50de4355b7816d5bc0e10commit-bot@chromium.org SkScalar radius0 = 0.f; 14880ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 149c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 150c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 151c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 152c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 153c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 15483f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 155c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 156c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 157c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data, 15883f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 159c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 16080894678ca7b54413ba50de4355b7816d5bc0e10commit-bot@chromium.org SkScalar radius0 = 0.f; 16180ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 162c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 163c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 164c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center1, radius1, 165c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0, radius0, 166c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 16783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 168c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 169c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 170c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data, 17183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 172c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 17380ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; 17480ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 175c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarAve(pts[0].fX, pts[1].fX), 176c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 177c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(center1.fX + radius1, center1.fY); 178c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 179c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 180c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 18183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 182c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 183c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 184c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data, 18583f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 186c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 18780ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; 18880ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 189c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarAve(pts[0].fX, pts[1].fX), 190c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 191c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(center1.fX, center1.fY + radius1); 192c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 193c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 194c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 19583f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 196c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 1978405ef9854858b2527bf03b7e7abb1c0da59411degdaniel 198c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data, 19983f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 200c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 20180894678ca7b54413ba50de4355b7816d5bc0e10commit-bot@chromium.org SkScalar radius0 = 0.f; 20280ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 203c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarAve(pts[0].fX, pts[1].fX), 204c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 205c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(center1.fX + radius1, center1.fY); 206c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 207c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 208c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 20983f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 210c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 211c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 212c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data, 21383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 214c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 21580894678ca7b54413ba50de4355b7816d5bc0e10commit-bot@chromium.org SkScalar radius0 = 0.f; 21680ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 217c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarAve(pts[0].fX, pts[1].fX), 218c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 219c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(center1.fX, center1.fY + radius1); 220c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 221c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 222c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 22383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 224c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 225c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 226c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data, 22783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 228c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 22980ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; 23080ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 231c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarAve(pts[0].fX, pts[1].fX), 232c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 233c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(center1.fX - radius1 + radius0, center1.fY); 234c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 235c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 236c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 23783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 238c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 239c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 240c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data, 24183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 242c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 24380ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7; 24480ea19ca4bdd68c1493666a5fe7e4ce9d43ded8breed SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; 245c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarAve(pts[0].fX, pts[1].fX), 246c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 247c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(center1.fX, center1.fY + radius1 - radius0); 248c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, radius0, 249c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1, radius1, 250c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org data.fColors, data.fPos, 25183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fCount, tm, 0, &localMatrix); 252c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 253c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 254c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic SkShader* Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data, 25583f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix) { 256c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint center0, center1; 257c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 258c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarAve(pts[0].fY, pts[1].fY)); 259c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 260c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 2619c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org return SkGradientShader::CreateTwoPointConical(center0, 0.0000000000000000001f, 2629c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org center0, (pts[1].fX - pts[0].fX) / 2, 26383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org data.fColors, data.fPos, data.fCount, tm, 2649c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org 0, &localMatrix); 265c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 266c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 267c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgtypedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, 26883f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader::TileMode tm, const SkMatrix& localMatrix); 269c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 270c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const GradMaker gGradMakersOutside[] = { 271c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalOutside, Make2ConicalOutsideFlip, 272c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalZeroRadOutside, Make2ConicalZeroRadFlipOutside 273c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 274c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 275c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const GradMaker gGradMakersInside[] = { 276c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalInside, Make2ConicalInsideFlip, Make2ConicalInsideCenter, 277c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalZeroRad, Make2ConicalZeroRadFlip, Make2ConicalZeroRadCenter, 278c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 279c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 280c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const GradMaker gGradMakersEdgeCases[] = { 281c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalEdgeX, Make2ConicalEdgeY, 282c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalZeroRadEdgeX, Make2ConicalZeroRadEdgeY, 283c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalTouchX, Make2ConicalTouchY, 284c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org Make2ConicalInsideSmallRad 285c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 286c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 287c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 288c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic const struct { 289c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const GradMaker* fMaker; 290c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const int fCount; 291c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const char* fName; 292c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} gGradCases[] = { 293c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { gGradMakersOutside, SK_ARRAY_COUNT(gGradMakersOutside), "outside" }, 294c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { gGradMakersInside, SK_ARRAY_COUNT(gGradMakersInside), "inside" }, 295c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { gGradMakersEdgeCases, SK_ARRAY_COUNT(gGradMakersEdgeCases), "edge" }, 296c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 297c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 298c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgenum GradCaseType { // these must match the order in gGradCases 299c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org kOutside_GradCaseType, 300c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org kInside_GradCaseType, 301c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org kEdge_GradCaseType, 302c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 303c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 304c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org/////////////////////////////////////////////////////////////////////////////// 305c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 306c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgclass ConicalGradientsGM : public GM { 307c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgpublic: 308c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org ConicalGradientsGM(GradCaseType gradCaseType) { 309c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org this->setBGColor(0xFFDDDDDD); 310c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org fName.printf("gradients_2pt_conical_%s", gGradCases[gradCaseType].fName); 311c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org fGradCaseType = gradCaseType; 312c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org } 313c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 314c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgprotected: 315c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkString onShortName() { 316c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org return fName; 317c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org } 318c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 319c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org virtual SkISize onISize() { return SkISize::Make(840, 815); } 320c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 321c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org virtual void onDraw(SkCanvas* canvas) { 322c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 323c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPoint pts[2] = { 324c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { 0, 0 }, 325c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org { SkIntToScalar(100), SkIntToScalar(100) } 326c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org }; 327c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkShader::TileMode tm = SkShader::kClamp_TileMode; 328c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; 329c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkPaint paint; 330c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org paint.setAntiAlias(true); 331c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 332c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); 333c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 334c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const GradMaker* gradMaker = gGradCases[fGradCaseType].fMaker; 335c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org const int count = gGradCases[fGradCaseType].fCount; 336c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 337c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) { 338c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org canvas->save(); 339c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org for (int j = 0; j < count; j++) { 3409c9005a347e9996f357bd79591bd34f74f8bbc66commit-bot@chromium.org SkMatrix scale = SkMatrix::I(); 341c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 342c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org if (i == 3) { // if the clamp case 343c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org scale.setScale(0.5f, 0.5f); 344c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org scale.postTranslate(25.f, 25.f); 345c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org } 346c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 34783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org SkShader* shader = gradMaker[j](pts, gGradData[i], tm, scale); 348c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org paint.setShader(shader); 349c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org canvas->drawRect(r, paint); 350c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org shader->unref(); 351c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org canvas->translate(0, SkIntToScalar(120)); 352c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org } 353c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org canvas->restore(); 354c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org canvas->translate(SkIntToScalar(120), 0); 355c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org } 356c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org } 357c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 358c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgprivate: 359c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org typedef GM INHERITED; 360c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 361c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org GradCaseType fGradCaseType; 362c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org SkString fName; 363c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org}; 364c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org/////////////////////////////////////////////////////////////////////////////// 365c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 366c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic GM* MyFactory1(void*) { return new ConicalGradientsGM(kInside_GradCaseType); } 367c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic GMRegistry reg1(MyFactory1); 368c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 369c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic GM* MyFactory2(void*) { return new ConicalGradientsGM(kOutside_GradCaseType); } 370c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic GMRegistry reg2(MyFactory2); 371c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org 372c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic GM* MyFactory3(void*) { return new ConicalGradientsGM(kEdge_GradCaseType); } 373c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.orgstatic GMRegistry reg3(MyFactory3); 374c8379d7f1b5ac9a53792cedf47e942262759d4a6commit-bot@chromium.org} 375