summaryrefslogtreecommitdiff
path: root/libs/hwui/renderstate/RenderState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/renderstate/RenderState.cpp')
-rw-r--r--libs/hwui/renderstate/RenderState.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp
index 2c92924cc12c..5fc5cb275741 100644
--- a/libs/hwui/renderstate/RenderState.cpp
+++ b/libs/hwui/renderstate/RenderState.cpp
@@ -53,6 +53,11 @@ void RenderState::onGLContextCreated() {
mScissor = new Scissor();
mStencil = new Stencil();
+ // Deferred because creation needs GL context for texture limits
+ if (!mLayerPool) {
+ mLayerPool = new OffscreenBufferPool();
+ }
+
// This is delayed because the first access of Caches makes GL calls
if (!mCaches) {
mCaches = &Caches::createInstance(*this);
@@ -67,7 +72,7 @@ static void layerLostGlContext(Layer* layer) {
}
void RenderState::onGLContextDestroyed() {
- mLayerPool.clear();
+ mLayerPool->clear();
// TODO: reset all cached state in state objects
std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext);
@@ -100,7 +105,7 @@ static void layerDestroyedVkContext(Layer* layer) {
}
void RenderState::onVkContextDestroyed() {
- mLayerPool.clear();
+ mLayerPool->clear();
std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerDestroyedVkContext);
GpuMemoryTracker::onGpuContextDestroyed();
}
@@ -116,10 +121,10 @@ void RenderState::flush(Caches::FlushMode mode) {
case Caches::FlushMode::Moderate:
// fall through
case Caches::FlushMode::Layers:
- mLayerPool.clear();
+ if (mLayerPool) mLayerPool->clear();
break;
}
- mCaches->flush(mode);
+ if (mCaches) mCaches->flush(mode);
}
void RenderState::onBitmapDestroyed(uint32_t pixelRefId) {
@@ -257,7 +262,8 @@ void RenderState::postDecStrong(VirtualLightRefBase* object) {
// Render
///////////////////////////////////////////////////////////////////////////////
-void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix) {
+void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix,
+ bool overrideDisableBlending) {
const Glop::Mesh& mesh = glop.mesh;
const Glop::Mesh::Vertices& vertices = mesh.vertices;
const Glop::Mesh::Indices& indices = mesh.indices;
@@ -412,7 +418,11 @@ void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix) {
// ------------------------------------
// ---------- GL state setup ----------
// ------------------------------------
- blend().setFactors(glop.blend.src, glop.blend.dst);
+ if (CC_UNLIKELY(overrideDisableBlending)) {
+ blend().setFactors(GL_ZERO, GL_ZERO);
+ } else {
+ blend().setFactors(glop.blend.src, glop.blend.dst);
+ }
GL_CHECKPOINT(MODERATE);