Chet Haase | dd78cca | 2010-10-22 18:59:26 -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 | |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 17 | #include "Caches.h" |
Chris Craik | 65fe5ee | 2015-01-26 18:06:29 -0800 | [diff] [blame] | 18 | |
Tom Hudson | 2dc236b | 2014-10-15 15:46:42 -0400 | [diff] [blame] | 19 | #include "GammaFontRenderer.h" |
Greg Daniel | 8cd3edf | 2017-01-09 14:15:41 -0500 | [diff] [blame] | 20 | #include "GlLayer.h" |
Chris Craik | 65fe5ee | 2015-01-26 18:06:29 -0800 | [diff] [blame] | 21 | #include "Properties.h" |
ztenghui | 63d41ab | 2014-02-14 13:13:41 -0800 | [diff] [blame] | 22 | #include "ShadowTessellator.h" |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 23 | #include "renderstate/RenderState.h" |
sergeyv | af102be | 2016-09-09 18:02:07 -0700 | [diff] [blame] | 24 | #ifdef BUGREPORT_FONT_CACHE_USAGE |
| 25 | #include "font/FontCacheHistoryTracker.h" |
| 26 | #endif |
John Reck | d7db4d7 | 2015-05-20 07:18:55 -0700 | [diff] [blame] | 27 | #include "utils/GLUtils.h" |
Chris Craik | 65fe5ee | 2015-01-26 18:06:29 -0800 | [diff] [blame] | 28 | |
John Reck | 6b50780 | 2015-11-03 10:09:59 -0800 | [diff] [blame] | 29 | #include <cutils/properties.h> |
Chris Craik | 65fe5ee | 2015-01-26 18:06:29 -0800 | [diff] [blame] | 30 | #include <utils/Log.h> |
| 31 | #include <utils/String8.h> |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 32 | |
| 33 | namespace android { |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 34 | namespace uirenderer { |
| 35 | |
Chris Craik | 96a5c4c | 2015-01-27 15:46:35 -0800 | [diff] [blame] | 36 | Caches* Caches::sInstance = nullptr; |
| 37 | |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 38 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 39 | // Macros |
| 40 | /////////////////////////////////////////////////////////////////////////////// |
| 41 | |
| 42 | #if DEBUG_CACHE_FLUSH |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 43 | #define FLUSH_LOGD(...) ALOGD(__VA_ARGS__) |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 44 | #else |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 45 | #define FLUSH_LOGD(...) |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 46 | #endif |
| 47 | |
| 48 | /////////////////////////////////////////////////////////////////////////////// |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 49 | // Constructors/destructor |
| 50 | /////////////////////////////////////////////////////////////////////////////// |
| 51 | |
Chris Craik | 96a5c4c | 2015-01-27 15:46:35 -0800 | [diff] [blame] | 52 | Caches::Caches(RenderState& renderState) |
John Reck | 8dc02f9 | 2017-07-17 09:55:02 -0700 | [diff] [blame] | 53 | : gradientCache(extensions()) |
Chris Craik | 117bdbc | 2015-02-05 10:12:38 -0800 | [diff] [blame] | 54 | , patchCache(renderState) |
John Reck | 8dc02f9 | 2017-07-17 09:55:02 -0700 | [diff] [blame] | 55 | , programCache(extensions()) |
Chris Craik | 96a5c4c | 2015-01-27 15:46:35 -0800 | [diff] [blame] | 56 | , mRenderState(&renderState) |
Chris Craik | 96a5c4c | 2015-01-27 15:46:35 -0800 | [diff] [blame] | 57 | , mInitialized(false) { |
| 58 | INIT_LOGD("Creating OpenGL renderer caches"); |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 59 | init(); |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 60 | initConstraints(); |
Romain Guy | f9f0016 | 2013-05-09 11:50:12 -0700 | [diff] [blame] | 61 | initStaticProperties(); |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 62 | initExtensions(); |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 65 | bool Caches::init() { |
| 66 | if (mInitialized) return false; |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 67 | |
John Reck | fbc8df0 | 2014-11-14 16:18:41 -0800 | [diff] [blame] | 68 | ATRACE_NAME("Caches::init"); |
| 69 | |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 70 | mRegionMesh = nullptr; |
Chris Craik | 6c15ffa | 2015-02-02 13:50:55 -0800 | [diff] [blame] | 71 | mProgram = nullptr; |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 72 | |
| 73 | mInitialized = true; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 74 | |
Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 75 | mPixelBufferState = new PixelBufferState(); |
| 76 | mTextureState = new TextureState(); |
Chris Craik | 138c21f | 2016-04-28 16:59:42 -0700 | [diff] [blame] | 77 | mTextureState->constructTexture(*this); |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 78 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 79 | return true; |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 82 | void Caches::initExtensions() { |
John Reck | 8dc02f9 | 2017-07-17 09:55:02 -0700 | [diff] [blame] | 83 | if (extensions().hasDebugMarker()) { |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 84 | eventMark = glInsertEventMarkerEXT; |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 85 | |
Chris Craik | ff78583 | 2013-03-08 13:12:16 -0800 | [diff] [blame] | 86 | startMark = glPushGroupMarkerEXT; |
| 87 | endMark = glPopGroupMarkerEXT; |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 88 | } else { |
| 89 | eventMark = eventMarkNull; |
| 90 | startMark = startMarkNull; |
| 91 | endMark = endMarkNull; |
| 92 | } |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | void Caches::initConstraints() { |
John Reck | 8dc02f9 | 2017-07-17 09:55:02 -0700 | [diff] [blame] | 96 | maxTextureSize = DeviceInfo::get()->maxTextureSize(); |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Romain Guy | f9f0016 | 2013-05-09 11:50:12 -0700 | [diff] [blame] | 99 | void Caches::initStaticProperties() { |
Romain Guy | f9f0016 | 2013-05-09 11:50:12 -0700 | [diff] [blame] | 100 | // OpenGL ES 3.0+ specific features |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 101 | gpuPixelBuffersEnabled = extensions().hasPixelBufferObjects() && |
| 102 | property_get_bool(PROPERTY_ENABLE_GPU_PIXEL_BUFFERS, true); |
Romain Guy | f9f0016 | 2013-05-09 11:50:12 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 105 | void Caches::terminate() { |
| 106 | if (!mInitialized) return; |
Sangkyu Lee | 441cc42 | 2015-12-11 16:05:10 +0900 | [diff] [blame] | 107 | mRegionMesh.reset(nullptr); |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 108 | |
| 109 | fboCache.clear(); |
| 110 | |
| 111 | programCache.clear(); |
Chris Craik | 3472568 | 2015-02-05 09:06:30 -0800 | [diff] [blame] | 112 | mProgram = nullptr; |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 113 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 114 | patchCache.clear(); |
| 115 | |
Romain Guy | 46bfc48 | 2013-08-16 18:38:29 -0700 | [diff] [blame] | 116 | clearGarbage(); |
| 117 | |
Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 118 | delete mPixelBufferState; |
| 119 | mPixelBufferState = nullptr; |
| 120 | delete mTextureState; |
| 121 | mTextureState = nullptr; |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 122 | mInitialized = false; |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Chris Craik | 6c15ffa | 2015-02-02 13:50:55 -0800 | [diff] [blame] | 125 | void Caches::setProgram(const ProgramDescription& description) { |
| 126 | setProgram(programCache.get(description)); |
| 127 | } |
| 128 | |
| 129 | void Caches::setProgram(Program* program) { |
| 130 | if (!program || !program->isInUse()) { |
| 131 | if (mProgram) { |
| 132 | mProgram->remove(); |
| 133 | } |
| 134 | if (program) { |
| 135 | program->use(); |
| 136 | } |
| 137 | mProgram = program; |
| 138 | } |
| 139 | } |
| 140 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 141 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 142 | // Debug |
| 143 | /////////////////////////////////////////////////////////////////////////////// |
| 144 | |
Romain Guy | 627c6fd | 2013-08-21 11:53:18 -0700 | [diff] [blame] | 145 | uint32_t Caches::getOverdrawColor(uint32_t amount) const { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 146 | static uint32_t sOverdrawColors[2][4] = {{0x2f0000ff, 0x2f00ff00, 0x3fff0000, 0x7fff0000}, |
| 147 | {0x2f0000ff, 0x4fffff00, 0x5fff8ad8, 0x7fff0000}}; |
Romain Guy | 627c6fd | 2013-08-21 11:53:18 -0700 | [diff] [blame] | 148 | if (amount < 1) amount = 1; |
| 149 | if (amount > 4) amount = 4; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 150 | |
| 151 | int overdrawColorIndex = static_cast<int>(Properties::overdrawColorSet); |
| 152 | return sOverdrawColors[overdrawColorIndex][amount - 1]; |
Romain Guy | 627c6fd | 2013-08-21 11:53:18 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 155 | void Caches::dumpMemoryUsage() { |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 156 | String8 stringLog; |
| 157 | dumpMemoryUsage(stringLog); |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 158 | ALOGD("%s", stringLog.string()); |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 159 | } |
| 160 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 161 | void Caches::dumpMemoryUsage(String8& log) { |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 162 | uint32_t total = 0; |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 163 | log.appendFormat("Current memory usage / total memory usage (bytes):\n"); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 164 | log.appendFormat(" TextureCache %8d / %8d\n", textureCache.getSize(), |
| 165 | textureCache.getMaxSize()); |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 166 | if (mRenderState) { |
| 167 | int memused = 0; |
John Reck | 5799801 | 2015-01-29 10:17:57 -0800 | [diff] [blame] | 168 | for (std::set<Layer*>::iterator it = mRenderState->mActiveLayers.begin(); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 169 | it != mRenderState->mActiveLayers.end(); it++) { |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 170 | const Layer* layer = *it; |
Greg Daniel | 8cd3edf | 2017-01-09 14:15:41 -0500 | [diff] [blame] | 171 | LOG_ALWAYS_FATAL_IF(layer->getApi() != Layer::Api::OpenGL); |
| 172 | const GlLayer* glLayer = static_cast<const GlLayer*>(layer); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 173 | log.appendFormat(" GlLayer size %dx%d; texid=%u refs=%d\n", layer->getWidth(), |
| 174 | layer->getHeight(), glLayer->getTextureId(), layer->getStrongCount()); |
John Reck | 88f5fc7 | 2014-11-03 10:32:24 -0800 | [diff] [blame] | 175 | memused += layer->getWidth() * layer->getHeight() * 4; |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 176 | } |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 177 | log.appendFormat(" Layers total %8d (numLayers = %zu)\n", memused, |
| 178 | mRenderState->mActiveLayers.size()); |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 179 | total += memused; |
| 180 | } |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 181 | log.appendFormat(" RenderBufferCache %8d / %8d\n", renderBufferCache.getSize(), |
| 182 | renderBufferCache.getMaxSize()); |
| 183 | log.appendFormat(" GradientCache %8d / %8d\n", gradientCache.getSize(), |
| 184 | gradientCache.getMaxSize()); |
| 185 | log.appendFormat(" PathCache %8d / %8d\n", pathCache.getSize(), |
| 186 | pathCache.getMaxSize()); |
| 187 | log.appendFormat(" TessellationCache %8d / %8d\n", tessellationCache.getSize(), |
| 188 | tessellationCache.getMaxSize()); |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 189 | log.appendFormat(" TextDropShadowCache %8d / %8d\n", dropShadowCache.getSize(), |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 190 | dropShadowCache.getMaxSize()); |
| 191 | log.appendFormat(" PatchCache %8d / %8d\n", patchCache.getSize(), |
| 192 | patchCache.getMaxSize()); |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 193 | |
sergeyv | baf29e7 | 2016-09-08 11:09:34 -0700 | [diff] [blame] | 194 | fontRenderer.dumpMemoryUsage(log); |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 195 | |
Romain Guy | d2ba50a | 2011-05-27 10:21:07 -0700 | [diff] [blame] | 196 | log.appendFormat("Other:\n"); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 197 | log.appendFormat(" FboCache %8d / %8d\n", fboCache.getSize(), |
| 198 | fboCache.getMaxSize()); |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 199 | |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 200 | total += textureCache.getSize(); |
Romain Guy | 8d4aeb7 | 2013-02-12 16:08:55 -0800 | [diff] [blame] | 201 | total += renderBufferCache.getSize(); |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 202 | total += gradientCache.getSize(); |
| 203 | total += pathCache.getSize(); |
Chris Craik | 05f3d6e | 2014-06-02 16:27:04 -0700 | [diff] [blame] | 204 | total += tessellationCache.getSize(); |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 205 | total += dropShadowCache.getSize(); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 206 | total += patchCache.getSize(); |
sergeyv | baf29e7 | 2016-09-08 11:09:34 -0700 | [diff] [blame] | 207 | total += fontRenderer.getSize(); |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 208 | |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 209 | log.appendFormat("Total memory usage:\n"); |
| 210 | log.appendFormat(" %d bytes, %.2f MB\n", total, total / 1024.0f / 1024.0f); |
sergeyv | af102be | 2016-09-09 18:02:07 -0700 | [diff] [blame] | 211 | |
| 212 | #ifdef BUGREPORT_FONT_CACHE_USAGE |
| 213 | fontRenderer.getFontRenderer().historyTracker().dump(log); |
| 214 | #endif |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | fe48f65 | 2010-11-11 15:36:56 -0800 | [diff] [blame] | 218 | // Memory management |
| 219 | /////////////////////////////////////////////////////////////////////////////// |
| 220 | |
| 221 | void Caches::clearGarbage() { |
Romain Guy | fe48f65 | 2010-11-11 15:36:56 -0800 | [diff] [blame] | 222 | pathCache.clearGarbage(); |
Romain Guy | e3b0a01 | 2013-06-26 15:45:41 -0700 | [diff] [blame] | 223 | patchCache.clearGarbage(); |
Romain Guy | fe48f65 | 2010-11-11 15:36:56 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 226 | void Caches::flush(FlushMode mode) { |
| 227 | FLUSH_LOGD("Flushing caches (mode %d)", mode); |
| 228 | |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 229 | switch (mode) { |
Chris Craik | b9ce116d | 2015-08-20 15:14:06 -0700 | [diff] [blame] | 230 | case FlushMode::Full: |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 231 | textureCache.clear(); |
| 232 | patchCache.clear(); |
| 233 | dropShadowCache.clear(); |
| 234 | gradientCache.clear(); |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 235 | fontRenderer.clear(); |
Romain Guy | b746371 | 2013-08-16 13:55:29 -0700 | [diff] [blame] | 236 | fboCache.clear(); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 237 | // fall through |
Chris Craik | b9ce116d | 2015-08-20 15:14:06 -0700 | [diff] [blame] | 238 | case FlushMode::Moderate: |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 239 | fontRenderer.flush(); |
Romain Guy | eca0ca2 | 2011-11-04 15:12:29 -0700 | [diff] [blame] | 240 | textureCache.flush(); |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 241 | pathCache.clear(); |
Chris Craik | 05f3d6e | 2014-06-02 16:27:04 -0700 | [diff] [blame] | 242 | tessellationCache.clear(); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 243 | // fall through |
Chris Craik | b9ce116d | 2015-08-20 15:14:06 -0700 | [diff] [blame] | 244 | case FlushMode::Layers: |
Romain Guy | 8d4aeb7 | 2013-02-12 16:08:55 -0800 | [diff] [blame] | 245 | renderBufferCache.clear(); |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 246 | break; |
| 247 | } |
Chet Haase | 6a2d17f | 2012-09-30 12:14:13 -0700 | [diff] [blame] | 248 | |
| 249 | clearGarbage(); |
John Reck | 4ced262 | 2014-09-19 10:10:19 -0700 | [diff] [blame] | 250 | glFinish(); |
John Reck | d7db4d7 | 2015-05-20 07:18:55 -0700 | [diff] [blame] | 251 | // Errors during cleanup should be considered non-fatal, dump them and |
| 252 | // and move on. TODO: All errors or just errors like bad surface? |
| 253 | GLUtils::dumpGLErrors(); |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Romain Guy | fe48f65 | 2010-11-11 15:36:56 -0800 | [diff] [blame] | 256 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 257 | // Regions |
| 258 | /////////////////////////////////////////////////////////////////////////////// |
| 259 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 260 | TextureVertex* Caches::getRegionMesh() { |
| 261 | // Create the mesh, 2 triangles and 4 vertices per rectangle in the region |
| 262 | if (!mRegionMesh) { |
Chris Craik | 96a5c4c | 2015-01-27 15:46:35 -0800 | [diff] [blame] | 263 | mRegionMesh.reset(new TextureVertex[kMaxNumberOfQuads * 4]); |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Chris Craik | 51d6a3d | 2014-12-22 17:16:56 -0800 | [diff] [blame] | 266 | return mRegionMesh.get(); |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Chris Craik | ba9b613 | 2013-12-15 17:10:19 -0800 | [diff] [blame] | 269 | /////////////////////////////////////////////////////////////////////////////// |
| 270 | // Temporary Properties |
| 271 | /////////////////////////////////////////////////////////////////////////////// |
| 272 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 273 | }; // namespace uirenderer |
| 274 | }; // namespace android |