OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkShader_DEFINED | 8 #ifndef SkShader_DEFINED |
9 #define SkShader_DEFINED | 9 #define SkShader_DEFINED |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 enum Flags { | 74 enum Flags { |
75 //!< set if all of the colors will be opaque | 75 //!< set if all of the colors will be opaque |
76 kOpaqueAlpha_Flag = 1 << 0, | 76 kOpaqueAlpha_Flag = 1 << 0, |
77 | 77 |
78 /** set if the spans only vary in X (const in Y). | 78 /** set if the spans only vary in X (const in Y). |
79 e.g. an Nx1 bitmap that is being tiled in Y, or a linear-gradient | 79 e.g. an Nx1 bitmap that is being tiled in Y, or a linear-gradient |
80 that varies from left-to-right. This flag specifies this for | 80 that varies from left-to-right. This flag specifies this for |
81 shadeSpan(). | 81 shadeSpan(). |
82 */ | 82 */ |
83 kConstInY32_Flag = 1 << 1, | 83 kConstInY32_Flag = 1 << 1, |
| 84 kSupports4f_Flag = 1 << 2, |
84 }; | 85 }; |
85 | 86 |
86 /** | 87 /** |
87 * Returns true if the shader is guaranteed to produce only opaque | 88 * Returns true if the shader is guaranteed to produce only opaque |
88 * colors, subject to the SkPaint using the shader to apply an opaque | 89 * colors, subject to the SkPaint using the shader to apply an opaque |
89 * alpha value. Subclasses should override this to allow some | 90 * alpha value. Subclasses should override this to allow some |
90 * optimizations. | 91 * optimizations. |
91 */ | 92 */ |
92 virtual bool isOpaque() const { return false; } | 93 virtual bool isOpaque() const { return false; } |
93 | 94 |
(...skipping 26 matching lines...) Expand all Loading... |
120 */ | 121 */ |
121 virtual uint32_t getFlags() const { return 0; } | 122 virtual uint32_t getFlags() const { return 0; } |
122 | 123 |
123 /** | 124 /** |
124 * Called for each span of the object being drawn. Your subclass should | 125 * Called for each span of the object being drawn. Your subclass should |
125 * set the appropriate colors (with premultiplied alpha) that correspon
d | 126 * set the appropriate colors (with premultiplied alpha) that correspon
d |
126 * to the specified device coordinates. | 127 * to the specified device coordinates. |
127 */ | 128 */ |
128 virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0; | 129 virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0; |
129 | 130 |
| 131 virtual void shadeSpan4f(int x, int y, SkPM4f[], int count); |
| 132 |
130 /** | 133 /** |
131 * The const void* ctx is only const because all the implementations are
const. | 134 * The const void* ctx is only const because all the implementations are
const. |
132 * This can be changed to non-const if a new shade proc needs to change
the ctx. | 135 * This can be changed to non-const if a new shade proc needs to change
the ctx. |
133 */ | 136 */ |
134 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in
t count); | 137 typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], in
t count); |
135 virtual ShadeProc asAShadeProc(void** ctx); | 138 virtual ShadeProc asAShadeProc(void** ctx); |
136 | 139 |
137 /** | 140 /** |
138 * Similar to shadeSpan, but only returns the alpha-channel for a span. | 141 * Similar to shadeSpan, but only returns the alpha-channel for a span. |
139 * The default implementation calls shadeSpan() and then extracts the a
lpha | 142 * The default implementation calls shadeSpan() and then extracts the a
lpha |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 * Call this to create a new "empty" shader, that will not draw anything. | 327 * Call this to create a new "empty" shader, that will not draw anything. |
325 */ | 328 */ |
326 static SkShader* CreateEmptyShader(); | 329 static SkShader* CreateEmptyShader(); |
327 | 330 |
328 /** | 331 /** |
329 * Call this to create a new shader that just draws the specified color. Th
is should always | 332 * Call this to create a new shader that just draws the specified color. Th
is should always |
330 * draw the same as a paint with this color (and no shader). | 333 * draw the same as a paint with this color (and no shader). |
331 */ | 334 */ |
332 static SkShader* CreateColorShader(SkColor); | 335 static SkShader* CreateColorShader(SkColor); |
333 | 336 |
| 337 static SkShader* CreateColorShader(const SkColor4f&); |
| 338 |
334 /** Call this to create a new shader that will draw with the specified bitma
p. | 339 /** Call this to create a new shader that will draw with the specified bitma
p. |
335 * | 340 * |
336 * If the bitmap cannot be used (e.g. has no pixels, or its dimensions | 341 * If the bitmap cannot be used (e.g. has no pixels, or its dimensions |
337 * exceed implementation limits (currently at 64K - 1)) then SkEmptyShader | 342 * exceed implementation limits (currently at 64K - 1)) then SkEmptyShader |
338 * may be returned. | 343 * may be returned. |
339 * | 344 * |
340 * If the src is kA8_Config then that mask will be colorized using the colo
r on | 345 * If the src is kA8_Config then that mask will be colorized using the colo
r on |
341 * the paint. | 346 * the paint. |
342 * | 347 * |
343 * @param src The bitmap to use inside the shader | 348 * @param src The bitmap to use inside the shader |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 SkMatrix fLocalMatrix; | 412 SkMatrix fLocalMatrix; |
408 | 413 |
409 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 414 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
410 friend class SkLocalMatrixShader; | 415 friend class SkLocalMatrixShader; |
411 friend class SkBitmapProcShader; // for computeTotalInverse() | 416 friend class SkBitmapProcShader; // for computeTotalInverse() |
412 | 417 |
413 typedef SkFlattenable INHERITED; | 418 typedef SkFlattenable INHERITED; |
414 }; | 419 }; |
415 | 420 |
416 #endif | 421 #endif |
OLD | NEW |