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.
19 #include <utils/RefBase.h>
20 #include <GpuMemoryTracker.h>
23 #include <SkBlendMode.h>
28 namespace uirenderer {
30 ///////////////////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////////////
37 * A layer has dimensions and is backed by a backend specific texture or framebuffer.
39 class Layer : public VirtualLightRefBase, GpuMemoryTracker {
52 virtual uint32_t getWidth() const = 0;
54 virtual uint32_t getHeight() const = 0;
56 virtual void setSize(uint32_t width, uint32_t height) = 0;
58 virtual void setBlend(bool blend) = 0;
60 virtual bool isBlend() const = 0;
62 inline void setForceFilter(bool forceFilter) {
63 this->forceFilter = forceFilter;
66 inline bool getForceFilter() const {
70 inline void setAlpha(int alpha) {
74 inline void setAlpha(int alpha, SkBlendMode mode) {
79 inline int getAlpha() const {
83 inline SkBlendMode getMode() const {
87 inline SkColorFilter* getColorFilter() const {
91 void setColorFilter(SkColorFilter* filter);
93 inline mat4& getTexTransform() {
97 inline mat4& getTransform() {
102 * Posts a decStrong call to the appropriate thread.
105 void postDecStrong();
108 Layer(RenderState& renderState, Api api, SkColorFilter* colorFilter, int alpha,
111 RenderState& mRenderState;
117 * Color filter used to draw this layer. Optional.
119 SkColorFilter* colorFilter;
122 * Indicates raster data backing the layer is scaled, requiring filtration.
124 bool forceFilter = false;
127 * Opacity of the layer.
132 * Blending mode of the layer.
137 * Optional texture coordinates transform.
142 * Optional transform.
148 }; // namespace uirenderer
149 }; // namespace android