| Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 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 <SkXfermode.h> | 
 | 24 | #include <memory> | 
 | 25 |  | 
 | 26 | namespace android { | 
 | 27 | namespace uirenderer { | 
 | 28 |  | 
 | 29 | class Blend { | 
 | 30 |     friend class RenderState; | 
 | 31 | public: | 
| Chris Craik | 182952f | 2015-03-09 14:17:29 -0700 | [diff] [blame] | 32 |     // dictates whether to swap src/dst | 
 | 33 |     enum class ModeOrderSwap { | 
 | 34 |         NoSwap, | 
 | 35 |         Swap, | 
 | 36 |     }; | 
 | 37 |  | 
 | 38 |     void enable(SkXfermode::Mode mode, ModeOrderSwap modeUsage); | 
| Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 39 |     void disable(); | 
 | 40 |     void syncEnabled(); | 
| Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 41 |  | 
| Chris Craik | 182952f | 2015-03-09 14:17:29 -0700 | [diff] [blame] | 42 |     static void getFactors(SkXfermode::Mode mode, ModeOrderSwap modeUsage, | 
 | 43 |             GLenum* outSrc, GLenum* outDst); | 
| Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 44 |     void setFactors(GLenum src, GLenum dst); | 
| Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 45 |  | 
 | 46 |     void dump(); | 
| Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 47 | private: | 
 | 48 |     Blend(); | 
 | 49 |     void invalidate(); | 
 | 50 |     bool mEnabled; | 
 | 51 |     GLenum mSrcMode; | 
 | 52 |     GLenum mDstMode; | 
 | 53 | }; | 
 | 54 |  | 
 | 55 | } /* namespace uirenderer */ | 
 | 56 | } /* namespace android */ | 
 | 57 |  | 
 | 58 | #endif // RENDERSTATE_BLEND_H |