gfx/skia/trunk/include/effects/SkGradientShader.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2006 The Android Open Source Project
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkGradientShader_DEFINED
michael@0 9 #define SkGradientShader_DEFINED
michael@0 10
michael@0 11 #include "SkShader.h"
michael@0 12
michael@0 13 class SkUnitMapper;
michael@0 14
michael@0 15 /** \class SkGradientShader
michael@0 16
michael@0 17 SkGradientShader hosts factories for creating subclasses of SkShader that
michael@0 18 render linear and radial gradients.
michael@0 19 */
michael@0 20 class SK_API SkGradientShader {
michael@0 21 public:
michael@0 22 enum Flags {
michael@0 23 /** By default gradients will interpolate their colors in unpremul space
michael@0 24 * and then premultiply each of the results. By setting this flag, the
michael@0 25 * gradients will premultiply their colors first, and then interpolate
michael@0 26 * between them.
michael@0 27 */
michael@0 28 kInterpolateColorsInPremul_Flag = 1 << 0,
michael@0 29 };
michael@0 30
michael@0 31 /** Returns a shader that generates a linear gradient between the two
michael@0 32 specified points.
michael@0 33 <p />
michael@0 34 CreateLinear returns a shader with a reference count of 1.
michael@0 35 The caller should decrement the shader's reference count when done with the shader.
michael@0 36 It is an error for count to be < 2.
michael@0 37 @param pts The start and end points for the gradient.
michael@0 38 @param colors The array[count] of colors, to be distributed between the two points
michael@0 39 @param pos May be NULL. array[count] of SkScalars, or NULL, of the relative position of
michael@0 40 each corresponding color in the colors array. If this is NULL,
michael@0 41 the the colors are distributed evenly between the start and end point.
michael@0 42 If this is not null, the values must begin with 0, end with 1.0, and
michael@0 43 intermediate values must be strictly increasing.
michael@0 44 @param count Must be >=2. The number of colors (and pos if not NULL) entries.
michael@0 45 @param mode The tiling mode
michael@0 46 @param mapper May be NULL. Callback to modify the spread of the colors.
michael@0 47 */
michael@0 48 static SkShader* CreateLinear(const SkPoint pts[2],
michael@0 49 const SkColor colors[], const SkScalar pos[], int count,
michael@0 50 SkShader::TileMode mode,
michael@0 51 SkUnitMapper* mapper = NULL,
michael@0 52 uint32_t flags = 0);
michael@0 53
michael@0 54 /** Returns a shader that generates a radial gradient given the center and radius.
michael@0 55 <p />
michael@0 56 CreateRadial returns a shader with a reference count of 1.
michael@0 57 The caller should decrement the shader's reference count when done with the shader.
michael@0 58 It is an error for colorCount to be < 2, or for radius to be <= 0.
michael@0 59 @param center The center of the circle for this gradient
michael@0 60 @param radius Must be positive. The radius of the circle for this gradient
michael@0 61 @param colors The array[count] of colors, to be distributed between the center and edge of the circle
michael@0 62 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
michael@0 63 each corresponding color in the colors array. If this is NULL,
michael@0 64 the the colors are distributed evenly between the center and edge of the circle.
michael@0 65 If this is not null, the values must begin with 0, end with 1.0, and
michael@0 66 intermediate values must be strictly increasing.
michael@0 67 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
michael@0 68 @param mode The tiling mode
michael@0 69 @param mapper May be NULL. Callback to modify the spread of the colors.
michael@0 70 */
michael@0 71 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
michael@0 72 const SkColor colors[], const SkScalar pos[], int count,
michael@0 73 SkShader::TileMode mode,
michael@0 74 SkUnitMapper* mapper = NULL,
michael@0 75 uint32_t flags = 0);
michael@0 76
michael@0 77 /** Returns a shader that generates a radial gradient given the start position, start radius, end position and end radius.
michael@0 78 <p />
michael@0 79 CreateTwoPointRadial returns a shader with a reference count of 1.
michael@0 80 The caller should decrement the shader's reference count when done with the shader.
michael@0 81 It is an error for colorCount to be < 2, for startRadius or endRadius to be < 0, or for
michael@0 82 startRadius to be equal to endRadius.
michael@0 83 @param start The center of the start circle for this gradient
michael@0 84 @param startRadius Must be positive. The radius of the start circle for this gradient.
michael@0 85 @param end The center of the end circle for this gradient
michael@0 86 @param endRadius Must be positive. The radius of the end circle for this gradient.
michael@0 87 @param colors The array[count] of colors, to be distributed between the center and edge of the circle
michael@0 88 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
michael@0 89 each corresponding color in the colors array. If this is NULL,
michael@0 90 the the colors are distributed evenly between the center and edge of the circle.
michael@0 91 If this is not null, the values must begin with 0, end with 1.0, and
michael@0 92 intermediate values must be strictly increasing.
michael@0 93 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
michael@0 94 @param mode The tiling mode
michael@0 95 @param mapper May be NULL. Callback to modify the spread of the colors.
michael@0 96 */
michael@0 97 static SkShader* CreateTwoPointRadial(const SkPoint& start,
michael@0 98 SkScalar startRadius,
michael@0 99 const SkPoint& end,
michael@0 100 SkScalar endRadius,
michael@0 101 const SkColor colors[],
michael@0 102 const SkScalar pos[], int count,
michael@0 103 SkShader::TileMode mode,
michael@0 104 SkUnitMapper* mapper = NULL,
michael@0 105 uint32_t flags = 0);
michael@0 106
michael@0 107 /**
michael@0 108 * Returns a shader that generates a conical gradient given two circles, or
michael@0 109 * returns NULL if the inputs are invalid. The gradient interprets the
michael@0 110 * two circles according to the following HTML spec.
michael@0 111 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
michael@0 112 */
michael@0 113 static SkShader* CreateTwoPointConical(const SkPoint& start,
michael@0 114 SkScalar startRadius,
michael@0 115 const SkPoint& end,
michael@0 116 SkScalar endRadius,
michael@0 117 const SkColor colors[],
michael@0 118 const SkScalar pos[], int count,
michael@0 119 SkShader::TileMode mode,
michael@0 120 SkUnitMapper* mapper = NULL,
michael@0 121 uint32_t flags = 0);
michael@0 122
michael@0 123 /** Returns a shader that generates a sweep gradient given a center.
michael@0 124 <p />
michael@0 125 CreateSweep returns a shader with a reference count of 1.
michael@0 126 The caller should decrement the shader's reference count when done with the shader.
michael@0 127 It is an error for colorCount to be < 2.
michael@0 128 @param cx The X coordinate of the center of the sweep
michael@0 129 @param cx The Y coordinate of the center of the sweep
michael@0 130 @param colors The array[count] of colors, to be distributed around the center.
michael@0 131 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
michael@0 132 each corresponding color in the colors array. If this is NULL,
michael@0 133 the the colors are distributed evenly between the center and edge of the circle.
michael@0 134 If this is not null, the values must begin with 0, end with 1.0, and
michael@0 135 intermediate values must be strictly increasing.
michael@0 136 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
michael@0 137 @param mapper May be NULL. Callback to modify the spread of the colors.
michael@0 138 */
michael@0 139 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
michael@0 140 const SkColor colors[], const SkScalar pos[],
michael@0 141 int count, SkUnitMapper* mapper = NULL,
michael@0 142 uint32_t flags = 0);
michael@0 143
michael@0 144 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
michael@0 145 };
michael@0 146
michael@0 147 #endif

mercurial