Loading core/java/android/view/ViewRoot.java +11 −5 Original line number Diff line number Diff line Loading @@ -1584,11 +1584,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn mAttachInfo.mRootView = null; mAttachInfo.mSurface = null; if (mHwRenderer != null) { mHwRenderer.destroy(true); mHwRenderer = null; mAttachInfo.mHardwareAccelerated = false; } destroyHardwareRenderer(); mSurface.release(); Loading Loading @@ -2542,6 +2538,8 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn if (LOCAL_LOGV) Log.v(TAG, "DIE in " + this + " of " + mSurface); synchronized (this) { if (mAdded && !mFirst) { destroyHardwareRenderer(); int viewVisibility = mView.getVisibility(); boolean viewVisibilityChanged = mViewVisibility != viewVisibility; if (mWindowAttributesChanged || viewVisibilityChanged) { Loading @@ -2566,6 +2564,14 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn } } private void destroyHardwareRenderer() { if (mHwRenderer != null) { mHwRenderer.destroy(true); mHwRenderer = null; mAttachInfo.mHardwareAccelerated = false; } } public void dispatchFinishedEvent(int seq, boolean handled) { Message msg = obtainMessage(FINISHED_EVENT); msg.arg1 = seq; Loading libs/hwui/Caches.h +3 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "ProgramCache.h" #include "PathCache.h" #include "TextDropShadowCache.h" #include "Line.h" namespace android { namespace uirenderer { Loading Loading @@ -64,6 +65,8 @@ public: PatchCache patchCache; TextDropShadowCache dropShadowCache; GammaFontRenderer fontRenderer; Line line; }; // class Caches }; // namespace uirenderer Loading libs/hwui/OpenGLRenderer.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -133,6 +133,8 @@ OpenGLRenderer::OpenGLRenderer(): mCaches(Caches::getInstance()) { OpenGLRenderer::~OpenGLRenderer() { LOGD("Destroy OpenGLRenderer"); // The context has already been destroyed at this point, do not call // GL APIs. All GL state should be kept in Caches.h } /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -615,14 +617,14 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { const bool isAA = paint->isAntiAlias(); if (isAA) { GLuint textureUnit = 0; setupTextureAlpha8(mLine.getTexture(), 0, 0, textureUnit, 0.0f, 0.0f, r, g, b, a, mode, false, true, mLine.getVertices(), mLine.getTexCoords()); setupTextureAlpha8(mCaches.line.getTexture(), 0, 0, textureUnit, 0.0f, 0.0f, r, g, b, a, mode, false, true, mCaches.line.getVertices(), mCaches.line.getTexCoords()); } else { setupColorRect(0.0f, 0.0f, 1.0f, 1.0f, r, g, b, a, mode, false); } const float strokeWidth = paint->getStrokeWidth(); const GLsizei elementsCount = isAA ? mLine.getElementsCount() : gMeshCount; const GLsizei elementsCount = isAA ? mCaches.line.getElementsCount() : gMeshCount; const GLenum drawMode = isAA ? GL_TRIANGLES : GL_TRIANGLE_STRIP; for (int i = 0; i < count; i += 4) { Loading @@ -630,7 +632,7 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { float ty = 0.0f; if (isAA) { mLine.update(points[i], points[i + 1], points[i + 2], points[i + 3], mCaches.line.update(points[i], points[i + 1], points[i + 2], points[i + 3], strokeWidth, tx, ty); } else { ty = strokeWidth <= 1.0f ? 0.0f : -strokeWidth * 0.5f; Loading @@ -647,7 +649,8 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { } mModelView.translate(tx, ty, 0.0f); if (!isAA) { float length = mLine.getLength(points[i], points[i + 1], points[i + 2], points[i + 3]); float length = mCaches.line.getLength(points[i], points[i + 1], points[i + 2], points[i + 3]); mModelView.scale(length, strokeWidth, 1.0f); } mCaches.currentProgram->set(mOrthoMatrix, mModelView, *mSnapshot->transform); Loading @@ -659,8 +662,10 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { glDrawArrays(drawMode, 0, elementsCount); } if (isAA) { glDisableVertexAttribArray(mCaches.currentProgram->getAttrib("texCoords")); } } void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { const Rect& clip = *mSnapshot->clipRect; Loading libs/hwui/OpenGLRenderer.h +0 −4 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ #include "SkiaShader.h" #include "SkiaColorFilter.h" #include "Caches.h" #include "Line.h" namespace android { namespace uirenderer { Loading Loading @@ -420,9 +419,6 @@ private: // List of rectangles to clear due to calls to saveLayer() Vector<Rect*> mLayers; // Single object used to draw lines Line mLine; // Misc GLint mMaxTextureSize; Loading libs/hwui/SkiaShader.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -94,6 +94,11 @@ void SkiaBitmapShader::describe(ProgramDescription& description, const Extension description.isBitmapNpot = true; description.bitmapWrapS = gTileModes[mTileX]; description.bitmapWrapT = gTileModes[mTileY]; mWrapS = GL_CLAMP_TO_EDGE; mWrapT = GL_CLAMP_TO_EDGE; } else { mWrapS = gTileModes[mTileX]; mWrapT = gTileModes[mTileY]; } } Loading Loading @@ -121,7 +126,7 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView, } // Uniforms bindTexture(texture->id, gTileModes[mTileX], gTileModes[mTileY], textureSlot); bindTexture(texture->id, mWrapS, mWrapT, textureSlot); glUniform1i(program->getUniform("bitmapSampler"), textureSlot); glUniformMatrix4fv(program->getUniform("textureTransform"), 1, GL_FALSE, &textureTransform.data[0]); Loading Loading
core/java/android/view/ViewRoot.java +11 −5 Original line number Diff line number Diff line Loading @@ -1584,11 +1584,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn mAttachInfo.mRootView = null; mAttachInfo.mSurface = null; if (mHwRenderer != null) { mHwRenderer.destroy(true); mHwRenderer = null; mAttachInfo.mHardwareAccelerated = false; } destroyHardwareRenderer(); mSurface.release(); Loading Loading @@ -2542,6 +2538,8 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn if (LOCAL_LOGV) Log.v(TAG, "DIE in " + this + " of " + mSurface); synchronized (this) { if (mAdded && !mFirst) { destroyHardwareRenderer(); int viewVisibility = mView.getVisibility(); boolean viewVisibilityChanged = mViewVisibility != viewVisibility; if (mWindowAttributesChanged || viewVisibilityChanged) { Loading @@ -2566,6 +2564,14 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn } } private void destroyHardwareRenderer() { if (mHwRenderer != null) { mHwRenderer.destroy(true); mHwRenderer = null; mAttachInfo.mHardwareAccelerated = false; } } public void dispatchFinishedEvent(int seq, boolean handled) { Message msg = obtainMessage(FINISHED_EVENT); msg.arg1 = seq; Loading
libs/hwui/Caches.h +3 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "ProgramCache.h" #include "PathCache.h" #include "TextDropShadowCache.h" #include "Line.h" namespace android { namespace uirenderer { Loading Loading @@ -64,6 +65,8 @@ public: PatchCache patchCache; TextDropShadowCache dropShadowCache; GammaFontRenderer fontRenderer; Line line; }; // class Caches }; // namespace uirenderer Loading
libs/hwui/OpenGLRenderer.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -133,6 +133,8 @@ OpenGLRenderer::OpenGLRenderer(): mCaches(Caches::getInstance()) { OpenGLRenderer::~OpenGLRenderer() { LOGD("Destroy OpenGLRenderer"); // The context has already been destroyed at this point, do not call // GL APIs. All GL state should be kept in Caches.h } /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -615,14 +617,14 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { const bool isAA = paint->isAntiAlias(); if (isAA) { GLuint textureUnit = 0; setupTextureAlpha8(mLine.getTexture(), 0, 0, textureUnit, 0.0f, 0.0f, r, g, b, a, mode, false, true, mLine.getVertices(), mLine.getTexCoords()); setupTextureAlpha8(mCaches.line.getTexture(), 0, 0, textureUnit, 0.0f, 0.0f, r, g, b, a, mode, false, true, mCaches.line.getVertices(), mCaches.line.getTexCoords()); } else { setupColorRect(0.0f, 0.0f, 1.0f, 1.0f, r, g, b, a, mode, false); } const float strokeWidth = paint->getStrokeWidth(); const GLsizei elementsCount = isAA ? mLine.getElementsCount() : gMeshCount; const GLsizei elementsCount = isAA ? mCaches.line.getElementsCount() : gMeshCount; const GLenum drawMode = isAA ? GL_TRIANGLES : GL_TRIANGLE_STRIP; for (int i = 0; i < count; i += 4) { Loading @@ -630,7 +632,7 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { float ty = 0.0f; if (isAA) { mLine.update(points[i], points[i + 1], points[i + 2], points[i + 3], mCaches.line.update(points[i], points[i + 1], points[i + 2], points[i + 3], strokeWidth, tx, ty); } else { ty = strokeWidth <= 1.0f ? 0.0f : -strokeWidth * 0.5f; Loading @@ -647,7 +649,8 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { } mModelView.translate(tx, ty, 0.0f); if (!isAA) { float length = mLine.getLength(points[i], points[i + 1], points[i + 2], points[i + 3]); float length = mCaches.line.getLength(points[i], points[i + 1], points[i + 2], points[i + 3]); mModelView.scale(length, strokeWidth, 1.0f); } mCaches.currentProgram->set(mOrthoMatrix, mModelView, *mSnapshot->transform); Loading @@ -659,8 +662,10 @@ void OpenGLRenderer::drawLines(float* points, int count, const SkPaint* paint) { glDrawArrays(drawMode, 0, elementsCount); } if (isAA) { glDisableVertexAttribArray(mCaches.currentProgram->getAttrib("texCoords")); } } void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { const Rect& clip = *mSnapshot->clipRect; Loading
libs/hwui/OpenGLRenderer.h +0 −4 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ #include "SkiaShader.h" #include "SkiaColorFilter.h" #include "Caches.h" #include "Line.h" namespace android { namespace uirenderer { Loading Loading @@ -420,9 +419,6 @@ private: // List of rectangles to clear due to calls to saveLayer() Vector<Rect*> mLayers; // Single object used to draw lines Line mLine; // Misc GLint mMaxTextureSize; Loading
libs/hwui/SkiaShader.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -94,6 +94,11 @@ void SkiaBitmapShader::describe(ProgramDescription& description, const Extension description.isBitmapNpot = true; description.bitmapWrapS = gTileModes[mTileX]; description.bitmapWrapT = gTileModes[mTileY]; mWrapS = GL_CLAMP_TO_EDGE; mWrapT = GL_CLAMP_TO_EDGE; } else { mWrapS = gTileModes[mTileX]; mWrapT = gTileModes[mTileY]; } } Loading Loading @@ -121,7 +126,7 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView, } // Uniforms bindTexture(texture->id, gTileModes[mTileX], gTileModes[mTileY], textureSlot); bindTexture(texture->id, mWrapS, mWrapT, textureSlot); glUniform1i(program->getUniform("bitmapSampler"), textureSlot); glUniformMatrix4fv(program->getUniform("textureTransform"), 1, GL_FALSE, &textureTransform.data[0]); Loading