SkColorShader.h revision 91f319c5dc4493384f0a52aaeef3dcc311ef6ed0
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2007 The Android Open Source Project 48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkColorShader_DEFINED 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkColorShader_DEFINED 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkShader.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkColorShader 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com A Shader that represents a single color. In general, this effect can be 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com accomplished by just using the color field on the paint, but if an 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com actual shader object is needed, this provides that feature. 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 207ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkColorShader : public SkShader { 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create a ColorShader that will inherit its color from the Paint 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com at draw time. 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 25f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkColorShader(); 265119bdb952025a30f115b9c6a187173956e55097reed@android.com 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Create a ColorShader that ignores the color in the paint, and uses the 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com specified color. Note: like all shaders, at draw time the paint's alpha 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com will be respected, and is applied to the specified color. 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 31f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkColorShader(SkColor c); 32f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 33f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com virtual ~SkColorShader(); 34f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com 3559ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com virtual uint32_t getFlags() SK_OVERRIDE; 3659ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; 37b6e161937bc890f0aa12ac5e27415d4d260ea6e0junov@chromium.org virtual bool isOpaque() const SK_OVERRIDE; 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool setContext(const SkBitmap& device, const SkPaint& paint, 3959ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com const SkMatrix& matrix) SK_OVERRIDE; 4059ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE; 4159ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE; 4259ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE; 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 442be9e8b407624fa696854b78b407b97a01dbb703reed@google.com // we return false for this, use asAGradient 458cad58624bc194390b14a21d0578dfcdd6fbad6freed@google.com virtual BitmapType asABitmap(SkBitmap* outTexture, 46f2b98d67dcb6fcb3120feede9c72016fc7b3ead8reed@android.com SkMatrix* outMatrix, 4791f319c5dc4493384f0a52aaeef3dcc311ef6ed0rileya@google.com TileMode xy[2]) const SK_OVERRIDE; 48d3ae77965e94e0efda496f5461cbec4533cb5b16vandebo@chromium.org 4959ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; 50d3ae77965e94e0efda496f5461cbec4533cb5b16vandebo@chromium.org 51ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) 52a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 5459ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com SkColorShader(SkFlattenableReadBuffer&); 5554924243c1b65b3ee6d8fa064b50a9b1bb2a19a5djsollen@google.com virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 5659ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 5859ccef695cef28a74ab2ea13d5a6c9017af45402reed@google.com 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkColor fColor; // ignored if fInheritColor is true 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPMColor fPMColor; // cached after setContext() 615119bdb952025a30f115b9c6a187173956e55097reed@android.com uint32_t fFlags; // cached after setContext() 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint16_t fColor16; // cached after setContext() 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkBool8 fInheritColor; 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com typedef SkShader INHERITED; 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 69