Loading libs/hwui/FontRenderer.cpp +34 −8 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include "Caches.h" #include "Debug.h" #include "Extensions.h" #include "Glop.h" #include "GlopBuilder.h" #include "OpenGLRenderer.h" #include "PixelBuffer.h" #include "Rect.h" Loading @@ -44,10 +46,12 @@ namespace uirenderer { // blur inputs smaller than this constant will bypass renderscript #define RS_MIN_INPUT_CUTOFF 10000 #define USE_GLOPS true /////////////////////////////////////////////////////////////////////////////// // TextSetupFunctor /////////////////////////////////////////////////////////////////////////////// status_t TextSetupFunctor::setup(GLenum glyphFormat) { void TextSetupFunctor::setup(GLenum glyphFormat) { renderer->setupDraw(); renderer->setupDrawTextGamma(paint); renderer->setupDrawDirtyRegionsDisabled(); Loading Loading @@ -84,8 +88,24 @@ status_t TextSetupFunctor::setup(GLenum glyphFormat) { renderer->setupDrawColorFilterUniforms(paint->getColorFilter()); renderer->setupDrawShaderUniforms(paint->getShader(), pureTranslate); renderer->setupDrawTextGammaUniforms(); } return NO_ERROR; void TextSetupFunctor::draw(CacheTexture& texture, bool linearFiltering) { int textureFillFlags = static_cast<int>(texture.getFormat() == GL_ALPHA ? TextureFillFlags::kIsAlphaMaskTexture : TextureFillFlags::kNone); if (linearFiltering) { textureFillFlags |= TextureFillFlags::kForceFilter; } const Matrix4& transform = pureTranslate ? Matrix4::identity() : *(renderer->currentTransform()); Glop glop; GlopBuilder(renderer->mRenderState, renderer->mCaches, &glop) .setMeshTexturedIndexedQuads(texture.mesh(), texture.meshElementCount()) .setFillTexturePaint(texture.getTexture(), textureFillFlags, paint, renderer->currentSnapshot()->alpha) .setTransform(renderer->currentSnapshot()->getOrthoMatrix(), transform, false) .setModelViewOffsetRect(0, 0, Rect(0, 0, 0, 0)) .setRoundRectClipState(renderer->currentSnapshot()->roundRectClipState) .build(); renderer->renderGlop(glop); } /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -196,7 +216,7 @@ void FontRenderer::flushLargeCaches(Vector<CacheTexture*>& cacheTextures) { while (it.next()) { it.value()->invalidateTextureCache(cacheTexture); } cacheTexture->releaseTexture(); cacheTexture->releasePixelBuffer(); } } } Loading Loading @@ -290,7 +310,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp if (!cacheTexture->getPixelBuffer()) { Caches::getInstance().textureState().activateTexture(0); // Large-glyph texture memory is allocated only as needed cacheTexture->allocateTexture(); cacheTexture->allocatePixelBuffer(); } if (!cacheTexture->mesh()) { cacheTexture->allocateMesh(); Loading Loading @@ -402,7 +422,7 @@ CacheTexture* FontRenderer::createCacheTexture(int width, int height, GLenum for if (allocate) { Caches::getInstance().textureState().activateTexture(0); cacheTexture->allocateTexture(); cacheTexture->allocatePixelBuffer(); cacheTexture->allocateMesh(); } Loading Loading @@ -497,9 +517,10 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { CacheTexture* texture = cacheTextures[i]; if (texture->canDraw()) { if (first) { checkTextureUpdate(); #if !USE_GLOPS mFunctor->setup(texture->getFormat()); checkTextureUpdate(); renderState.meshState().bindQuadIndicesBuffer(); // If returns true, a VBO was bound and we must Loading @@ -508,12 +529,17 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { forceRebind = renderState.meshState().unbindMeshBuffer(); caches.textureState().activateTexture(0); #endif first = false; mDrawn = true; } #if USE_GLOPS mFunctor->draw(*texture, mLinearFiltering); #endif #if !USE_GLOPS caches.textureState().bindTexture(texture->getTextureId()); texture->setLinearFiltering(mLinearFiltering, false); texture->setLinearFiltering(mLinearFiltering); TextureVertex* mesh = texture->mesh(); MeshState& meshState = renderState.meshState(); Loading @@ -522,7 +548,7 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { glDrawElements(GL_TRIANGLES, texture->meshElementCount(), GL_UNSIGNED_SHORT, texture->indices()); #endif texture->resetMesh(); forceRebind = false; } Loading libs/hwui/FontRenderer.h +3 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,9 @@ public: , paint(paint) { } status_t setup(GLenum glyphFormat); void setup(GLenum glyphFormat); void draw(CacheTexture& texture, bool linearFiltering); OpenGLRenderer* renderer; float x; Loading libs/hwui/OpenGLRenderer.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -2935,27 +2935,27 @@ int OpenGLRenderer::save(int flags) { } void OpenGLRenderer::restore() { return mState.restore(); mState.restore(); } void OpenGLRenderer::restoreToCount(int saveCount) { return mState.restoreToCount(saveCount); mState.restoreToCount(saveCount); } void OpenGLRenderer::translate(float dx, float dy, float dz) { return mState.translate(dx, dy, dz); mState.translate(dx, dy, dz); } void OpenGLRenderer::rotate(float degrees) { return mState.rotate(degrees); mState.rotate(degrees); } void OpenGLRenderer::scale(float sx, float sy) { return mState.scale(sx, sy); mState.scale(sx, sy); } void OpenGLRenderer::skew(float sx, float sy) { return mState.skew(sx, sy); mState.skew(sx, sy); } void OpenGLRenderer::setMatrix(const Matrix4& matrix) { Loading libs/hwui/PathCache.cpp +19 −30 Original line number Diff line number Diff line Loading @@ -40,25 +40,25 @@ namespace uirenderer { // Cache entries /////////////////////////////////////////////////////////////////////////////// PathDescription::PathDescription(): type(kShapeNone), join(SkPaint::kDefault_Join), cap(SkPaint::kDefault_Cap), style(SkPaint::kFill_Style), miter(4.0f), strokeWidth(1.0f), pathEffect(nullptr) { PathDescription::PathDescription() : type(kShapeNone) , join(SkPaint::kDefault_Join) , cap(SkPaint::kDefault_Cap) , style(SkPaint::kFill_Style) , miter(4.0f) , strokeWidth(1.0f) , pathEffect(nullptr) { memset(&shape, 0, sizeof(Shape)); } PathDescription::PathDescription(ShapeType type, const SkPaint* paint): type(type), join(paint->getStrokeJoin()), cap(paint->getStrokeCap()), style(paint->getStyle()), miter(paint->getStrokeMiter()), strokeWidth(paint->getStrokeWidth()), pathEffect(paint->getPathEffect()) { PathDescription::PathDescription(ShapeType type, const SkPaint* paint) : type(type) , join(paint->getStrokeJoin()) , cap(paint->getStrokeCap()) , style(paint->getStyle()) , miter(paint->getStrokeMiter()) , strokeWidth(paint->getStrokeWidth()) , pathEffect(paint->getPathEffect()) { memset(&shape, 0, sizeof(Shape)); } Loading Loading @@ -132,18 +132,6 @@ static void drawPath(const SkPath *path, const SkPaint* paint, SkBitmap& bitmap, canvas.drawPath(*path, pathPaint); } static PathTexture* createTexture(float left, float top, float offset, uint32_t width, uint32_t height, uint32_t id) { PathTexture* texture = new PathTexture(Caches::getInstance()); texture->left = left; texture->top = top; texture->offset = offset; texture->width = width; texture->height = height; texture->generation = id; return texture; } /////////////////////////////////////////////////////////////////////////////// // Cache constructor/destructor /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -267,7 +255,8 @@ PathTexture* PathCache::addTexture(const PathDescription& entry, const SkPath *p SkBitmap bitmap; drawPath(path, paint, bitmap, left, top, offset, width, height); PathTexture* texture = createTexture(left, top, offset, width, height, PathTexture* texture = new PathTexture(Caches::getInstance(), left, top, offset, width, height, path->getGenerationID()); generateTexture(entry, &bitmap, texture); Loading Loading @@ -441,7 +430,7 @@ void PathCache::precache(const SkPath* path, const SkPaint* paint) { if (generate) { // It is important to specify the generation ID so we do not // attempt to precache the same path several times texture = createTexture(0.0f, 0.0f, 0.0f, 0, 0, path->getGenerationID()); texture = new PathTexture(Caches::getInstance(), path->getGenerationID()); sp<PathTask> task = new PathTask(path, paint, texture); texture->setTask(task); Loading libs/hwui/PathCache.h +16 −4 Original line number Diff line number Diff line Loading @@ -59,7 +59,19 @@ class Caches; * Alpha texture used to represent a path. */ struct PathTexture: public Texture { PathTexture(Caches& caches): Texture(caches) { PathTexture(Caches& caches, float left, float top, float offset, int width, int height, int generation) : Texture(caches) , left(left) , top(top) , offset(offset) { this->width = width; this->height = height; this->generation = generation; } PathTexture(Caches& caches, int generation) : Texture(caches) { this->generation = generation; } ~PathTexture() { Loading @@ -69,15 +81,15 @@ struct PathTexture: public Texture { /** * Left coordinate of the path bounds. */ float left; float left = 0; /** * Top coordinate of the path bounds. */ float top; float top = 0; /** * Offset to draw the path at the correct origin. */ float offset; float offset = 0; sp<Task<SkBitmap*> > task() const { return mTask; Loading Loading
libs/hwui/FontRenderer.cpp +34 −8 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include "Caches.h" #include "Debug.h" #include "Extensions.h" #include "Glop.h" #include "GlopBuilder.h" #include "OpenGLRenderer.h" #include "PixelBuffer.h" #include "Rect.h" Loading @@ -44,10 +46,12 @@ namespace uirenderer { // blur inputs smaller than this constant will bypass renderscript #define RS_MIN_INPUT_CUTOFF 10000 #define USE_GLOPS true /////////////////////////////////////////////////////////////////////////////// // TextSetupFunctor /////////////////////////////////////////////////////////////////////////////// status_t TextSetupFunctor::setup(GLenum glyphFormat) { void TextSetupFunctor::setup(GLenum glyphFormat) { renderer->setupDraw(); renderer->setupDrawTextGamma(paint); renderer->setupDrawDirtyRegionsDisabled(); Loading Loading @@ -84,8 +88,24 @@ status_t TextSetupFunctor::setup(GLenum glyphFormat) { renderer->setupDrawColorFilterUniforms(paint->getColorFilter()); renderer->setupDrawShaderUniforms(paint->getShader(), pureTranslate); renderer->setupDrawTextGammaUniforms(); } return NO_ERROR; void TextSetupFunctor::draw(CacheTexture& texture, bool linearFiltering) { int textureFillFlags = static_cast<int>(texture.getFormat() == GL_ALPHA ? TextureFillFlags::kIsAlphaMaskTexture : TextureFillFlags::kNone); if (linearFiltering) { textureFillFlags |= TextureFillFlags::kForceFilter; } const Matrix4& transform = pureTranslate ? Matrix4::identity() : *(renderer->currentTransform()); Glop glop; GlopBuilder(renderer->mRenderState, renderer->mCaches, &glop) .setMeshTexturedIndexedQuads(texture.mesh(), texture.meshElementCount()) .setFillTexturePaint(texture.getTexture(), textureFillFlags, paint, renderer->currentSnapshot()->alpha) .setTransform(renderer->currentSnapshot()->getOrthoMatrix(), transform, false) .setModelViewOffsetRect(0, 0, Rect(0, 0, 0, 0)) .setRoundRectClipState(renderer->currentSnapshot()->roundRectClipState) .build(); renderer->renderGlop(glop); } /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -196,7 +216,7 @@ void FontRenderer::flushLargeCaches(Vector<CacheTexture*>& cacheTextures) { while (it.next()) { it.value()->invalidateTextureCache(cacheTexture); } cacheTexture->releaseTexture(); cacheTexture->releasePixelBuffer(); } } } Loading Loading @@ -290,7 +310,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp if (!cacheTexture->getPixelBuffer()) { Caches::getInstance().textureState().activateTexture(0); // Large-glyph texture memory is allocated only as needed cacheTexture->allocateTexture(); cacheTexture->allocatePixelBuffer(); } if (!cacheTexture->mesh()) { cacheTexture->allocateMesh(); Loading Loading @@ -402,7 +422,7 @@ CacheTexture* FontRenderer::createCacheTexture(int width, int height, GLenum for if (allocate) { Caches::getInstance().textureState().activateTexture(0); cacheTexture->allocateTexture(); cacheTexture->allocatePixelBuffer(); cacheTexture->allocateMesh(); } Loading Loading @@ -497,9 +517,10 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { CacheTexture* texture = cacheTextures[i]; if (texture->canDraw()) { if (first) { checkTextureUpdate(); #if !USE_GLOPS mFunctor->setup(texture->getFormat()); checkTextureUpdate(); renderState.meshState().bindQuadIndicesBuffer(); // If returns true, a VBO was bound and we must Loading @@ -508,12 +529,17 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { forceRebind = renderState.meshState().unbindMeshBuffer(); caches.textureState().activateTexture(0); #endif first = false; mDrawn = true; } #if USE_GLOPS mFunctor->draw(*texture, mLinearFiltering); #endif #if !USE_GLOPS caches.textureState().bindTexture(texture->getTextureId()); texture->setLinearFiltering(mLinearFiltering, false); texture->setLinearFiltering(mLinearFiltering); TextureVertex* mesh = texture->mesh(); MeshState& meshState = renderState.meshState(); Loading @@ -522,7 +548,7 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { glDrawElements(GL_TRIANGLES, texture->meshElementCount(), GL_UNSIGNED_SHORT, texture->indices()); #endif texture->resetMesh(); forceRebind = false; } Loading
libs/hwui/FontRenderer.h +3 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,9 @@ public: , paint(paint) { } status_t setup(GLenum glyphFormat); void setup(GLenum glyphFormat); void draw(CacheTexture& texture, bool linearFiltering); OpenGLRenderer* renderer; float x; Loading
libs/hwui/OpenGLRenderer.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -2935,27 +2935,27 @@ int OpenGLRenderer::save(int flags) { } void OpenGLRenderer::restore() { return mState.restore(); mState.restore(); } void OpenGLRenderer::restoreToCount(int saveCount) { return mState.restoreToCount(saveCount); mState.restoreToCount(saveCount); } void OpenGLRenderer::translate(float dx, float dy, float dz) { return mState.translate(dx, dy, dz); mState.translate(dx, dy, dz); } void OpenGLRenderer::rotate(float degrees) { return mState.rotate(degrees); mState.rotate(degrees); } void OpenGLRenderer::scale(float sx, float sy) { return mState.scale(sx, sy); mState.scale(sx, sy); } void OpenGLRenderer::skew(float sx, float sy) { return mState.skew(sx, sy); mState.skew(sx, sy); } void OpenGLRenderer::setMatrix(const Matrix4& matrix) { Loading
libs/hwui/PathCache.cpp +19 −30 Original line number Diff line number Diff line Loading @@ -40,25 +40,25 @@ namespace uirenderer { // Cache entries /////////////////////////////////////////////////////////////////////////////// PathDescription::PathDescription(): type(kShapeNone), join(SkPaint::kDefault_Join), cap(SkPaint::kDefault_Cap), style(SkPaint::kFill_Style), miter(4.0f), strokeWidth(1.0f), pathEffect(nullptr) { PathDescription::PathDescription() : type(kShapeNone) , join(SkPaint::kDefault_Join) , cap(SkPaint::kDefault_Cap) , style(SkPaint::kFill_Style) , miter(4.0f) , strokeWidth(1.0f) , pathEffect(nullptr) { memset(&shape, 0, sizeof(Shape)); } PathDescription::PathDescription(ShapeType type, const SkPaint* paint): type(type), join(paint->getStrokeJoin()), cap(paint->getStrokeCap()), style(paint->getStyle()), miter(paint->getStrokeMiter()), strokeWidth(paint->getStrokeWidth()), pathEffect(paint->getPathEffect()) { PathDescription::PathDescription(ShapeType type, const SkPaint* paint) : type(type) , join(paint->getStrokeJoin()) , cap(paint->getStrokeCap()) , style(paint->getStyle()) , miter(paint->getStrokeMiter()) , strokeWidth(paint->getStrokeWidth()) , pathEffect(paint->getPathEffect()) { memset(&shape, 0, sizeof(Shape)); } Loading Loading @@ -132,18 +132,6 @@ static void drawPath(const SkPath *path, const SkPaint* paint, SkBitmap& bitmap, canvas.drawPath(*path, pathPaint); } static PathTexture* createTexture(float left, float top, float offset, uint32_t width, uint32_t height, uint32_t id) { PathTexture* texture = new PathTexture(Caches::getInstance()); texture->left = left; texture->top = top; texture->offset = offset; texture->width = width; texture->height = height; texture->generation = id; return texture; } /////////////////////////////////////////////////////////////////////////////// // Cache constructor/destructor /////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -267,7 +255,8 @@ PathTexture* PathCache::addTexture(const PathDescription& entry, const SkPath *p SkBitmap bitmap; drawPath(path, paint, bitmap, left, top, offset, width, height); PathTexture* texture = createTexture(left, top, offset, width, height, PathTexture* texture = new PathTexture(Caches::getInstance(), left, top, offset, width, height, path->getGenerationID()); generateTexture(entry, &bitmap, texture); Loading Loading @@ -441,7 +430,7 @@ void PathCache::precache(const SkPath* path, const SkPaint* paint) { if (generate) { // It is important to specify the generation ID so we do not // attempt to precache the same path several times texture = createTexture(0.0f, 0.0f, 0.0f, 0, 0, path->getGenerationID()); texture = new PathTexture(Caches::getInstance(), path->getGenerationID()); sp<PathTask> task = new PathTask(path, paint, texture); texture->setTask(task); Loading
libs/hwui/PathCache.h +16 −4 Original line number Diff line number Diff line Loading @@ -59,7 +59,19 @@ class Caches; * Alpha texture used to represent a path. */ struct PathTexture: public Texture { PathTexture(Caches& caches): Texture(caches) { PathTexture(Caches& caches, float left, float top, float offset, int width, int height, int generation) : Texture(caches) , left(left) , top(top) , offset(offset) { this->width = width; this->height = height; this->generation = generation; } PathTexture(Caches& caches, int generation) : Texture(caches) { this->generation = generation; } ~PathTexture() { Loading @@ -69,15 +81,15 @@ struct PathTexture: public Texture { /** * Left coordinate of the path bounds. */ float left; float left = 0; /** * Top coordinate of the path bounds. */ float top; float top = 0; /** * Offset to draw the path at the correct origin. */ float offset; float offset = 0; sp<Task<SkBitmap*> > task() const { return mTask; Loading