diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/diskusage/dirsize.c | 7 | ||||
-rw-r--r-- | libs/hwui/Caches.cpp | 18 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 6 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 42 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 7 | ||||
-rw-r--r-- | libs/hwui/Matrix.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/Matrix.h | 1 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 30 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 3 | ||||
-rw-r--r-- | libs/hwui/SkiaColorFilter.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/Snapshot.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Snapshot.h | 5 | ||||
-rw-r--r-- | libs/hwui/font/Font.cpp | 2 |
13 files changed, 106 insertions, 30 deletions
diff --git a/libs/diskusage/dirsize.c b/libs/diskusage/dirsize.c index 45e7b2a..6703783 100644 --- a/libs/diskusage/dirsize.c +++ b/libs/diskusage/dirsize.c @@ -49,6 +49,9 @@ int64_t calculate_dir_size(int dfd) while ((de = readdir(d))) { const char *name = de->d_name; + if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) { + size += stat_size(&s); + } if (de->d_type == DT_DIR) { int subfd; @@ -64,10 +67,6 @@ int64_t calculate_dir_size(int dfd) if (subfd >= 0) { size += calculate_dir_size(subfd); } - } else { - if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) { - size += stat_size(&s); - } } } closedir(d); diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 2883f37..e443294 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -87,6 +87,8 @@ void Caches::init() { lastDstMode = GL_ZERO; currentProgram = NULL; + mFunctorsCount = 0; + mInitialized = true; } @@ -458,6 +460,22 @@ void Caches::endTiling() { } } +bool Caches::hasRegisteredFunctors() { + return mFunctorsCount > 0; +} + +void Caches::registerFunctors(uint32_t functorCount) { + mFunctorsCount += functorCount; +} + +void Caches::unregisterFunctors(uint32_t functorCount) { + if (functorCount > mFunctorsCount) { + mFunctorsCount = 0; + } else { + mFunctorsCount -= functorCount; + } +} + /////////////////////////////////////////////////////////////////////////////// // Regions /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 4c292b6..ad1ff6f 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -226,6 +226,10 @@ public: void dumpMemoryUsage(); void dumpMemoryUsage(String8& log); + bool hasRegisteredFunctors(); + void registerFunctors(uint32_t functorCount); + void unregisterFunctors(uint32_t functorCount); + bool blend; GLenum lastSrcMode; GLenum lastDstMode; @@ -316,6 +320,8 @@ private: DebugLevel mDebugLevel; bool mInitialized; + + uint32_t mFunctorsCount; }; // class Caches }; // namespace uirenderer diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index cc72df6..f84c847 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -143,6 +143,7 @@ void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) { void DisplayList::clearResources() { sk_free((void*) mReader.base()); + mReader.setMemory(NULL, 0); delete mTransformMatrix; delete mTransformCamera; @@ -157,6 +158,7 @@ void DisplayList::clearResources() { mAnimationMatrix = NULL; Caches& caches = Caches::getInstance(); + caches.unregisterFunctors(mFunctorCount); caches.resourceCache.lock(); for (size_t i = 0; i < mBitmapResources.size(); i++) { @@ -215,24 +217,28 @@ void DisplayList::clearResources() { void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) { const SkWriter32& writer = recorder.writeStream(); - init(); - - if (writer.size() == 0) { - return; - } if (reusing) { // re-using display list - clear out previous allocations clearResources(); } + + init(); initProperties(); + if (writer.size() == 0) { + return; + } + mSize = writer.size(); void* buffer = sk_malloc_throw(mSize); writer.flatten(buffer); mReader.setMemory(buffer, mSize); + mFunctorCount = recorder.getFunctorCount(); + Caches& caches = Caches::getInstance(); + caches.registerFunctors(mFunctorCount); caches.resourceCache.lock(); const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources(); @@ -296,6 +302,7 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde void DisplayList::init() { mSize = 0; mIsRenderable = true; + mFunctorCount = 0; } size_t DisplayList::getSize() { @@ -1340,7 +1347,8 @@ status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flag DisplayListRenderer::DisplayListRenderer(): mCaches(Caches::getInstance()), mWriter(MIN_WRITER_SIZE), - mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false), mHasDrawOps(false) { + mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false), + mHasDrawOps(false), mFunctorCount(0) { } DisplayListRenderer::~DisplayListRenderer() { @@ -1397,6 +1405,7 @@ void DisplayListRenderer::reset() { mLayers.clear(); mHasDrawOps = false; + mFunctorCount = 0; } /////////////////////////////////////////////////////////////////////////////// @@ -1453,6 +1462,7 @@ status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) // Ignore dirty during recording, it matters only when we replay addOp(DisplayList::DrawGLFunction); addInt((int) functor); + mFunctorCount++; return DrawGlInfo::kStatusDone; // No invalidate needed at record-time } @@ -1563,7 +1573,8 @@ status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* } status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) { - const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height()); + const bool reject = quickRejectNoScissor(left, top, + left + bitmap->width(), top + bitmap->height()); uint32_t* location = addOp(DisplayList::DrawBitmap, reject); addBitmap(bitmap); addPoint(left, top); @@ -1577,7 +1588,7 @@ status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkP const mat4 transform(*matrix); transform.mapRect(r); - const bool reject = quickReject(r.left, r.top, r.right, r.bottom); + const bool reject = quickRejectNoScissor(r.left, r.top, r.right, r.bottom); uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject); addBitmap(bitmap); addMatrix(matrix); @@ -1589,7 +1600,7 @@ status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkP status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop, float srcRight, float srcBottom, float dstLeft, float dstTop, float dstRight, float dstBottom, SkPaint* paint) { - const bool reject = quickReject(dstLeft, dstTop, dstRight, dstBottom); + const bool reject = quickRejectNoScissor(dstLeft, dstTop, dstRight, dstBottom); uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject); addBitmap(bitmap); addBounds(srcLeft, srcTop, srcRight, srcBottom); @@ -1601,7 +1612,8 @@ status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint) { - const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height()); + const bool reject = quickRejectNoScissor(left, top, + left + bitmap->width(), top + bitmap->height()); uint32_t* location = addOp(DisplayList::DrawBitmapData, reject); addBitmapData(bitmap); addPoint(left, top); @@ -1634,7 +1646,7 @@ status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, SkXfermode::Mode mode; OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode); - const bool reject = quickReject(left, top, right, bottom); + const bool reject = quickRejectNoScissor(left, top, right, bottom); uint32_t* location = addOp(DisplayList::DrawPatch, reject); addBitmap(bitmap); addInts(xDivs, width); @@ -1657,7 +1669,7 @@ status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) { status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom, SkPaint* paint) { const bool reject = paint->getStyle() == SkPaint::kFill_Style && - quickReject(left, top, right, bottom); + quickRejectNoScissor(left, top, right, bottom); uint32_t* location = addOp(DisplayList::DrawRect, reject); addBounds(left, top, right, bottom); addPaint(paint); @@ -1668,7 +1680,7 @@ status_t DisplayListRenderer::drawRect(float left, float top, float right, float status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, SkPaint* paint) { const bool reject = paint->getStyle() == SkPaint::kFill_Style && - quickReject(left, top, right, bottom); + quickRejectNoScissor(left, top, right, bottom); uint32_t* location = addOp(DisplayList::DrawRoundRect, reject); addBounds(left, top, right, bottom); addPoint(rx, ry); @@ -1711,7 +1723,7 @@ status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) { left -= offset; top -= offset; - const bool reject = quickReject(left, top, left + width, top + height); + const bool reject = quickRejectNoScissor(left, top, left + width, top + height); uint32_t* location = addOp(DisplayList::DrawPath, reject); addPath(path); addPaint(paint); @@ -1781,7 +1793,7 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) { SkPaint::FontMetrics metrics; paint->getFontMetrics(&metrics, 0.0f); - reject = quickReject(x, y + metrics.fTop, x + length, y + metrics.fBottom); + reject = quickRejectNoScissor(x, y + metrics.fTop, x + length, y + metrics.fBottom); } uint32_t* location = addOp(DisplayList::DrawText, reject); diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index a0b1630..39061f4 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -503,6 +503,7 @@ private: size_t mSize; bool mIsRenderable; + uint32_t mFunctorCount; String8 mName; @@ -661,6 +662,10 @@ public: return mMatrices; } + uint32_t getFunctorCount() const { + return mFunctorCount; + } + private: void insertRestoreToCount() { if (mRestoreSaveCount >= 0) { @@ -887,6 +892,8 @@ private: bool mHasTranslate; bool mHasDrawOps; + uint32_t mFunctorCount; + friend class DisplayList; }; // class DisplayListRenderer diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index 87add17..a924362 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -73,6 +73,11 @@ bool Matrix4::isIdentity() const { return mIsIdentity; } +bool Matrix4::isPerspective() const { + return data[kPerspective0] != 0.0f || data[kPerspective1] != 0.0f || + data[kPerspective2] != 1.0f; +} + void Matrix4::load(const float* v) { memcpy(data, v, sizeof(data)); // TODO: Do something smarter here diff --git a/libs/hwui/Matrix.h b/libs/hwui/Matrix.h index 02b781e..f86823d 100644 --- a/libs/hwui/Matrix.h +++ b/libs/hwui/Matrix.h @@ -115,6 +115,7 @@ public: bool isPureTranslate() const; bool isSimple() const; bool isIdentity() const; + bool isPerspective() const; bool changesBounds() const; diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index b0328f5..c015077 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -193,6 +193,11 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto syncState(); + // Functors break the tiling extension in pretty spectacular ways + // This ensures we don't use tiling when a functor is going to be + // invoked during the frame + mSuppressTiling = mCaches.hasRegisteredFunctors(); + mTilingSnapshot = mSnapshot; startTiling(mTilingSnapshot, true); @@ -221,17 +226,19 @@ void OpenGLRenderer::syncState() { } void OpenGLRenderer::startTiling(const sp<Snapshot>& s, bool opaque) { - Rect* clip = mTilingSnapshot->clipRect; - if (s->flags & Snapshot::kFlagIsFboLayer) { - clip = s->clipRect; - } + if (!mSuppressTiling) { + Rect* clip = mTilingSnapshot->clipRect; + if (s->flags & Snapshot::kFlagIsFboLayer) { + clip = s->clipRect; + } - mCaches.startTiling(clip->left, s->height - clip->bottom, - clip->right - clip->left, clip->bottom - clip->top, opaque); + mCaches.startTiling(clip->left, s->height - clip->bottom, + clip->right - clip->left, clip->bottom - clip->top, opaque); + } } void OpenGLRenderer::endTiling() { - mCaches.endTiling(); + if (!mSuppressTiling) mCaches.endTiling(); } void OpenGLRenderer::finish() { @@ -2640,20 +2647,21 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, setupDrawShaderUniforms(pureTranslate); setupDrawTextGammaUniforms(); - const Rect* clip = pureTranslate ? mSnapshot->clipRect : &mSnapshot->getLocalClip(); + const Rect* clip = pureTranslate ? mSnapshot->clipRect : + (mSnapshot->hasPerspectiveTransform() ? NULL : &mSnapshot->getLocalClip()); Rect bounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f); const bool hasActiveLayer = hasLayer(); bool status; - if (paint->getTextAlign() != SkPaint::kLeft_Align) { + if (CC_UNLIKELY(paint->getTextAlign() != SkPaint::kLeft_Align)) { SkPaint paintCopy(*paint); paintCopy.setTextAlign(SkPaint::kLeft_Align); status = fontRenderer.renderPosText(&paintCopy, clip, text, 0, bytesCount, count, x, y, - positions, hasActiveLayer ? &bounds : NULL); + positions, hasActiveLayer ? &bounds : NULL); } else { status = fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y, - positions, hasActiveLayer ? &bounds : NULL); + positions, hasActiveLayer ? &bounds : NULL); } if (status && hasActiveLayer) { diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index bc9b693..a40d69a 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -817,6 +817,9 @@ private: // Properties.h bool mScissorOptimizationDisabled; + // No-ops start/endTiling when set + bool mSuppressTiling; + friend class DisplayListRenderer; }; // class OpenGLRenderer diff --git a/libs/hwui/SkiaColorFilter.cpp b/libs/hwui/SkiaColorFilter.cpp index f754388..df918be 100644 --- a/libs/hwui/SkiaColorFilter.cpp +++ b/libs/hwui/SkiaColorFilter.cpp @@ -36,6 +36,12 @@ SkiaColorFilter::~SkiaColorFilter() { SkiaColorMatrixFilter::SkiaColorMatrixFilter(SkColorFilter* skFilter, float* matrix, float* vector): SkiaColorFilter(skFilter, kColorMatrix, true), mMatrix(matrix), mVector(vector) { + // Skia uses the range [0..255] for the addition vector, but we need + // the [0..1] range to apply the vector in GLSL + for (int i = 0; i < 4; i++) { + mVector[i] /= 255.0f; + } + // TODO: We should be smarter about this mBlend = true; } diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp index 4484676..fbc8455 100644 --- a/libs/hwui/Snapshot.cpp +++ b/libs/hwui/Snapshot.cpp @@ -178,6 +178,10 @@ void Snapshot::setClip(float left, float top, float right, float bottom) { flags |= Snapshot::kFlagClipSet; } +bool Snapshot::hasPerspectiveTransform() const { + return transform->isPerspective(); +} + const Rect& Snapshot::getLocalClip() { mat4 inverse; inverse.loadInverse(*transform); diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h index a89b740..9c612ff 100644 --- a/libs/hwui/Snapshot.h +++ b/libs/hwui/Snapshot.h @@ -121,6 +121,11 @@ public: bool isIgnored() const; /** + * Indicates whether the current transform has perspective components. + */ + bool hasPerspectiveTransform() const; + + /** * Dirty flags. */ int flags; diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index 6e205b8..7bfa63d 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#define LOG_TAG "OpenGLRenderer" + #include <cutils/compiler.h> #include <SkUtils.h> |