2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ANDROID_HWUI_SKIA_SHADER_H
18 #define ANDROID_HWUI_SKIA_SHADER_H
20 #include "FloatColor.h"
23 #include <GLES2/gl2.h>
25 #include <SkXfermode.h>
26 #include <cutils/compiler.h>
29 namespace uirenderer {
35 struct ProgramDescription;
38 * Type of Skia shader in use.
40 * Note that kBitmap | kGradient = kCompose, since Compose implies
41 * both its component types are in use simultaneously. No other
42 * composition of multiple types is supported.
45 kNone_SkiaShaderType = 0,
46 kBitmap_SkiaShaderType = 1,
47 kGradient_SkiaShaderType = 2,
48 kCompose_SkiaShaderType = kBitmap_SkiaShaderType | kGradient_SkiaShaderType,
49 kLayer_SkiaShaderType = 4,
52 struct SkiaShaderData {
53 SkiaShaderType skiaShaderType;
54 struct BitmapShaderData {
55 Texture* bitmapTexture;
60 Matrix4 textureTransform;
61 float textureDimension[2];
63 struct GradientShaderData {
68 FloatColor startColor;
72 Texture* gradientTexture;
73 GLuint gradientSampler;
77 struct LayerShaderData {
83 Matrix4 textureTransform;
84 float textureDimension[2];
90 static void store(Caches& caches, const SkShader& shader, const Matrix4& modelViewMatrix,
91 GLuint* textureUnit, ProgramDescription* description,
92 SkiaShaderData* outData);
93 static void apply(Caches& caches, const SkiaShaderData& data);
96 }; // namespace uirenderer
97 }; // namespace android
99 #endif // ANDROID_HWUI_SKIA_SHADER_H