diff options
author | John Reck <jreck@google.com> | 2017-11-03 10:12:19 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2017-11-03 10:57:44 -0700 |
commit | 1bcacfdcab0eaa0cee92bd7f5a1b5e271dd68e52 (patch) | |
tree | 4a1366cf2d1cf50b5ec4ed1a8cf0f437053cd0d7 /libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp | |
parent | 30ec71c0fe194a551d2e4abaff2159e0730488e0 (diff) |
Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
Diffstat (limited to 'libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp')
-rw-r--r-- | libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp b/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp index 9c9e17d600bf..8fb621d24866 100644 --- a/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp +++ b/libs/hwui/pipeline/skia/VectorDrawableAtlas.cpp @@ -19,9 +19,9 @@ #include <GrRectanizer_pow2.h> #include <SkCanvas.h> #include <cmath> -#include "utils/TraceUtils.h" #include "renderthread/RenderProxy.h" #include "renderthread/RenderThread.h" +#include "utils/TraceUtils.h" namespace android { namespace uirenderer { @@ -30,8 +30,7 @@ namespace skiapipeline { VectorDrawableAtlas::VectorDrawableAtlas(size_t surfaceArea, StorageMode storageMode) : mWidth((int)std::sqrt(surfaceArea)) , mHeight((int)std::sqrt(surfaceArea)) - , mStorageMode(storageMode) { -} + , mStorageMode(storageMode) {} void VectorDrawableAtlas::prepareForDraw(GrContext* context) { if (StorageMode::allowSharedSurface == mStorageMode) { @@ -55,8 +54,8 @@ void VectorDrawableAtlas::prepareForDraw(GrContext* context) { #define MAX_UNUSED_RATIO 2.0f bool VectorDrawableAtlas::isFragmented() { - return mConsecutiveFailures > MAX_CONSECUTIVE_FAILURES - && mPixelUsedByVDs*MAX_UNUSED_RATIO < mPixelAllocated; + return mConsecutiveFailures > MAX_CONSECUTIVE_FAILURES && + mPixelUsedByVDs * MAX_UNUSED_RATIO < mPixelAllocated; } void VectorDrawableAtlas::repackIfNeeded(GrContext* context) { @@ -69,9 +68,9 @@ void VectorDrawableAtlas::repackIfNeeded(GrContext* context) { } // compare to CacheEntry objects based on VD area. -bool VectorDrawableAtlas::compareCacheEntry(const CacheEntry& first, const CacheEntry& second) -{ - return first.VDrect.width()*first.VDrect.height() < second.VDrect.width()*second.VDrect.height(); +bool VectorDrawableAtlas::compareCacheEntry(const CacheEntry& first, const CacheEntry& second) { + return first.VDrect.width() * first.VDrect.height() < + second.VDrect.width() * second.VDrect.height(); } void VectorDrawableAtlas::repack(GrContext* context) { @@ -88,7 +87,7 @@ void VectorDrawableAtlas::repack(GrContext* context) { mRectanizer = std::make_unique<GrRectanizerPow2>(mWidth, mHeight); } else { if (!mSurface) { - return; //nothing to repack + return; // nothing to repack } mRectanizer.reset(); } @@ -106,20 +105,20 @@ void VectorDrawableAtlas::repack(GrContext* context) { for (CacheEntry& entry : mRects) { SkRect currentVDRect = entry.VDrect; - SkImage* sourceImage; //copy either from the atlas or from a standalone surface + SkImage* sourceImage; // copy either from the atlas or from a standalone surface if (entry.surface) { if (!fitInAtlas(currentVDRect.width(), currentVDRect.height())) { - continue; //don't even try to repack huge VD + continue; // don't even try to repack huge VD } sourceImage = entry.surface->makeImageSnapshot().get(); } else { sourceImage = sourceImageAtlas; } - size_t VDRectArea = currentVDRect.width()*currentVDRect.height(); + size_t VDRectArea = currentVDRect.width() * currentVDRect.height(); SkIPoint16 pos; if (canvas && mRectanizer->addRect(currentVDRect.width(), currentVDRect.height(), &pos)) { - SkRect newRect = SkRect::MakeXYWH(pos.fX, pos.fY, currentVDRect.width(), - currentVDRect.height()); + SkRect newRect = + SkRect::MakeXYWH(pos.fX, pos.fY, currentVDRect.width(), currentVDRect.height()); canvas->drawImageRect(sourceImage, currentVDRect, newRect, nullptr); entry.VDrect = newRect; entry.rect = newRect; @@ -134,8 +133,7 @@ void VectorDrawableAtlas::repack(GrContext* context) { if (!entry.surface) { // A rectangle moved from an atlas to a standalone surface. mPixelUsedByVDs -= VDRectArea; - SkRect newRect = SkRect::MakeWH(currentVDRect.width(), - currentVDRect.height()); + SkRect newRect = SkRect::MakeWH(currentVDRect.width(), currentVDRect.height()); entry.surface = createSurface(newRect.width(), newRect.height(), context); auto tempCanvas = entry.surface->getCanvas(); tempCanvas->clear(SK_ColorTRANSPARENT); @@ -158,7 +156,7 @@ AtlasEntry VectorDrawableAtlas::requestNewEntry(int width, int height, GrContext } if (mSurface) { - const size_t area = width*height; + const size_t area = width * height; // Use a rectanizer to allocate unused space from the atlas surface. bool notTooBig = fitInAtlas(width, height); @@ -243,10 +241,10 @@ void VectorDrawableAtlas::releaseEntry(AtlasKey atlasKey) { // Store freed atlas rectangles in "mFreeRects" and try to reuse them later, when atlas // is full. SkRect& removedRect = entry->rect; - size_t rectArea = removedRect.width()*removedRect.height(); + size_t rectArea = removedRect.width() * removedRect.height(); mFreeRects.emplace(rectArea, removedRect); SkRect& removedVDRect = entry->VDrect; - size_t VDRectArea = removedVDRect.width()*removedVDRect.height(); + size_t VDRectArea = removedVDRect.width() * removedVDRect.height(); mPixelUsedByVDs -= VDRectArea; mConsecutiveFailures = 0; } @@ -272,8 +270,8 @@ sk_sp<SkSurface> VectorDrawableAtlas::createSurface(int width, int height, GrCon SkImageInfo info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType, colorSpace); // This must have a top-left origin so that calls to surface->canvas->writePixels // performs a basic texture upload instead of a more complex drawing operation - return SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0, - kTopLeft_GrSurfaceOrigin, nullptr); + return SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0, kTopLeft_GrSurfaceOrigin, + nullptr); } void VectorDrawableAtlas::setStorageMode(StorageMode mode) { |