Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HWUI_PROGRAM_CACHE_H |
| 18 | #define ANDROID_HWUI_PROGRAM_CACHE_H |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 19 | |
| 20 | #include <utils/KeyedVector.h> |
| 21 | #include <utils/Log.h> |
Romain Guy | 06f96e2 | 2010-07-30 19:18:16 -0700 | [diff] [blame] | 22 | #include <utils/String8.h> |
Chris Craik | 51d6a3d | 2014-12-22 17:16:56 -0800 | [diff] [blame] | 23 | #include <map> |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 24 | |
Romain Guy | 889f8d1 | 2010-07-29 14:37:42 -0700 | [diff] [blame] | 25 | #include <GLES2/gl2.h> |
| 26 | |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 27 | #include "Debug.h" |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 28 | #include "Program.h" |
| 29 | |
| 30 | namespace android { |
| 31 | namespace uirenderer { |
| 32 | |
| 33 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 34 | // Cache |
| 35 | /////////////////////////////////////////////////////////////////////////////// |
| 36 | |
| 37 | /** |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 38 | * Generates and caches program. Programs are generated based on |
| 39 | * ProgramDescriptions. |
| 40 | */ |
| 41 | class ProgramCache { |
| 42 | public: |
John Reck | 8dc02f9 | 2017-07-17 09:55:02 -0700 | [diff] [blame] | 43 | explicit ProgramCache(const Extensions& extensions); |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 44 | ~ProgramCache(); |
| 45 | |
| 46 | Program* get(const ProgramDescription& description); |
| 47 | |
| 48 | void clear(); |
| 49 | |
| 50 | private: |
| 51 | Program* generateProgram(const ProgramDescription& description, programid key); |
| 52 | String8 generateVertexShader(const ProgramDescription& description); |
| 53 | String8 generateFragmentShader(const ProgramDescription& description); |
Mike Reed | c2f31df | 2016-10-28 17:21:45 -0400 | [diff] [blame] | 54 | void generateBlend(String8& shader, const char* name, SkBlendMode mode); |
Romain Guy | 889f8d1 | 2010-07-29 14:37:42 -0700 | [diff] [blame] | 55 | void generateTextureWrap(String8& shader, GLenum wrapS, GLenum wrapT); |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 56 | |
Romain Guy | db1938e | 2010-08-02 18:50:22 -0700 | [diff] [blame] | 57 | void printLongString(const String8& shader) const; |
| 58 | |
Chris Craik | 51d6a3d | 2014-12-22 17:16:56 -0800 | [diff] [blame] | 59 | std::map<programid, std::unique_ptr<Program>> mCache; |
Romain Guy | b488004 | 2013-04-05 11:17:55 -0700 | [diff] [blame] | 60 | |
| 61 | const bool mHasES3; |
Romain Guy | efb4b06 | 2017-02-27 11:00:04 -0800 | [diff] [blame] | 62 | const bool mHasLinearBlending; |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 63 | }; // class ProgramCache |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 64 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 65 | }; // namespace uirenderer |
| 66 | }; // namespace android |
Romain Guy | ac670c0 | 2010-07-27 17:39:27 -0700 | [diff] [blame] | 67 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame^] | 68 | #endif // ANDROID_HWUI_PROGRAM_CACHE_H |