Loading libs/hwui/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ ifeq ($(USE_OPENGL_RENDERER),true) SkiaShader.cpp \ Snapshot.cpp \ Stencil.cpp \ Texture.cpp \ TextureCache.cpp \ TextDropShadowCache.cpp Loading libs/hwui/AssetAtlas.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include "AssetAtlas.h" #include "Caches.h" #include <GLES2/gl2ext.h> Loading @@ -33,12 +34,14 @@ void AssetAtlas::init(sp<GraphicBuffer> buffer, int* map, int count) { mImage = new Image(buffer); if (mImage->getTexture()) { mTexture = new Texture(); Caches& caches = Caches::getInstance(); mTexture = new Texture(caches); mTexture->id = mImage->getTexture(); mTexture->width = buffer->getWidth(); mTexture->height = buffer->getHeight(); createEntries(map, count); createEntries(caches, map, count); } else { ALOGW("Could not create atlas image"); Loading Loading @@ -82,7 +85,7 @@ Texture* AssetAtlas::getEntryTexture(SkBitmap* const bitmap) const { * instead of applying the changes to the virtual textures. */ struct DelegateTexture: public Texture { DelegateTexture(Texture* delegate): Texture(), mDelegate(delegate) { } DelegateTexture(Caches& caches, Texture* delegate): Texture(caches), mDelegate(delegate) { } virtual void setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture = false, bool force = false, GLenum renderTarget = GL_TEXTURE_2D) { Loading @@ -100,7 +103,7 @@ private: /** * TODO: This method does not take the rotation flag into account */ void AssetAtlas::createEntries(int* map, int count) { void AssetAtlas::createEntries(Caches& caches, int* map, int count) { const float width = float(mTexture->width); const float height = float(mTexture->height); Loading @@ -117,7 +120,7 @@ void AssetAtlas::createEntries(int* map, int count) { x / width, (x + bitmap->width()) / width, y / height, (y + bitmap->height()) / height); Texture* texture = new DelegateTexture(mTexture); Texture* texture = new DelegateTexture(caches, mTexture); Entry* entry = new Entry(bitmap, x, y, rotated, texture, mapper, *this); texture->id = mTexture->id; Loading libs/hwui/AssetAtlas.h +3 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ namespace android { namespace uirenderer { class Caches; /** * An asset atlas holds a collection of framework bitmaps in a single OpenGL * texture. Each bitmap is associated with a location, defined in pixels, Loading Loading @@ -157,7 +159,7 @@ public: Texture* getEntryTexture(SkBitmap* const bitmap) const; private: void createEntries(int* map, int count); void createEntries(Caches& caches, int* map, int count); Texture* mTexture; Image* mImage; Loading libs/hwui/Caches.cpp +22 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,8 @@ namespace uirenderer { // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), mInitialized(false) { Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), mInitialized(false) { init(); initFont(); initConstraints(); Loading Loading @@ -100,6 +101,8 @@ bool Caches::init() { mInitialized = true; resetBoundTextures(); return true; } Loading Loading @@ -491,6 +494,24 @@ void Caches::activeTexture(GLuint textureUnit) { } } void Caches::bindTexture(GLuint texture) { if (mBoundTextures[mTextureUnit] != texture) { glBindTexture(GL_TEXTURE_2D, texture); mBoundTextures[mTextureUnit] = texture; } } void Caches::bindTexture(GLenum target, GLuint texture) { if (mBoundTextures[mTextureUnit] != texture) { glBindTexture(target, texture); mBoundTextures[mTextureUnit] = texture; } } void Caches::resetBoundTextures() { memset(mBoundTextures, 0, REQUIRED_TEXTURE_UNITS_COUNT * sizeof(GLuint)); } /////////////////////////////////////////////////////////////////////////////// // Scissor /////////////////////////////////////////////////////////////////////////////// Loading libs/hwui/Caches.h +20 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ namespace uirenderer { // Globals /////////////////////////////////////////////////////////////////////////////// // GL ES 2.0 defines that at least 16 texture units must be supported #define REQUIRED_TEXTURE_UNITS_COUNT 3 #define REGION_MESH_QUAD_COUNT 512 Loading @@ -79,6 +80,7 @@ static const GLsizei gVertexAAWidthOffset = 2 * sizeof(float); static const GLsizei gVertexAALengthOffset = 3 * sizeof(float); static const GLsizei gMeshCount = 4; // Must define as many texture units as specified by REQUIRED_TEXTURE_UNITS_COUNT static const GLenum gTextureUnits[] = { GL_TEXTURE0, GL_TEXTURE1, Loading Loading @@ -222,6 +224,22 @@ public: */ void activeTexture(GLuint textureUnit); /** * Binds the specified texture as a GL_TEXTURE_2D texture. */ void bindTexture(GLuint texture); /** * Binds the specified texture.. */ void bindTexture(GLenum target, GLuint texture); /** * Signals that the cache of bound textures should be cleared. * Other users of the context may have altered which textures are bound. */ void resetBoundTextures(); /** * Sets the scissor for the current surface. */ Loading Loading @@ -363,6 +381,8 @@ private: bool mInitialized; uint32_t mFunctorsCount; GLuint mBoundTextures[REQUIRED_TEXTURE_UNITS_COUNT]; }; // class Caches }; // namespace uirenderer Loading Loading
libs/hwui/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ ifeq ($(USE_OPENGL_RENDERER),true) SkiaShader.cpp \ Snapshot.cpp \ Stencil.cpp \ Texture.cpp \ TextureCache.cpp \ TextDropShadowCache.cpp Loading
libs/hwui/AssetAtlas.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include "AssetAtlas.h" #include "Caches.h" #include <GLES2/gl2ext.h> Loading @@ -33,12 +34,14 @@ void AssetAtlas::init(sp<GraphicBuffer> buffer, int* map, int count) { mImage = new Image(buffer); if (mImage->getTexture()) { mTexture = new Texture(); Caches& caches = Caches::getInstance(); mTexture = new Texture(caches); mTexture->id = mImage->getTexture(); mTexture->width = buffer->getWidth(); mTexture->height = buffer->getHeight(); createEntries(map, count); createEntries(caches, map, count); } else { ALOGW("Could not create atlas image"); Loading Loading @@ -82,7 +85,7 @@ Texture* AssetAtlas::getEntryTexture(SkBitmap* const bitmap) const { * instead of applying the changes to the virtual textures. */ struct DelegateTexture: public Texture { DelegateTexture(Texture* delegate): Texture(), mDelegate(delegate) { } DelegateTexture(Caches& caches, Texture* delegate): Texture(caches), mDelegate(delegate) { } virtual void setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture = false, bool force = false, GLenum renderTarget = GL_TEXTURE_2D) { Loading @@ -100,7 +103,7 @@ private: /** * TODO: This method does not take the rotation flag into account */ void AssetAtlas::createEntries(int* map, int count) { void AssetAtlas::createEntries(Caches& caches, int* map, int count) { const float width = float(mTexture->width); const float height = float(mTexture->height); Loading @@ -117,7 +120,7 @@ void AssetAtlas::createEntries(int* map, int count) { x / width, (x + bitmap->width()) / width, y / height, (y + bitmap->height()) / height); Texture* texture = new DelegateTexture(mTexture); Texture* texture = new DelegateTexture(caches, mTexture); Entry* entry = new Entry(bitmap, x, y, rotated, texture, mapper, *this); texture->id = mTexture->id; Loading
libs/hwui/AssetAtlas.h +3 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ namespace android { namespace uirenderer { class Caches; /** * An asset atlas holds a collection of framework bitmaps in a single OpenGL * texture. Each bitmap is associated with a location, defined in pixels, Loading Loading @@ -157,7 +159,7 @@ public: Texture* getEntryTexture(SkBitmap* const bitmap) const; private: void createEntries(int* map, int count); void createEntries(Caches& caches, int* map, int count); Texture* mTexture; Image* mImage; Loading
libs/hwui/Caches.cpp +22 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,8 @@ namespace uirenderer { // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), mInitialized(false) { Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), mInitialized(false) { init(); initFont(); initConstraints(); Loading Loading @@ -100,6 +101,8 @@ bool Caches::init() { mInitialized = true; resetBoundTextures(); return true; } Loading Loading @@ -491,6 +494,24 @@ void Caches::activeTexture(GLuint textureUnit) { } } void Caches::bindTexture(GLuint texture) { if (mBoundTextures[mTextureUnit] != texture) { glBindTexture(GL_TEXTURE_2D, texture); mBoundTextures[mTextureUnit] = texture; } } void Caches::bindTexture(GLenum target, GLuint texture) { if (mBoundTextures[mTextureUnit] != texture) { glBindTexture(target, texture); mBoundTextures[mTextureUnit] = texture; } } void Caches::resetBoundTextures() { memset(mBoundTextures, 0, REQUIRED_TEXTURE_UNITS_COUNT * sizeof(GLuint)); } /////////////////////////////////////////////////////////////////////////////// // Scissor /////////////////////////////////////////////////////////////////////////////// Loading
libs/hwui/Caches.h +20 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ namespace uirenderer { // Globals /////////////////////////////////////////////////////////////////////////////// // GL ES 2.0 defines that at least 16 texture units must be supported #define REQUIRED_TEXTURE_UNITS_COUNT 3 #define REGION_MESH_QUAD_COUNT 512 Loading @@ -79,6 +80,7 @@ static const GLsizei gVertexAAWidthOffset = 2 * sizeof(float); static const GLsizei gVertexAALengthOffset = 3 * sizeof(float); static const GLsizei gMeshCount = 4; // Must define as many texture units as specified by REQUIRED_TEXTURE_UNITS_COUNT static const GLenum gTextureUnits[] = { GL_TEXTURE0, GL_TEXTURE1, Loading Loading @@ -222,6 +224,22 @@ public: */ void activeTexture(GLuint textureUnit); /** * Binds the specified texture as a GL_TEXTURE_2D texture. */ void bindTexture(GLuint texture); /** * Binds the specified texture.. */ void bindTexture(GLenum target, GLuint texture); /** * Signals that the cache of bound textures should be cleared. * Other users of the context may have altered which textures are bound. */ void resetBoundTextures(); /** * Sets the scissor for the current surface. */ Loading Loading @@ -363,6 +381,8 @@ private: bool mInitialized; uint32_t mFunctorsCount; GLuint mBoundTextures[REQUIRED_TEXTURE_UNITS_COUNT]; }; // class Caches }; // namespace uirenderer Loading