• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #ifndef RENDERSTATE_BLEND_H
17 #define RENDERSTATE_BLEND_H
18 
19 #include "Vertex.h"
20 
21 #include <GLES2/gl2.h>
22 #include <GLES2/gl2ext.h>
23 #include <SkBlendMode.h>
24 #include <memory>
25 
26 namespace android {
27 namespace uirenderer {
28 
29 class Blend {
30     friend class RenderState;
31 
32 public:
33     // dictates whether to swap src/dst
34     enum class ModeOrderSwap {
35         NoSwap,
36         Swap,
37     };
38     void syncEnabled();
39 
40     static void getFactors(SkBlendMode mode, ModeOrderSwap modeUsage, GLenum* outSrc,
41                            GLenum* outDst);
42     void setFactors(GLenum src, GLenum dst);
43 
getEnabled()44     bool getEnabled() { return mEnabled; }
getFactors(GLenum * src,GLenum * dst)45     void getFactors(GLenum* src, GLenum* dst) {
46         *src = mSrcMode;
47         *dst = mDstMode;
48     }
49 
50     void dump();
51 
52 private:
53     Blend();
54     void invalidate();
55     bool mEnabled;
56     GLenum mSrcMode;
57     GLenum mDstMode;
58 };
59 
60 } /* namespace uirenderer */
61 } /* namespace android */
62 
63 #endif  // RENDERSTATE_BLEND_H
64