diff options
author | Bill Yi <byi@google.com> | 2014-04-29 16:07:29 -0700 |
---|---|---|
committer | Bill Yi <byi@google.com> | 2014-04-29 16:07:29 -0700 |
commit | 293513a59d36cd96a3e474dde5981380d372d8c9 (patch) | |
tree | 4268c9994be194a7f4fccdecd089af58516d0953 /libs | |
parent | 1866e5dc8bb04b58a67e54f66cb4ec22e878667d (diff) | |
parent | 0b62467b142b61ee1e449ba958ba37dfd961ef56 (diff) | |
download | frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.zip frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.tar.gz frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.tar.bz2 |
Merge commit '0b62467b142b61ee1e449ba958ba37dfd961ef56' into HEAD
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Program.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/Program.h | 1 | ||||
-rw-r--r-- | libs/hwui/TextureCache.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/font/Font.cpp | 18 | ||||
-rw-r--r-- | libs/hwui/font/Font.h | 5 | ||||
-rw-r--r-- | libs/hwui/font/FontUtil.h | 4 |
6 files changed, 20 insertions, 16 deletions
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp index 7814a01..58f5325 100644 --- a/libs/hwui/Program.cpp +++ b/libs/hwui/Program.cpp @@ -163,7 +163,7 @@ GLuint Program::buildShader(const char* source, GLenum type) { void Program::set(const mat4& projectionMatrix, const mat4& modelViewMatrix, const mat4& transformMatrix, bool offset) { - if (projectionMatrix != mProjection) { + if (projectionMatrix != mProjection || offset != mOffset) { if (CC_LIKELY(!offset)) { glUniformMatrix4fv(projection, 1, GL_FALSE, &projectionMatrix.data[0]); } else { @@ -177,6 +177,7 @@ void Program::set(const mat4& projectionMatrix, const mat4& modelViewMatrix, glUniformMatrix4fv(projection, 1, GL_FALSE, &p.data[0]); } mProjection = projectionMatrix; + mOffset = offset; } mat4 t(transformMatrix); diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h index 4f94afc..f6ac8ec 100644 --- a/libs/hwui/Program.h +++ b/libs/hwui/Program.h @@ -431,6 +431,7 @@ private: bool mHasSampler; mat4 mProjection; + bool mOffset; }; // class Program }; // namespace uirenderer diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp index 54a206b..d5ba8c3 100644 --- a/libs/hwui/TextureCache.cpp +++ b/libs/hwui/TextureCache.cpp @@ -184,7 +184,7 @@ void TextureCache::clearGarbage() { Mutex::Autolock _l(mLock); size_t count = mGarbage.size(); for (size_t i = 0; i < count; i++) { - const SkBitmap* bitmap = mGarbage.itemAt(i); + SkBitmap* bitmap = mGarbage.itemAt(i); mCache.remove(bitmap); delete bitmap; } @@ -287,10 +287,9 @@ void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool rege void TextureCache::uploadLoFiTexture(bool resize, SkBitmap* bitmap, uint32_t width, uint32_t height) { SkBitmap rgbaBitmap; - rgbaBitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); + rgbaBitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, bitmap->alphaType()); rgbaBitmap.allocPixels(); rgbaBitmap.eraseColor(0); - rgbaBitmap.setIsOpaque(bitmap->isOpaque()); SkCanvas canvas(rgbaBitmap); canvas.drawBitmap(*bitmap, 0.0f, 0.0f, NULL); diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index 8f5beb8..436dcef 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -23,6 +23,7 @@ #include <utils/Trace.h> #include <SkGlyph.h> +#include <SkGlyphCache.h> #include <SkUtils.h> #include "FontUtil.h" @@ -271,9 +272,9 @@ CachedGlyphInfo* Font::getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool pre if (cachedGlyph) { // Is the glyph still in texture cache? if (!cachedGlyph->mIsValid) { - const SkGlyph& skiaGlyph = GET_METRICS(paint, textUnit, - &mDescription.mLookupTransform); - updateGlyphCache(paint, skiaGlyph, cachedGlyph, precaching); + SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); + const SkGlyph& skiaGlyph = GET_METRICS(autoCache.getCache(), textUnit); + updateGlyphCache(paint, skiaGlyph, autoCache.getCache(), cachedGlyph, precaching); } } else { cachedGlyph = cacheGlyph(paint, textUnit, precaching); @@ -415,8 +416,8 @@ void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len } } -void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo* glyph, - bool precaching) { +void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, SkGlyphCache* skiaGlyphCache, + CachedGlyphInfo* glyph, bool precaching) { glyph->mAdvanceX = skiaGlyph.fAdvanceX; glyph->mAdvanceY = skiaGlyph.fAdvanceY; glyph->mBitmapLeft = skiaGlyph.fLeft; @@ -429,7 +430,7 @@ void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyp // Get the bitmap for the glyph if (!skiaGlyph.fImage) { - paint->findImage(skiaGlyph, &mDescription.mLookupTransform); + skiaGlyphCache->findImage(skiaGlyph); } mState->cacheBitmap(skiaGlyph, glyph, &startX, &startY, precaching); @@ -463,11 +464,12 @@ CachedGlyphInfo* Font::cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching CachedGlyphInfo* newGlyph = new CachedGlyphInfo(); mCachedGlyphs.add(glyph, newGlyph); - const SkGlyph& skiaGlyph = GET_METRICS(paint, glyph, &mDescription.mLookupTransform); + SkAutoGlyphCache autoCache(*paint, NULL, &mDescription.mLookupTransform); + const SkGlyph& skiaGlyph = GET_METRICS(autoCache.getCache(), glyph); newGlyph->mIsValid = false; newGlyph->mGlyphIndex = skiaGlyph.fID; - updateGlyphCache(paint, skiaGlyph, newGlyph, precaching); + updateGlyphCache(paint, skiaGlyph, autoCache.getCache(), newGlyph, precaching); return newGlyph; } diff --git a/libs/hwui/font/Font.h b/libs/hwui/font/Font.h index 9e7ec2d..f68b430 100644 --- a/libs/hwui/font/Font.h +++ b/libs/hwui/font/Font.h @@ -19,6 +19,7 @@ #include <utils/KeyedVector.h> +#include <SkGlyphCache.h> #include <SkScalerContext.h> #include <SkPaint.h> #include <SkPathMeasure.h> @@ -117,8 +118,8 @@ private: void invalidateTextureCache(CacheTexture* cacheTexture = NULL); CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching); - void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo* glyph, - bool precaching); + void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, SkGlyphCache* skiaGlyphCache, + CachedGlyphInfo* glyph, bool precaching); void measureCachedGlyph(CachedGlyphInfo* glyph, int x, int y, uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH, diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h index cdcb23c..c2fd5f5 100644 --- a/libs/hwui/font/FontUtil.h +++ b/libs/hwui/font/FontUtil.h @@ -40,7 +40,7 @@ #if RENDER_TEXT_AS_GLYPHS typedef uint16_t glyph_t; #define TO_GLYPH(g) g - #define GET_METRICS(paint, glyph, matrix) paint->getGlyphMetrics(glyph, matrix) + #define GET_METRICS(cache, glyph) cache->getGlyphIDMetrics(glyph) #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) false @@ -53,7 +53,7 @@ #else typedef SkUnichar glyph_t; #define TO_GLYPH(g) ((SkUnichar) g) - #define GET_METRICS(paint, glyph, matrix) paint->getUnicharMetrics(glyph, matrix) + #define GET_METRICS(cache, glyph) cache->getUnicharMetrics(glyph) #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) glyph < 0 #endif |