Loading libs/hwui/Caches.cpp +18 −3 Original line number Diff line number Diff line Loading @@ -72,9 +72,8 @@ bool Caches::init() { ATRACE_NAME("Caches::init"); mRegionMesh = nullptr; currentProgram = nullptr; mProgram = nullptr; mFunctorsCount = 0; Loading Loading @@ -200,7 +199,7 @@ void Caches::terminate() { fboCache.clear(); programCache.clear(); currentProgram = nullptr; setProgram(nullptr); patchCache.clear(); Loading @@ -213,6 +212,22 @@ void Caches::terminate() { mInitialized = false; } void Caches::setProgram(const ProgramDescription& description) { setProgram(programCache.get(description)); } void Caches::setProgram(Program* program) { if (!program || !program->isInUse()) { if (mProgram) { mProgram->remove(); } if (program) { program->use(); } mProgram = program; } } /////////////////////////////////////////////////////////////////////////////// // Debug /////////////////////////////////////////////////////////////////////////////// Loading libs/hwui/Caches.h +10 −6 Original line number Diff line number Diff line Loading @@ -162,8 +162,6 @@ public: void registerFunctors(uint32_t functorCount); void unregisterFunctors(uint32_t functorCount); Program* currentProgram; bool drawDeferDisabled; bool drawReorderDisabled; Loading Loading @@ -219,6 +217,10 @@ public: int propertyAmbientShadowStrength; int propertySpotShadowStrength; void setProgram(const ProgramDescription& description); void setProgram(Program* program); Program& program() { return *mProgram; } PixelBufferState& pixelBufferState() { return *mPixelBufferState; } TextureState& textureState() { return *mTextureState; } Loading Loading @@ -246,10 +248,6 @@ private: } RenderState* mRenderState; PixelBufferState* mPixelBufferState = nullptr; // TODO: move to RenderState TextureState* mTextureState = nullptr; // TODO: move to RenderState Extensions& mExtensions; // Used to render layers Loading @@ -264,6 +262,12 @@ private: uint32_t mFunctorsCount; OverdrawColorSet mOverdrawDebugColorSet; // TODO: move below to RenderState PixelBufferState* mPixelBufferState = nullptr; TextureState* mTextureState = nullptr; Program* mProgram = nullptr; // note: object owned by ProgramCache }; // class Caches }; // namespace uirenderer Loading libs/hwui/Dither.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -89,13 +89,13 @@ void Dither::clear() { // Program management /////////////////////////////////////////////////////////////////////////////// void Dither::setupProgram(Program* program, GLuint* textureUnit) { void Dither::setupProgram(Program& program, GLuint* textureUnit) { GLuint textureSlot = (*textureUnit)++; mCaches.textureState().activateTexture(textureSlot); bindDitherTexture(); glUniform1i(program->getUniform("ditherSampler"), textureSlot); glUniform1i(program.getUniform("ditherSampler"), textureSlot); } }; // namespace uirenderer Loading libs/hwui/Dither.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: Dither(Caches& caches); void clear(); void setupProgram(Program* program, GLuint* textureUnit); void setupProgram(Program& program, GLuint* textureUnit); private: void bindDitherTexture(); Loading libs/hwui/FontRenderer.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -516,9 +516,8 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { TextureVertex* mesh = texture->mesh(); MeshState& meshState = renderState.meshState(); Program* program = caches.currentProgram; meshState.bindPositionVertexPointer(program, forceRebind, &mesh[0].x); meshState.bindTexCoordsVertexPointer(program, forceRebind, &mesh[0].u); meshState.bindPositionVertexPointer(forceRebind, &mesh[0].x); meshState.bindTexCoordsVertexPointer(forceRebind, &mesh[0].u); glDrawElements(GL_TRIANGLES, texture->meshElementCount(), GL_UNSIGNED_SHORT, texture->indices()); Loading Loading
libs/hwui/Caches.cpp +18 −3 Original line number Diff line number Diff line Loading @@ -72,9 +72,8 @@ bool Caches::init() { ATRACE_NAME("Caches::init"); mRegionMesh = nullptr; currentProgram = nullptr; mProgram = nullptr; mFunctorsCount = 0; Loading Loading @@ -200,7 +199,7 @@ void Caches::terminate() { fboCache.clear(); programCache.clear(); currentProgram = nullptr; setProgram(nullptr); patchCache.clear(); Loading @@ -213,6 +212,22 @@ void Caches::terminate() { mInitialized = false; } void Caches::setProgram(const ProgramDescription& description) { setProgram(programCache.get(description)); } void Caches::setProgram(Program* program) { if (!program || !program->isInUse()) { if (mProgram) { mProgram->remove(); } if (program) { program->use(); } mProgram = program; } } /////////////////////////////////////////////////////////////////////////////// // Debug /////////////////////////////////////////////////////////////////////////////// Loading
libs/hwui/Caches.h +10 −6 Original line number Diff line number Diff line Loading @@ -162,8 +162,6 @@ public: void registerFunctors(uint32_t functorCount); void unregisterFunctors(uint32_t functorCount); Program* currentProgram; bool drawDeferDisabled; bool drawReorderDisabled; Loading Loading @@ -219,6 +217,10 @@ public: int propertyAmbientShadowStrength; int propertySpotShadowStrength; void setProgram(const ProgramDescription& description); void setProgram(Program* program); Program& program() { return *mProgram; } PixelBufferState& pixelBufferState() { return *mPixelBufferState; } TextureState& textureState() { return *mTextureState; } Loading Loading @@ -246,10 +248,6 @@ private: } RenderState* mRenderState; PixelBufferState* mPixelBufferState = nullptr; // TODO: move to RenderState TextureState* mTextureState = nullptr; // TODO: move to RenderState Extensions& mExtensions; // Used to render layers Loading @@ -264,6 +262,12 @@ private: uint32_t mFunctorsCount; OverdrawColorSet mOverdrawDebugColorSet; // TODO: move below to RenderState PixelBufferState* mPixelBufferState = nullptr; TextureState* mTextureState = nullptr; Program* mProgram = nullptr; // note: object owned by ProgramCache }; // class Caches }; // namespace uirenderer Loading
libs/hwui/Dither.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -89,13 +89,13 @@ void Dither::clear() { // Program management /////////////////////////////////////////////////////////////////////////////// void Dither::setupProgram(Program* program, GLuint* textureUnit) { void Dither::setupProgram(Program& program, GLuint* textureUnit) { GLuint textureSlot = (*textureUnit)++; mCaches.textureState().activateTexture(textureSlot); bindDitherTexture(); glUniform1i(program->getUniform("ditherSampler"), textureSlot); glUniform1i(program.getUniform("ditherSampler"), textureSlot); } }; // namespace uirenderer Loading
libs/hwui/Dither.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: Dither(Caches& caches); void clear(); void setupProgram(Program* program, GLuint* textureUnit); void setupProgram(Program& program, GLuint* textureUnit); private: void bindDitherTexture(); Loading
libs/hwui/FontRenderer.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -516,9 +516,8 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { TextureVertex* mesh = texture->mesh(); MeshState& meshState = renderState.meshState(); Program* program = caches.currentProgram; meshState.bindPositionVertexPointer(program, forceRebind, &mesh[0].x); meshState.bindTexCoordsVertexPointer(program, forceRebind, &mesh[0].u); meshState.bindPositionVertexPointer(forceRebind, &mesh[0].x); meshState.bindTexCoordsVertexPointer(forceRebind, &mesh[0].u); glDrawElements(GL_TRIANGLES, texture->meshElementCount(), GL_UNSIGNED_SHORT, texture->indices()); Loading