diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/FrameInfo.cpp | 1 | ||||
-rw-r--r-- | libs/hwui/FrameInfo.h | 26 | ||||
-rw-r--r-- | libs/hwui/FrameInfoVisualizer.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/FrameInfoVisualizer.h | 6 | ||||
-rw-r--r-- | libs/hwui/JankTracker.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Matrix.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/Matrix.h | 4 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/Patch.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/PathCache.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/Properties.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/TessellationCache.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/font/CacheTexture.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 2 | ||||
-rw-r--r-- | libs/hwui/renderthread/DrawFrameTask.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/renderthread/DrawFrameTask.h | 1 | ||||
-rw-r--r-- | libs/hwui/tests/main.cpp | 2 |
19 files changed, 65 insertions, 54 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 9664f58..35051b7 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -521,10 +521,10 @@ void FontRenderer::appendMeshQuad(float x1, float y1, float u1, float v1, appendMeshQuadNoClip(x1, y1, u1, v1, x2, y2, u2, v2, x3, y3, u3, v3, x4, y4, u4, v4, texture); if (mBounds) { - mBounds->left = fmin(mBounds->left, x1); - mBounds->top = fmin(mBounds->top, y3); - mBounds->right = fmax(mBounds->right, x3); - mBounds->bottom = fmax(mBounds->bottom, y1); + mBounds->left = std::min(mBounds->left, x1); + mBounds->top = std::min(mBounds->top, y3); + mBounds->right = std::max(mBounds->right, x3); + mBounds->bottom = std::max(mBounds->bottom, y1); } if (mCurrentCacheTexture->endOfMesh()) { @@ -539,10 +539,10 @@ void FontRenderer::appendRotatedMeshQuad(float x1, float y1, float u1, float v1, appendMeshQuadNoClip(x1, y1, u1, v1, x2, y2, u2, v2, x3, y3, u3, v3, x4, y4, u4, v4, texture); if (mBounds) { - mBounds->left = fmin(mBounds->left, fmin(x1, fmin(x2, fmin(x3, x4)))); - mBounds->top = fmin(mBounds->top, fmin(y1, fmin(y2, fmin(y3, y4)))); - mBounds->right = fmax(mBounds->right, fmax(x1, fmax(x2, fmax(x3, x4)))); - mBounds->bottom = fmax(mBounds->bottom, fmax(y1, fmax(y2, fmax(y3, y4)))); + mBounds->left = std::min(mBounds->left, std::min(x1, std::min(x2, std::min(x3, x4)))); + mBounds->top = std::min(mBounds->top, std::min(y1, std::min(y2, std::min(y3, y4)))); + mBounds->right = std::max(mBounds->right, std::max(x1, std::max(x2, std::max(x3, x4)))); + mBounds->bottom = std::max(mBounds->bottom, std::max(y1, std::max(y2, std::max(y3, y4)))); } if (mCurrentCacheTexture->endOfMesh()) { diff --git a/libs/hwui/FrameInfo.cpp b/libs/hwui/FrameInfo.cpp index 85998f1..41e2233 100644 --- a/libs/hwui/FrameInfo.cpp +++ b/libs/hwui/FrameInfo.cpp @@ -30,6 +30,7 @@ const std::string FrameInfoNames[] = { "AnimationStart", "PerformTraversalsStart", "DrawStart", + "SyncQueued", "SyncStart", "IssueDrawCommandsStart", "SwapBuffers", diff --git a/libs/hwui/FrameInfo.h b/libs/hwui/FrameInfo.h index 23339ce..f8013ab 100644 --- a/libs/hwui/FrameInfo.h +++ b/libs/hwui/FrameInfo.h @@ -41,6 +41,8 @@ enum class FrameInfoIndex { DrawStart, // End of UI frame info + SyncQueued, + SyncStart, IssueDrawCommandsStart, SwapBuffers, @@ -117,8 +119,7 @@ public: } inline int64_t operator[](FrameInfoIndex index) const { - if (index == FrameInfoIndex::NumIndexes) return 0; - return mFrameInfo[static_cast<int>(index)]; + return get(index); } inline int64_t operator[](int index) const { @@ -127,10 +128,20 @@ public: } inline int64_t duration(FrameInfoIndex start, FrameInfoIndex end) const { - int64_t endtime = mFrameInfo[static_cast<int>(end)]; - int64_t starttime = mFrameInfo[static_cast<int>(start)]; + int64_t endtime = get(end); + int64_t starttime = get(start); int64_t gap = endtime - starttime; gap = starttime > 0 ? gap : 0; + if (end > FrameInfoIndex::SyncQueued && + start < FrameInfoIndex::SyncQueued) { + // Need to subtract out the time spent in a stalled state + // as this will be captured by the previous frame's info + int64_t offset = get(FrameInfoIndex::SyncStart) + - get(FrameInfoIndex::SyncQueued); + if (offset > 0) { + gap -= offset; + } + } return gap > 0 ? gap : 0; } @@ -138,11 +149,16 @@ public: return duration(FrameInfoIndex::IntendedVsync, FrameInfoIndex::FrameCompleted); } -private: inline int64_t& set(FrameInfoIndex index) { return mFrameInfo[static_cast<int>(index)]; } + inline int64_t get(FrameInfoIndex index) const { + if (index == FrameInfoIndex::NumIndexes) return 0; + return mFrameInfo[static_cast<int>(index)]; + } + +private: int64_t mFrameInfo[static_cast<int>(FrameInfoIndex::NumIndexes)]; }; diff --git a/libs/hwui/FrameInfoVisualizer.cpp b/libs/hwui/FrameInfoVisualizer.cpp index 7f9d9b9..b416615 100644 --- a/libs/hwui/FrameInfoVisualizer.cpp +++ b/libs/hwui/FrameInfoVisualizer.cpp @@ -189,7 +189,7 @@ void FrameInfoVisualizer::nextBarSegment(FrameInfoIndex start, FrameInfoIndex en // Set the bottom to the old top (build upwards) rect[ri + 3] = rect[ri + 1]; // Move the top up by the duration - rect[ri + 1] -= mVerticalUnit * duration(fi, start, end); + rect[ri + 1] -= mVerticalUnit * durationMS(fi, start, end); } } @@ -253,10 +253,10 @@ void FrameInfoVisualizer::dumpData(int fd) { } mLastFrameLogged = mFrameSource[i][FrameInfoIndex::IntendedVsync]; fprintf(file, "\t%3.2f\t%3.2f\t%3.2f\t%3.2f\n", - duration(i, FrameInfoIndex::IntendedVsync, FrameInfoIndex::SyncStart), - duration(i, FrameInfoIndex::SyncStart, FrameInfoIndex::IssueDrawCommandsStart), - duration(i, FrameInfoIndex::IssueDrawCommandsStart, FrameInfoIndex::SwapBuffers), - duration(i, FrameInfoIndex::SwapBuffers, FrameInfoIndex::FrameCompleted)); + durationMS(i, FrameInfoIndex::IntendedVsync, FrameInfoIndex::SyncStart), + durationMS(i, FrameInfoIndex::SyncStart, FrameInfoIndex::IssueDrawCommandsStart), + durationMS(i, FrameInfoIndex::IssueDrawCommandsStart, FrameInfoIndex::SwapBuffers), + durationMS(i, FrameInfoIndex::SwapBuffers, FrameInfoIndex::FrameCompleted)); } fflush(file); diff --git a/libs/hwui/FrameInfoVisualizer.h b/libs/hwui/FrameInfoVisualizer.h index f1dc954..cf877c4 100644 --- a/libs/hwui/FrameInfoVisualizer.h +++ b/libs/hwui/FrameInfoVisualizer.h @@ -59,10 +59,8 @@ private: void drawGraph(OpenGLRenderer* canvas); void drawThreshold(OpenGLRenderer* canvas); - inline float duration(size_t index, FrameInfoIndex start, FrameInfoIndex end) { - nsecs_t ns_start = mFrameSource[index][start]; - nsecs_t ns_end = mFrameSource[index][end]; - float duration = ((ns_end - ns_start) * 0.000001f); + inline float durationMS(size_t index, FrameInfoIndex start, FrameInfoIndex end) { + float duration = mFrameSource[index].duration(start, end) * 0.000001f; // Clamp to large to avoid spiking off the top of the screen duration = duration > 50.0f ? 50.0f : duration; return duration > 0.0f ? duration : 0.0f; diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp index 5c0801e..eb9b55f 100644 --- a/libs/hwui/JankTracker.cpp +++ b/libs/hwui/JankTracker.cpp @@ -31,7 +31,7 @@ static const char* JANK_TYPE_NAMES[] = { "High input latency", "Slow UI thread", "Slow bitmap uploads", - "Slow draw", + "Slow issue draw commands", }; struct Comparison { @@ -223,7 +223,7 @@ void JankTracker::addFrame(const FrameInfo& frame) { mData->jankFrameCount++; for (int i = 0; i < NUM_BUCKETS; i++) { - int64_t delta = frame[COMPARISONS[i].end] - frame[COMPARISONS[i].start]; + int64_t delta = frame.duration(COMPARISONS[i].start, COMPARISONS[i].end); if (delta >= mThresholds[i] && delta < IGNORE_EXCEEDING) { mData->jankTypeCounts[i]++; } diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index 061d26a..06e67c0 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -155,8 +155,7 @@ void Matrix4::load(const float* v) { } void Matrix4::load(const Matrix4& v) { - memcpy(data, v.data, sizeof(data)); - mType = v.getType(); + *this = v; } void Matrix4::load(const SkMatrix& v) { diff --git a/libs/hwui/Matrix.h b/libs/hwui/Matrix.h index c152789..ed54a25 100644 --- a/libs/hwui/Matrix.h +++ b/libs/hwui/Matrix.h @@ -85,10 +85,6 @@ public: load(v); } - Matrix4(const Matrix4& v) { - load(v); - } - Matrix4(const SkMatrix& v) { load(v); } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 87ed84f..ed2a4db 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1670,10 +1670,10 @@ void OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, Rect src, Rect dst, cons if (!texture) return; const AutoTexture autoCleanup(texture); - Rect uv(fmax(0.0f, src.left / texture->width), - fmax(0.0f, src.top / texture->height), - fmin(1.0f, src.right / texture->width), - fmin(1.0f, src.bottom / texture->height)); + Rect uv(std::max(0.0f, src.left / texture->width), + std::max(0.0f, src.top / texture->height), + std::min(1.0f, src.right / texture->width), + std::min(1.0f, src.bottom / texture->height)); const int textureFillFlags = (bitmap->colorType() == kAlpha_8_SkColorType) ? TextureFillFlags::IsAlphaMaskTexture : TextureFillFlags::None; @@ -2450,7 +2450,7 @@ void OpenGLRenderer::drawTextDecorations(float underlineWidth, float x, float y, if (CC_LIKELY(underlineWidth > 0.0f)) { const float textSize = paintCopy.getTextSize(); - const float strokeWidth = fmax(textSize * kStdUnderline_Thickness, 1.0f); + const float strokeWidth = std::max(textSize * kStdUnderline_Thickness, 1.0f); const float left = x; float top = 0.0f; diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index f4dd943..6a7dfb3 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -119,7 +119,7 @@ Patch::Patch(const float bitmapWidth, const float bitmapHeight, } float vOffset = y1 == y2 ? 0.0f : 0.5 - (0.5 * segment / (y2 - y1)); - float v2 = fmax(0.0f, stepY - vOffset) / bitmapHeight; + float v2 = std::max(0.0f, stepY - vOffset) / bitmapHeight; v1 += vOffset / bitmapHeight; if (stepY > 0.0f) { @@ -167,7 +167,7 @@ void Patch::generateRow(const int32_t* xDivs, uint32_t xCount, TextureVertex*& v } float uOffset = x1 == x2 ? 0.0f : 0.5 - (0.5 * segment / (x2 - x1)); - float u2 = fmax(0.0f, stepX - uOffset) / bitmapWidth; + float u2 = std::max(0.0f, stepX - uOffset) / bitmapWidth; u1 += uOffset / bitmapWidth; if (stepX > 0.0f) { diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index e466604..3af640f 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -91,13 +91,13 @@ void PathCache::computePathBounds(const SkPath* path, const SkPaint* paint, void PathCache::computeBounds(const SkRect& bounds, const SkPaint* paint, float& left, float& top, float& offset, uint32_t& width, uint32_t& height) { - const float pathWidth = fmax(bounds.width(), 1.0f); - const float pathHeight = fmax(bounds.height(), 1.0f); + const float pathWidth = std::max(bounds.width(), 1.0f); + const float pathHeight = std::max(bounds.height(), 1.0f); left = bounds.fLeft; top = bounds.fTop; - offset = (int) floorf(fmax(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f); + offset = (int) floorf(std::max(paint->getStrokeWidth(), 1.0f) * 1.5f + 0.5f); width = uint32_t(pathWidth + offset * 2.0 + 0.5); height = uint32_t(pathHeight + offset * 2.0 + 0.5); diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp index 7dbe3b7..2e63793 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -17,7 +17,7 @@ #include "Debug.h" -#include <cmath> +#include <algorithm> #include <cutils/log.h> namespace android { @@ -117,19 +117,19 @@ void Properties::overrideProperty(const char* name, const char* value) { ALOGD("profile bars %s", sDisableProfileBars ? "disabled" : "enabled"); return; } else if (!strcmp(name, "ambientRatio")) { - overrideAmbientRatio = fmin(fmax(atof(value), 0.0), 10.0); + overrideAmbientRatio = std::min(std::max(atof(value), 0.0), 10.0); ALOGD("ambientRatio = %.2f", overrideAmbientRatio); return; } else if (!strcmp(name, "lightRadius")) { - overrideLightRadius = fmin(fmax(atof(value), 0.0), 3000.0); + overrideLightRadius = std::min(std::max(atof(value), 0.0), 3000.0); ALOGD("lightRadius = %.2f", overrideLightRadius); return; } else if (!strcmp(name, "lightPosY")) { - overrideLightPosY = fmin(fmax(atof(value), 0.0), 3000.0); + overrideLightPosY = std::min(std::max(atof(value), 0.0), 3000.0); ALOGD("lightPos Y = %.2f", overrideLightPosY); return; } else if (!strcmp(name, "lightPosZ")) { - overrideLightPosZ = fmin(fmax(atof(value), 0.0), 3000.0); + overrideLightPosZ = std::min(std::max(atof(value), 0.0), 3000.0); ALOGD("lightPos Z = %.2f", overrideLightPosZ); return; } else if (!strcmp(name, "ambientShadowStrength")) { diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp index 9df1f0d..17cb3a7 100644 --- a/libs/hwui/TessellationCache.cpp +++ b/libs/hwui/TessellationCache.cpp @@ -244,8 +244,8 @@ static void tessellateShadows( const Vertex& point2d = casterVertices2d[i]; casterPolygon[i] = (Vector3){point2d.x, point2d.y, 0}; mapPointFakeZ(casterPolygon[i], casterTransformXY, casterTransformZ); - minZ = fmin(minZ, casterPolygon[i].z); - maxZ = fmax(maxZ, casterPolygon[i].z); + minZ = std::min(minZ, casterPolygon[i].z); + maxZ = std::max(maxZ, casterPolygon[i].z); } // map the centroid of the caster into 3d diff --git a/libs/hwui/font/CacheTexture.cpp b/libs/hwui/font/CacheTexture.cpp index 845cf30..d2685da 100644 --- a/libs/hwui/font/CacheTexture.cpp +++ b/libs/hwui/font/CacheTexture.cpp @@ -314,7 +314,7 @@ bool CacheTexture::fitBitmap(const SkGlyph& glyph, uint32_t* retOriginX, uint32_ #endif } - if (cacheBlock->mHeight < fmin(glyphH, glyphW)) { + if (cacheBlock->mHeight < std::min(glyphH, glyphW)) { // If remaining space in this block is too small to be useful, remove it mCacheBlocks = CacheBlock::removeBlock(mCacheBlocks, cacheBlock); } diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index b88f30e..260fb6f 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -160,7 +160,7 @@ static bool wasSkipped(FrameInfo* info) { return info && ((*info)[FrameInfoIndex::Flags] & FrameInfoFlags::SkippedFrame); } -void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo) { +void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t syncQueued) { mRenderThread.removeFrameCallback(this); // If the previous frame was dropped we don't need to hold onto it, so @@ -169,6 +169,7 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo) { mCurrentFrameInfo = &mFrames.next(); } mCurrentFrameInfo->importUiThreadInfo(uiFrameInfo); + mCurrentFrameInfo->set(FrameInfoIndex::SyncQueued) = syncQueued; mCurrentFrameInfo->markSyncStart(); info.damageAccumulator = &mDamageAccumulator; @@ -293,7 +294,7 @@ void CanvasContext::doFrame() { mRenderThread.timeLord().latestVsync()); TreeInfo info(TreeInfo::MODE_RT_ONLY, mRenderThread.renderState()); - prepareTree(info, frameInfo); + prepareTree(info, frameInfo, systemTime(CLOCK_MONOTONIC)); if (info.out.canDrawThisFrame) { draw(); } diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index 10e66e9..f2fa9cd 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -78,7 +78,7 @@ public: void setOpaque(bool opaque); void makeCurrent(); void processLayerUpdate(DeferredLayerUpdater* layerUpdater); - void prepareTree(TreeInfo& info, int64_t* uiFrameInfo); + void prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t syncQueued); void draw(); void destroy(); diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp index 008e297..6507ce8 100644 --- a/libs/hwui/renderthread/DrawFrameTask.cpp +++ b/libs/hwui/renderthread/DrawFrameTask.cpp @@ -69,6 +69,7 @@ int DrawFrameTask::drawFrame() { LOG_ALWAYS_FATAL_IF(!mContext, "Cannot drawFrame with no CanvasContext!"); mSyncResult = kSync_OK; + mSyncQueued = systemTime(CLOCK_MONOTONIC); postAndWait(); return mSyncResult; @@ -119,7 +120,7 @@ bool DrawFrameTask::syncFrameState(TreeInfo& info) { mContext->processLayerUpdate(mLayers[i].get()); } mLayers.clear(); - mContext->prepareTree(info, mFrameInfo); + mContext->prepareTree(info, mFrameInfo, mSyncQueued); // This is after the prepareTree so that any pending operations // (RenderNode tree state, prefetched layers, etc...) will be flushed. diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h index 8039643..ebefcba 100644 --- a/libs/hwui/renderthread/DrawFrameTask.h +++ b/libs/hwui/renderthread/DrawFrameTask.h @@ -85,6 +85,7 @@ private: std::vector< sp<DeferredLayerUpdater> > mLayers; int mSyncResult; + int64_t mSyncQueued; int64_t mFrameInfo[UI_THREAD_FRAME_INFO_SIZE]; }; diff --git a/libs/hwui/tests/main.cpp b/libs/hwui/tests/main.cpp index ceee953..80d7029 100644 --- a/libs/hwui/tests/main.cpp +++ b/libs/hwui/tests/main.cpp @@ -111,8 +111,6 @@ public: for (int i = 0; i < animation.getFrameCount(); i++) { testContext.waitForVsync(); - // workaround b/20853441 - proxy->fence(); ATRACE_NAME("UI-Draw Frame"); nsecs_t vsync = systemTime(CLOCK_MONOTONIC); UiFrameInfoBuilder(proxy->frameInfo()) |