Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
diff --git a/libs/hwui/utils/Blur.cpp b/libs/hwui/utils/Blur.cpp
index 9b70765..1bc5646 100644
--- a/libs/hwui/utils/Blur.cpp
+++ b/libs/hwui/utils/Blur.cpp
@@ -38,7 +38,7 @@
// is within the conversion error tolerance then we attempt to snap to the
// original integer boundary.
uint32_t Blur::convertRadiusToInt(float radius) {
- const float radiusCeil = ceilf(radius);
+ const float radiusCeil = ceilf(radius);
if (MathUtils::areEqual(radiusCeil, radius)) {
return radiusCeil;
}
@@ -75,46 +75,45 @@
// the blur calculations
// precompute some values
float coeff1 = 1.0f / (sqrt(2.0f * pi) * sigma);
- float coeff2 = - 1.0f / (2.0f * sigma * sigma);
+ float coeff2 = -1.0f / (2.0f * sigma * sigma);
float normalizeFactor = 0.0f;
- for (int32_t r = -intRadius; r <= intRadius; r ++) {
- float floatR = (float) r;
+ for (int32_t r = -intRadius; r <= intRadius; r++) {
+ float floatR = (float)r;
weights[r + intRadius] = coeff1 * pow(e, floatR * floatR * coeff2);
normalizeFactor += weights[r + intRadius];
}
- //Now we need to normalize the weights because all our coefficients need to add up to one
+ // Now we need to normalize the weights because all our coefficients need to add up to one
normalizeFactor = 1.0f / normalizeFactor;
- for (int32_t r = -intRadius; r <= intRadius; r ++) {
+ for (int32_t r = -intRadius; r <= intRadius; r++) {
weights[r + intRadius] *= normalizeFactor;
}
}
-void Blur::horizontal(float* weights, int32_t radius,
- const uint8_t* source, uint8_t* dest, int32_t width, int32_t height) {
+void Blur::horizontal(float* weights, int32_t radius, const uint8_t* source, uint8_t* dest,
+ int32_t width, int32_t height) {
float blurredPixel = 0.0f;
float currentPixel = 0.0f;
- for (int32_t y = 0; y < height; y ++) {
-
+ for (int32_t y = 0; y < height; y++) {
const uint8_t* input = source + y * width;
uint8_t* output = dest + y * width;
- for (int32_t x = 0; x < width; x ++) {
+ for (int32_t x = 0; x < width; x++) {
blurredPixel = 0.0f;
const float* gPtr = weights;
// Optimization for non-border pixels
if (x > radius && x < (width - radius)) {
- const uint8_t *i = input + (x - radius);
- for (int r = -radius; r <= radius; r ++) {
- currentPixel = (float) (*i);
+ const uint8_t* i = input + (x - radius);
+ for (int r = -radius; r <= radius; r++) {
+ currentPixel = (float)(*i);
blurredPixel += currentPixel * gPtr[0];
gPtr++;
i++;
}
} else {
- for (int32_t r = -radius; r <= radius; r ++) {
+ for (int32_t r = -radius; r <= radius; r++) {
// Stepping left and right away from the pixel
int validW = x + r;
if (validW < 0) {
@@ -124,40 +123,40 @@
validW = width - 1;
}
- currentPixel = (float) input[validW];
+ currentPixel = (float)input[validW];
blurredPixel += currentPixel * gPtr[0];
gPtr++;
}
}
*output = (uint8_t)blurredPixel;
- output ++;
+ output++;
}
}
}
-void Blur::vertical(float* weights, int32_t radius,
- const uint8_t* source, uint8_t* dest, int32_t width, int32_t height) {
+void Blur::vertical(float* weights, int32_t radius, const uint8_t* source, uint8_t* dest,
+ int32_t width, int32_t height) {
float blurredPixel = 0.0f;
float currentPixel = 0.0f;
- for (int32_t y = 0; y < height; y ++) {
+ for (int32_t y = 0; y < height; y++) {
uint8_t* output = dest + y * width;
- for (int32_t x = 0; x < width; x ++) {
+ for (int32_t x = 0; x < width; x++) {
blurredPixel = 0.0f;
const float* gPtr = weights;
const uint8_t* input = source + x;
// Optimization for non-border pixels
if (y > radius && y < (height - radius)) {
- const uint8_t *i = input + ((y - radius) * width);
- for (int32_t r = -radius; r <= radius; r ++) {
- currentPixel = (float) (*i);
+ const uint8_t* i = input + ((y - radius) * width);
+ for (int32_t r = -radius; r <= radius; r++) {
+ currentPixel = (float)(*i);
blurredPixel += currentPixel * gPtr[0];
gPtr++;
i += width;
}
} else {
- for (int32_t r = -radius; r <= radius; r ++) {
+ for (int32_t r = -radius; r <= radius; r++) {
int validH = y + r;
// Clamp to zero and width
if (validH < 0) {
@@ -167,17 +166,17 @@
validH = height - 1;
}
- const uint8_t *i = input + validH * width;
- currentPixel = (float) (*i);
+ const uint8_t* i = input + validH * width;
+ currentPixel = (float)(*i);
blurredPixel += currentPixel * gPtr[0];
gPtr++;
}
}
- *output = (uint8_t) blurredPixel;
+ *output = (uint8_t)blurredPixel;
output++;
}
}
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/utils/Blur.h b/libs/hwui/utils/Blur.h
index 3f21832..bec3837 100644
--- a/libs/hwui/utils/Blur.h
+++ b/libs/hwui/utils/Blur.h
@@ -17,8 +17,8 @@
#ifndef ANDROID_HWUI_BLUR_H
#define ANDROID_HWUI_BLUR_H
-#include <stdint.h>
#include <cutils/compiler.h>
+#include <stdint.h>
namespace android {
namespace uirenderer {
@@ -35,13 +35,13 @@
static uint32_t convertRadiusToInt(float radius);
static void generateGaussianWeights(float* weights, float radius);
- static void horizontal(float* weights, int32_t radius, const uint8_t* source,
- uint8_t* dest, int32_t width, int32_t height);
- static void vertical(float* weights, int32_t radius, const uint8_t* source,
- uint8_t* dest, int32_t width, int32_t height);
+ static void horizontal(float* weights, int32_t radius, const uint8_t* source, uint8_t* dest,
+ int32_t width, int32_t height);
+ static void vertical(float* weights, int32_t radius, const uint8_t* source, uint8_t* dest,
+ int32_t width, int32_t height);
};
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
-#endif // ANDROID_HWUI_BLUR_H
+#endif // ANDROID_HWUI_BLUR_H
diff --git a/libs/hwui/utils/Color.cpp b/libs/hwui/utils/Color.cpp
index 7d234b0..c2af867 100644
--- a/libs/hwui/utils/Color.cpp
+++ b/libs/hwui/utils/Color.cpp
@@ -41,18 +41,17 @@
const float sRGBParamG = 2.4f;
// This comparison will catch Display P3
- return
- almostEqual(sRGBParamA, transferFunction.fA)
- && almostEqual(sRGBParamB, transferFunction.fB)
- && almostEqual(sRGBParamC, transferFunction.fC)
- && almostEqual(sRGBParamD, transferFunction.fD)
- && almostEqual(sRGBParamE, transferFunction.fE)
- && almostEqual(sRGBParamF, transferFunction.fF)
- && almostEqual(sRGBParamG, transferFunction.fG);
+ return almostEqual(sRGBParamA, transferFunction.fA) &&
+ almostEqual(sRGBParamB, transferFunction.fB) &&
+ almostEqual(sRGBParamC, transferFunction.fC) &&
+ almostEqual(sRGBParamD, transferFunction.fD) &&
+ almostEqual(sRGBParamE, transferFunction.fE) &&
+ almostEqual(sRGBParamF, transferFunction.fF) &&
+ almostEqual(sRGBParamG, transferFunction.fG);
}
return false;
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/utils/Color.h b/libs/hwui/utils/Color.h
index 9c09660..4857a87 100644
--- a/libs/hwui/utils/Color.h
+++ b/libs/hwui/utils/Color.h
@@ -23,114 +23,94 @@
namespace android {
namespace uirenderer {
- namespace Color {
- enum Color {
- Red_500 = 0xFFF44336,
- Pink_500 = 0xFFE91E63,
- Purple_500 = 0xFF9C27B0,
- DeepPurple_500 = 0xFF673AB7,
- Indigo_500 = 0xFF3F51B5,
- Blue_500 = 0xFF2196F3,
- LightBlue_300 = 0xFF4FC3F7,
- LightBlue_500 = 0xFF03A9F4,
- Cyan_500 = 0xFF00BCD4,
- Teal_500 = 0xFF009688,
- Teal_700 = 0xFF00796B,
- Green_500 = 0xFF4CAF50,
- Green_700 = 0xFF388E3C,
- LightGreen_500 = 0xFF8BC34A,
- LightGreen_700 = 0xFF689F38,
- Lime_500 = 0xFFCDDC39,
- Yellow_500 = 0xFFFFEB3B,
- Amber_500 = 0xFFFFC107,
- Orange_500 = 0xFFFF9800,
- DeepOrange_500 = 0xFFFF5722,
- Brown_500 = 0xFF795548,
- Grey_200 = 0xFFEEEEEE,
- Grey_500 = 0xFF9E9E9E,
- Grey_700 = 0xFF616161,
- BlueGrey_500 = 0xFF607D8B,
- Transparent = 0x00000000,
- Black = 0xFF000000,
- White = 0xFFFFFFFF,
- };
- }
+namespace Color {
+enum Color {
+ Red_500 = 0xFFF44336,
+ Pink_500 = 0xFFE91E63,
+ Purple_500 = 0xFF9C27B0,
+ DeepPurple_500 = 0xFF673AB7,
+ Indigo_500 = 0xFF3F51B5,
+ Blue_500 = 0xFF2196F3,
+ LightBlue_300 = 0xFF4FC3F7,
+ LightBlue_500 = 0xFF03A9F4,
+ Cyan_500 = 0xFF00BCD4,
+ Teal_500 = 0xFF009688,
+ Teal_700 = 0xFF00796B,
+ Green_500 = 0xFF4CAF50,
+ Green_700 = 0xFF388E3C,
+ LightGreen_500 = 0xFF8BC34A,
+ LightGreen_700 = 0xFF689F38,
+ Lime_500 = 0xFFCDDC39,
+ Yellow_500 = 0xFFFFEB3B,
+ Amber_500 = 0xFFFFC107,
+ Orange_500 = 0xFFFF9800,
+ DeepOrange_500 = 0xFFFF5722,
+ Brown_500 = 0xFF795548,
+ Grey_200 = 0xFFEEEEEE,
+ Grey_500 = 0xFF9E9E9E,
+ Grey_700 = 0xFF616161,
+ BlueGrey_500 = 0xFF607D8B,
+ Transparent = 0x00000000,
+ Black = 0xFF000000,
+ White = 0xFFFFFFFF,
+};
+}
- static_assert(Color::White == SK_ColorWHITE, "color format has changed");
- static_assert(Color::Black == SK_ColorBLACK, "color format has changed");
+static_assert(Color::White == SK_ColorWHITE, "color format has changed");
+static_assert(Color::Black == SK_ColorBLACK, "color format has changed");
- // Array of bright (500 intensity) colors for synthetic content
- static const Color::Color BrightColors[] = {
- Color::Red_500,
- Color::Pink_500,
- Color::Purple_500,
- Color::DeepPurple_500,
- Color::Indigo_500,
- Color::Blue_500,
- Color::LightBlue_500,
- Color::Cyan_500,
- Color::Teal_500,
- Color::Green_500,
- Color::LightGreen_500,
- Color::Lime_500,
- Color::Yellow_500,
- Color::Amber_500,
- Color::Orange_500,
- Color::DeepOrange_500,
- Color::Brown_500,
- Color::Grey_500,
- Color::BlueGrey_500,
- };
- static constexpr int BrightColorsCount = sizeof(BrightColors) / sizeof(Color::Color);
+// Array of bright (500 intensity) colors for synthetic content
+static const Color::Color BrightColors[] = {
+ Color::Red_500, Color::Pink_500, Color::Purple_500, Color::DeepPurple_500,
+ Color::Indigo_500, Color::Blue_500, Color::LightBlue_500, Color::Cyan_500,
+ Color::Teal_500, Color::Green_500, Color::LightGreen_500, Color::Lime_500,
+ Color::Yellow_500, Color::Amber_500, Color::Orange_500, Color::DeepOrange_500,
+ Color::Brown_500, Color::Grey_500, Color::BlueGrey_500,
+};
+static constexpr int BrightColorsCount = sizeof(BrightColors) / sizeof(Color::Color);
- enum class TransferFunctionType : int8_t {
- None = 0,
- Full,
- Limited,
- Gamma
- };
+enum class TransferFunctionType : int8_t { None = 0, Full, Limited, Gamma };
- // Opto-electronic conversion function for the sRGB color space
- // Takes a linear sRGB value and converts it to a gamma-encoded sRGB value
- static constexpr float OECF_sRGB(float linear) {
- // IEC 61966-2-1:1999
- return linear <= 0.0031308f ?
- linear * 12.92f : (powf(linear, 1.0f / 2.4f) * 1.055f) - 0.055f;
- }
+// Opto-electronic conversion function for the sRGB color space
+// Takes a linear sRGB value and converts it to a gamma-encoded sRGB value
+static constexpr float OECF_sRGB(float linear) {
+ // IEC 61966-2-1:1999
+ return linear <= 0.0031308f ? linear * 12.92f : (powf(linear, 1.0f / 2.4f) * 1.055f) - 0.055f;
+}
- // Opto-electronic conversion function for the sRGB color space
- // Takes a linear sRGB value and converts it to a gamma-encoded sRGB value
- // This function returns the input unmodified if linear blending is not enabled
- static constexpr float OECF(float linear) {
+// Opto-electronic conversion function for the sRGB color space
+// Takes a linear sRGB value and converts it to a gamma-encoded sRGB value
+// This function returns the input unmodified if linear blending is not enabled
+static constexpr float OECF(float linear) {
#ifdef ANDROID_ENABLE_LINEAR_BLENDING
- return OECF_sRGB(linear);
+ return OECF_sRGB(linear);
#else
- return linear;
+ return linear;
#endif
- }
+}
- // Electro-optical conversion function for the sRGB color space
- // Takes a gamma-encoded sRGB value and converts it to a linear sRGB value
- static constexpr float EOCF_sRGB(float srgb) {
- // IEC 61966-2-1:1999
- return srgb <= 0.04045f ? srgb / 12.92f : powf((srgb + 0.055f) / 1.055f, 2.4f);
- }
+// Electro-optical conversion function for the sRGB color space
+// Takes a gamma-encoded sRGB value and converts it to a linear sRGB value
+static constexpr float EOCF_sRGB(float srgb) {
+ // IEC 61966-2-1:1999
+ return srgb <= 0.04045f ? srgb / 12.92f : powf((srgb + 0.055f) / 1.055f, 2.4f);
+}
- // Electro-optical conversion function for the sRGB color space
- // Takes a gamma-encoded sRGB value and converts it to a linear sRGB value
- // This function returns the input unmodified if linear blending is not enabled
- static constexpr float EOCF(float srgb) {
+// Electro-optical conversion function for the sRGB color space
+// Takes a gamma-encoded sRGB value and converts it to a linear sRGB value
+// This function returns the input unmodified if linear blending is not enabled
+static constexpr float EOCF(float srgb) {
#ifdef ANDROID_ENABLE_LINEAR_BLENDING
- return EOCF_sRGB(srgb);
+ return EOCF_sRGB(srgb);
#else
- return srgb;
+ return srgb;
#endif
- }
+}
- // Returns whether the specified color space's transfer function can be
- // approximated with the native sRGB transfer function. This method
- // returns true for sRGB, gamma 2.2 and Display P3 for instance
- bool transferFunctionCloseToSRGB(const SkColorSpace* colorSpace);
+// Returns whether the specified color space's transfer function can be
+// approximated with the native sRGB transfer function. This method
+// returns true for sRGB, gamma 2.2 and Display P3 for instance
+bool transferFunctionCloseToSRGB(const SkColorSpace* colorSpace);
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/utils/FatVector.h b/libs/hwui/utils/FatVector.h
index df8cb076..eafe2f1 100644
--- a/libs/hwui/utils/FatVector.h
+++ b/libs/hwui/utils/FatVector.h
@@ -30,8 +30,8 @@
#include <stddef.h>
#include <stdlib.h>
-#include <type_traits>
#include <utils/Log.h>
+#include <type_traits>
#include <vector>
@@ -43,28 +43,27 @@
public:
struct Allocation {
PREVENT_COPY_AND_ASSIGN(Allocation);
+
public:
- Allocation() {};
+ Allocation(){};
// char array instead of T array, so memory is uninitialized, with no destructors run
char array[sizeof(T) * SIZE];
bool inUse = false;
};
- typedef T value_type; // needed to implement std::allocator
- typedef T* pointer; // needed to implement std::allocator
+ typedef T value_type; // needed to implement std::allocator
+ typedef T* pointer; // needed to implement std::allocator
- explicit InlineStdAllocator(Allocation& allocation)
- : mAllocation(allocation) {}
- InlineStdAllocator(const InlineStdAllocator& other)
- : mAllocation(other.mAllocation) {}
+ explicit InlineStdAllocator(Allocation& allocation) : mAllocation(allocation) {}
+ InlineStdAllocator(const InlineStdAllocator& other) : mAllocation(other.mAllocation) {}
~InlineStdAllocator() {}
T* allocate(size_t num, const void* = 0) {
if (!mAllocation.inUse && num <= SIZE) {
mAllocation.inUse = true;
- return (T*) mAllocation.array;
+ return (T*)mAllocation.array;
} else {
- return (T*) malloc(num * sizeof(T));
+ return (T*)malloc(num * sizeof(T));
}
}
@@ -88,20 +87,19 @@
template <typename T, size_t SIZE>
class FatVector : public std::vector<T, InlineStdAllocator<T, SIZE>> {
public:
- FatVector() : std::vector<T, InlineStdAllocator<T, SIZE>>(
- InlineStdAllocator<T, SIZE>(mAllocation)) {
+ FatVector()
+ : std::vector<T, InlineStdAllocator<T, SIZE>>(
+ InlineStdAllocator<T, SIZE>(mAllocation)) {
this->reserve(SIZE);
}
- explicit FatVector(size_t capacity) : FatVector() {
- this->resize(capacity);
- }
+ explicit FatVector(size_t capacity) : FatVector() { this->resize(capacity); }
private:
typename InlineStdAllocator<T, SIZE>::Allocation mAllocation;
};
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
-#endif // ANDROID_FAT_VECTOR_H
+#endif // ANDROID_FAT_VECTOR_H
diff --git a/libs/hwui/utils/GLUtils.cpp b/libs/hwui/utils/GLUtils.cpp
index 33209759..bf27300 100644
--- a/libs/hwui/utils/GLUtils.cpp
+++ b/libs/hwui/utils/GLUtils.cpp
@@ -39,25 +39,25 @@
while ((status = glGetError()) != GL_NO_ERROR) {
errorObserved = true;
switch (status) {
- case GL_INVALID_ENUM:
- ALOGE("GL error: GL_INVALID_ENUM");
- break;
- case GL_INVALID_VALUE:
- ALOGE("GL error: GL_INVALID_VALUE");
- break;
- case GL_INVALID_OPERATION:
- ALOGE("GL error: GL_INVALID_OPERATION");
- break;
- case GL_OUT_OF_MEMORY:
- ALOGE("GL error: Out of memory!");
- break;
- default:
- ALOGE("GL error: 0x%x", status);
+ case GL_INVALID_ENUM:
+ ALOGE("GL error: GL_INVALID_ENUM");
+ break;
+ case GL_INVALID_VALUE:
+ ALOGE("GL error: GL_INVALID_VALUE");
+ break;
+ case GL_INVALID_OPERATION:
+ ALOGE("GL error: GL_INVALID_OPERATION");
+ break;
+ case GL_OUT_OF_MEMORY:
+ ALOGE("GL error: Out of memory!");
+ break;
+ default:
+ ALOGE("GL error: 0x%x", status);
}
}
return errorObserved;
#endif
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/utils/GLUtils.h b/libs/hwui/utils/GLUtils.h
index c127478..debfb5d 100644
--- a/libs/hwui/utils/GLUtils.h
+++ b/libs/hwui/utils/GLUtils.h
@@ -23,13 +23,14 @@
namespace android {
namespace uirenderer {
-
#if DEBUG_OPENGL
-#define GL_CHECKPOINT(LEVEL) \
- do { if (DEBUG_OPENGL >= DEBUG_LEVEL_##LEVEL) {\
- LOG_ALWAYS_FATAL_IF(android::uirenderer::GLUtils::dumpGLErrors(),\
- "GL errors! %s:%d", __FILE__, __LINE__);\
- } } while (0)
+#define GL_CHECKPOINT(LEVEL) \
+ do { \
+ if (DEBUG_OPENGL >= DEBUG_LEVEL_##LEVEL) { \
+ LOG_ALWAYS_FATAL_IF(android::uirenderer::GLUtils::dumpGLErrors(), "GL errors! %s:%d", \
+ __FILE__, __LINE__); \
+ } \
+ } while (0)
#else
#define GL_CHECKPOINT(LEVEL)
#endif
@@ -42,7 +43,7 @@
*/
static bool dumpGLErrors();
-}; // class GLUtils
+}; // class GLUtils
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/utils/LinearAllocator.cpp b/libs/hwui/utils/LinearAllocator.cpp
index d92bc0c..5a59de8 100644
--- a/libs/hwui/utils/LinearAllocator.cpp
+++ b/libs/hwui/utils/LinearAllocator.cpp
@@ -30,10 +30,9 @@
#include <stdlib.h>
#include <utils/Log.h>
-
// The ideal size of a page allocation (these need to be multiples of 8)
-#define INITIAL_PAGE_SIZE ((size_t)512) // 512b
-#define MAX_PAGE_SIZE ((size_t)131072) // 128kb
+#define INITIAL_PAGE_SIZE ((size_t)512) // 512b
+#define MAX_PAGE_SIZE ((size_t)131072) // 128kb
// The maximum amount of wasted space we can have per page
// Allocations exceeding this will have their own dedicated page
@@ -48,7 +47,7 @@
#define ALIGN_SZ (sizeof(int))
#endif
-#define ALIGN(x) (((x) + ALIGN_SZ - 1 ) & ~(ALIGN_SZ - 1))
+#define ALIGN(x) (((x) + ALIGN_SZ - 1) & ~(ALIGN_SZ - 1))
#define ALIGN_PTR(p) ((void*)(ALIGN((size_t)(p))))
#if LOG_NDEBUG
@@ -79,7 +78,7 @@
#define RM_ALLOCATION(size) _addAllocation(-1);
#endif
-#define min(x,y) (((x) < (y)) ? (x) : (y))
+#define min(x, y) (((x) < (y)) ? (x) : (y))
namespace android {
namespace uirenderer {
@@ -89,19 +88,13 @@
Page* next() { return mNextPage; }
void setNext(Page* next) { mNextPage = next; }
- Page()
- : mNextPage(0)
- {}
+ Page() : mNextPage(0) {}
void* operator new(size_t /*size*/, void* buf) { return buf; }
- void* start() {
- return (void*) (((size_t)this) + sizeof(Page));
- }
+ void* start() { return (void*)(((size_t)this) + sizeof(Page)); }
- void* end(int pageSize) {
- return (void*) (((size_t)start()) + pageSize);
- }
+ void* end(int pageSize) { return (void*)(((size_t)start()) + pageSize); }
private:
Page(const Page& /*other*/) {}
@@ -109,15 +102,15 @@
};
LinearAllocator::LinearAllocator()
- : mPageSize(INITIAL_PAGE_SIZE)
- , mMaxAllocSize(INITIAL_PAGE_SIZE * MAX_WASTE_RATIO)
- , mNext(0)
- , mCurrentPage(0)
- , mPages(0)
- , mTotalAllocated(0)
- , mWastedSpace(0)
- , mPageCount(0)
- , mDedicatedPageCount(0) {}
+ : mPageSize(INITIAL_PAGE_SIZE)
+ , mMaxAllocSize(INITIAL_PAGE_SIZE * MAX_WASTE_RATIO)
+ , mNext(0)
+ , mCurrentPage(0)
+ , mPages(0)
+ , mTotalAllocated(0)
+ , mWastedSpace(0)
+ , mPageCount(0)
+ , mDedicatedPageCount(0) {}
LinearAllocator::~LinearAllocator(void) {
while (mDtorList) {
@@ -176,8 +169,7 @@
mDedicatedPageCount++;
page->setNext(mPages);
mPages = page;
- if (!mCurrentPage)
- mCurrentPage = mPages;
+ if (!mCurrentPage) mCurrentPage = mPages;
return start(page);
}
ensureNext(size);
@@ -225,8 +217,8 @@
runDestructorFor(ptr);
// Don't bother rewinding across pages
allocSize = ALIGN(allocSize);
- if (ptr >= start(mCurrentPage) && ptr < end(mCurrentPage)
- && ptr == ((char*)mNext - allocSize)) {
+ if (ptr >= start(mCurrentPage) && ptr < end(mCurrentPage) &&
+ ptr == ((char*)mNext - allocSize)) {
mWastedSpace += allocSize;
mNext = ptr;
}
@@ -261,9 +253,9 @@
ALOGD("%sTotal allocated: %.2f%s", prefix, prettySize, prettySuffix);
prettySuffix = toSize(mWastedSpace, prettySize);
ALOGD("%sWasted space: %.2f%s (%.1f%%)", prefix, prettySize, prettySuffix,
- (float) mWastedSpace / (float) mTotalAllocated * 100.0f);
+ (float)mWastedSpace / (float)mTotalAllocated * 100.0f);
ALOGD("%sPages %zu (dedicated %zu)", prefix, mPageCount, mDedicatedPageCount);
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/utils/LinearAllocator.h b/libs/hwui/utils/LinearAllocator.h
index f95a6fe..03f685e 100644
--- a/libs/hwui/utils/LinearAllocator.h
+++ b/libs/hwui/utils/LinearAllocator.h
@@ -56,10 +56,10 @@
* Note that unlike create, for alloc the type is purely for compile-time error
* checking and does not affect size.
*/
- template<class T>
+ template <class T>
void* alloc(size_t size) {
static_assert(std::is_trivially_destructible<T>::value,
- "Error, type is non-trivial! did you mean to use create()?");
+ "Error, type is non-trivial! did you mean to use create()?");
return allocImpl(size);
}
@@ -67,7 +67,7 @@
* Allocates an instance of the template type with the given construction parameters
* and adds it to the automatic destruction list.
*/
- template<class T, typename... Params>
+ template <class T, typename... Params>
T* create(Params&&... params) {
T* ret = new (allocImpl(sizeof(T))) T(std::forward<Params>(params)...);
if (!std::is_trivially_destructible<T>::value) {
@@ -77,17 +77,17 @@
return ret;
}
- template<class T, typename... Params>
+ template <class T, typename... Params>
T* create_trivial(Params&&... params) {
static_assert(std::is_trivially_destructible<T>::value,
- "Error, called create_trivial on a non-trivial type");
+ "Error, called create_trivial on a non-trivial type");
return new (allocImpl(sizeof(T))) T(std::forward<Params>(params)...);
}
- template<class T>
+ template <class T>
T* create_trivial_array(int count) {
static_assert(std::is_trivially_destructible<T>::value,
- "Error, called create_trivial_array on a non-trivial type");
+ "Error, called create_trivial_array on a non-trivial type");
return reinterpret_cast<T*>(allocImpl(sizeof(T) * count));
}
@@ -100,7 +100,7 @@
/**
* Same as rewindIfLastAlloc(void*, size_t)
*/
- template<class T>
+ template <class T>
void rewindIfLastAlloc(T* ptr) {
rewindIfLastAlloc((void*)ptr, sizeof(T));
}
@@ -134,7 +134,7 @@
Page* newPage(size_t pageSize);
bool fitsInCurrentPage(size_t size);
void ensureNext(size_t size);
- void* start(Page *p);
+ void* start(Page* p);
void* end(Page* p);
size_t mPageSize;
@@ -154,13 +154,11 @@
template <class T>
class LinearStdAllocator {
public:
- typedef T value_type; // needed to implement std::allocator
- typedef T* pointer; // needed to implement std::allocator
+ typedef T value_type; // needed to implement std::allocator
+ typedef T* pointer; // needed to implement std::allocator
- explicit LinearStdAllocator(LinearAllocator& allocator)
- : linearAllocator(allocator) {}
- LinearStdAllocator(const LinearStdAllocator& other)
- : linearAllocator(other.linearAllocator) {}
+ explicit LinearStdAllocator(LinearAllocator& allocator) : linearAllocator(allocator) {}
+ LinearStdAllocator(const LinearStdAllocator& other) : linearAllocator(other.linearAllocator) {}
~LinearStdAllocator() {}
// rebind marks that allocators can be rebound to different types
@@ -188,9 +186,13 @@
// return that all specializations of LinearStdAllocator are interchangeable
template <class T1, class T2>
-bool operator== (const LinearStdAllocator<T1>&, const LinearStdAllocator<T2>&) { return true; }
+bool operator==(const LinearStdAllocator<T1>&, const LinearStdAllocator<T2>&) {
+ return true;
+}
template <class T1, class T2>
-bool operator!= (const LinearStdAllocator<T1>&, const LinearStdAllocator<T2>&) { return false; }
+bool operator!=(const LinearStdAllocator<T1>&, const LinearStdAllocator<T2>&) {
+ return false;
+}
template <class T>
class LsaVector : public std::vector<T, LinearStdAllocator<T>> {
@@ -199,7 +201,7 @@
: std::vector<T, LinearStdAllocator<T>>(allocator) {}
};
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
-#endif // ANDROID_LINEARALLOCATOR_H
+#endif // ANDROID_LINEARALLOCATOR_H
diff --git a/libs/hwui/utils/Macros.h b/libs/hwui/utils/Macros.h
index 7212897b..d758f29 100644
--- a/libs/hwui/utils/Macros.h
+++ b/libs/hwui/utils/Macros.h
@@ -19,21 +19,19 @@
#include <type_traits>
#define PREVENT_COPY_AND_ASSIGN(Type) \
- private: \
- Type(const Type&) = delete; \
- void operator=(const Type&) = delete
+private: \
+ Type(const Type&) = delete; \
+ void operator=(const Type&) = delete
-#define HASHABLE_TYPE(Type) \
- bool operator==(const Type& other) const; \
- hash_t hash() const; \
- bool operator!=(const Type& other) const { return !(*this == other); } \
- friend inline hash_t hash_type(const Type& entry) { return entry.hash(); }
+#define HASHABLE_TYPE(Type) \
+ bool operator==(const Type& other) const; \
+ hash_t hash() const; \
+ bool operator!=(const Type& other) const { return !(*this == other); } \
+ friend inline hash_t hash_type(const Type& entry) { return entry.hash(); }
#define REQUIRE_COMPATIBLE_LAYOUT(Type) \
- static_assert(std::is_standard_layout<Type>::value, \
- #Type " must have standard layout")
+ static_assert(std::is_standard_layout<Type>::value, #Type " must have standard layout")
-#define WARN_UNUSED_RESULT \
- __attribute__((warn_unused_result))
+#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#endif /* MACROS_H */
diff --git a/libs/hwui/utils/MathUtils.h b/libs/hwui/utils/MathUtils.h
index 8d20f21..5475898 100644
--- a/libs/hwui/utils/MathUtils.h
+++ b/libs/hwui/utils/MathUtils.h
@@ -16,8 +16,8 @@
#ifndef MATHUTILS_H
#define MATHUTILS_H
-#include <algorithm>
#include <math.h>
+#include <algorithm>
namespace android {
namespace uirenderer {
@@ -34,9 +34,7 @@
return (value >= -NON_ZERO_EPSILON) && (value <= NON_ZERO_EPSILON);
}
- inline static bool isPositive(float value) {
- return value >= NON_ZERO_EPSILON;
- }
+ inline static bool isPositive(float value) { return value >= NON_ZERO_EPSILON; }
/**
* Clamps alpha value, and snaps when very near 0 or 1
@@ -69,28 +67,24 @@
* Returns the number of points (beyond two, the start and end) needed to form a polygonal
* approximation of an arc, with a given threshold value.
*/
- inline static int divisionsNeededToApproximateArc(float radius,
- float angleInRads, float threshold) {
+ inline static int divisionsNeededToApproximateArc(float radius, float angleInRads,
+ float threshold) {
const float errConst = (-threshold / radius + 1);
const float targetCosVal = 2 * errConst * errConst - 1;
// needed divisions are rounded up from approximation
- return (int)(ceilf(angleInRads / acos(targetCosVal)/2)) * 2;
+ return (int)(ceilf(angleInRads / acos(targetCosVal) / 2)) * 2;
}
- inline static bool areEqual(float valueA, float valueB) {
- return isZero(valueA - valueB);
- }
+ inline static bool areEqual(float valueA, float valueB) { return isZero(valueA - valueB); }
- template<typename T>
+ template <typename T>
static inline T clamp(T a, T minValue, T maxValue) {
return std::min(std::max(a, minValue), maxValue);
}
- inline static float lerp(float v1, float v2, float t) {
- return v1 + ((v2 - v1) * t);
- }
-}; // class MathUtils
+ inline static float lerp(float v1, float v2, float t) { return v1 + ((v2 - v1) * t); }
+}; // class MathUtils
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/utils/PaintUtils.h b/libs/hwui/utils/PaintUtils.h
index 2673be1c..233adae 100644
--- a/libs/hwui/utils/PaintUtils.h
+++ b/libs/hwui/utils/PaintUtils.h
@@ -31,7 +31,6 @@
*/
class PaintUtils {
public:
-
static inline GLenum getFilter(const SkPaint* paint) {
if (!paint || paint->getFilterQuality() != kNone_SkFilterQuality) {
return GL_LINEAR;
@@ -40,18 +39,16 @@
}
static bool isOpaquePaint(const SkPaint* paint) {
- if (!paint) return true; // default (paintless) behavior is SrcOver, black
+ if (!paint) return true; // default (paintless) behavior is SrcOver, black
- if (paint->getAlpha() != 0xFF
- || PaintUtils::isBlendedShader(paint->getShader())
- || PaintUtils::isBlendedColorFilter(paint->getColorFilter())) {
+ if (paint->getAlpha() != 0xFF || PaintUtils::isBlendedShader(paint->getShader()) ||
+ PaintUtils::isBlendedColorFilter(paint->getColorFilter())) {
return false;
}
// Only let simple srcOver / src blending modes declare opaque, since behavior is clear.
SkBlendMode mode = paint->getBlendMode();
- return mode == SkBlendMode::kSrcOver
- || mode == SkBlendMode::kSrc;
+ return mode == SkBlendMode::kSrcOver || mode == SkBlendMode::kSrc;
}
static bool isBlendedShader(const SkShader* shader) {
@@ -89,9 +86,7 @@
return false;
}
- static inline bool hasTextShadow(const SkPaint* paint) {
- return getTextShadow(paint, nullptr);
- }
+ static inline bool hasTextShadow(const SkPaint* paint) { return getTextShadow(paint, nullptr); }
static inline SkBlendMode getBlendModeDirect(const SkPaint* paint) {
return paint ? paint->getBlendMode() : SkBlendMode::kSrcOver;
@@ -101,7 +96,7 @@
return paint ? paint->getAlpha() : 255;
}
-}; // class PaintUtils
+}; // class PaintUtils
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/utils/Pair.h b/libs/hwui/utils/Pair.h
index 0db3aa3..4bcd576 100644
--- a/libs/hwui/utils/Pair.h
+++ b/libs/hwui/utils/Pair.h
@@ -27,34 +27,34 @@
F first;
S second;
- Pair() { }
- Pair(const Pair& o) : first(o.first), second(o.second) { }
- Pair(const F& f, const S& s) : first(f), second(s) { }
+ Pair() {}
+ Pair(const Pair& o) : first(o.first), second(o.second) {}
+ Pair(const F& f, const S& s) : first(f), second(s) {}
- inline const F& getFirst() const {
- return first;
- }
+ inline const F& getFirst() const { return first; }
- inline const S& getSecond() const {
- return second;
- }
+ inline const S& getSecond() const { return second; }
};
-}; // namespace uirenderer
+}; // namespace uirenderer
template <typename F, typename S>
-struct trait_trivial_ctor< uirenderer::Pair<F, S> >
-{ enum { value = aggregate_traits<F, S>::has_trivial_ctor }; };
+struct trait_trivial_ctor<uirenderer::Pair<F, S> > {
+ enum { value = aggregate_traits<F, S>::has_trivial_ctor };
+};
template <typename F, typename S>
-struct trait_trivial_dtor< uirenderer::Pair<F, S> >
-{ enum { value = aggregate_traits<F, S>::has_trivial_dtor }; };
+struct trait_trivial_dtor<uirenderer::Pair<F, S> > {
+ enum { value = aggregate_traits<F, S>::has_trivial_dtor };
+};
template <typename F, typename S>
-struct trait_trivial_copy< uirenderer::Pair<F, S> >
-{ enum { value = aggregate_traits<F, S>::has_trivial_copy }; };
+struct trait_trivial_copy<uirenderer::Pair<F, S> > {
+ enum { value = aggregate_traits<F, S>::has_trivial_copy };
+};
template <typename F, typename S>
-struct trait_trivial_move< uirenderer::Pair<F, S> >
-{ enum { value = aggregate_traits<F, S>::has_trivial_move }; };
+struct trait_trivial_move<uirenderer::Pair<F, S> > {
+ enum { value = aggregate_traits<F, S>::has_trivial_move };
+};
-}; // namespace android
+}; // namespace android
-#endif // ANDROID_HWUI_PAIR_H
+#endif // ANDROID_HWUI_PAIR_H
diff --git a/libs/hwui/utils/RingBuffer.h b/libs/hwui/utils/RingBuffer.h
index 06bcdcd..b3e8931 100644
--- a/libs/hwui/utils/RingBuffer.h
+++ b/libs/hwui/utils/RingBuffer.h
@@ -23,7 +23,7 @@
namespace android {
namespace uirenderer {
-template<class T, size_t SIZE>
+template <class T, size_t SIZE>
class RingBuffer {
PREVENT_COPY_AND_ASSIGN(RingBuffer);
@@ -42,21 +42,13 @@
return mBuffer[mHead];
}
- T& front() {
- return (*this)[0];
- }
+ T& front() { return (*this)[0]; }
- T& back() {
- return (*this)[size() - 1];
- }
+ T& back() { return (*this)[size() - 1]; }
- T& operator[](size_t index) {
- return mBuffer[(mHead + index + 1) % mCount];
- }
+ T& operator[](size_t index) { return mBuffer[(mHead + index + 1) % mCount]; }
- const T& operator[](size_t index) const {
- return mBuffer[(mHead + index + 1) % mCount];
- }
+ const T& operator[](size_t index) const { return mBuffer[(mHead + index + 1) % mCount]; }
void clear() {
mCount = 0;
@@ -69,7 +61,7 @@
size_t mCount = 0;
};
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
#endif /* RINGBUFFER_H_ */
diff --git a/libs/hwui/utils/StringUtils.cpp b/libs/hwui/utils/StringUtils.cpp
index 64a5970..5304b76 100644
--- a/libs/hwui/utils/StringUtils.cpp
+++ b/libs/hwui/utils/StringUtils.cpp
@@ -34,5 +34,5 @@
return set;
}
-}; // namespace uirenderer
-}; // namespace android
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/utils/StringUtils.h b/libs/hwui/utils/StringUtils.h
index af5d10f..a10610a 100644
--- a/libs/hwui/utils/StringUtils.h
+++ b/libs/hwui/utils/StringUtils.h
@@ -30,9 +30,7 @@
class unordered_string_set : public std::unordered_set<std::string> {
public:
- bool has(const char* str) {
- return find(std::string(str)) != end();
- }
+ bool has(const char* str) { return find(std::string(str)) != end(); }
};
class StringUtils {
@@ -55,8 +53,8 @@
}
};
-class LogcatStream: public std::ostream {
- class LogcatStreamBuf: public std::stringbuf {
+class LogcatStream : public std::ostream {
+ class LogcatStreamBuf : public std::stringbuf {
virtual int sync() {
ALOGD("%s", str().c_str());
str("");
@@ -65,10 +63,9 @@
};
LogcatStreamBuf buffer;
+
public:
- LogcatStream()
- :std::ostream(&buffer) {
- }
+ LogcatStream() : std::ostream(&buffer) {}
};
} /* namespace uirenderer */
diff --git a/libs/hwui/utils/TestWindowContext.cpp b/libs/hwui/utils/TestWindowContext.cpp
index 492ca7fe..700d3b3 100644
--- a/libs/hwui/utils/TestWindowContext.cpp
+++ b/libs/hwui/utils/TestWindowContext.cpp
@@ -36,13 +36,13 @@
*/
class ContextFactory : public android::uirenderer::IContextFactory {
public:
- android::uirenderer::AnimationContext* createAnimationContext
- (android::uirenderer::renderthread::TimeLord& clock) override {
+ android::uirenderer::AnimationContext* createAnimationContext(
+ android::uirenderer::renderthread::TimeLord& clock) override {
return new android::uirenderer::AnimationContext(clock);
}
};
-} // anonymous namespace
+} // anonymous namespace
namespace android {
namespace uirenderer {
@@ -54,45 +54,38 @@
*/
class TestWindowContext::TestWindowData {
-
public:
-
explicit TestWindowData(SkISize size) : mSize(size) {
android::BufferQueue::createBufferQueue(&mProducer, &mConsumer);
mCpuConsumer = new android::CpuConsumer(mConsumer, 1);
mCpuConsumer->setName(android::String8("TestWindowContext"));
mCpuConsumer->setDefaultBufferSize(mSize.width(), mSize.height());
mAndroidSurface = new android::Surface(mProducer);
- native_window_set_buffers_dimensions(mAndroidSurface.get(),
- mSize.width(), mSize.height());
- native_window_set_buffers_format(mAndroidSurface.get(),
- android::PIXEL_FORMAT_RGBA_8888);
- native_window_set_usage(mAndroidSurface.get(),
- GRALLOC_USAGE_SW_READ_OFTEN |
- GRALLOC_USAGE_SW_WRITE_NEVER |
- GRALLOC_USAGE_HW_RENDER);
+ native_window_set_buffers_dimensions(mAndroidSurface.get(), mSize.width(), mSize.height());
+ native_window_set_buffers_format(mAndroidSurface.get(), android::PIXEL_FORMAT_RGBA_8888);
+ native_window_set_usage(mAndroidSurface.get(), GRALLOC_USAGE_SW_READ_OFTEN |
+ GRALLOC_USAGE_SW_WRITE_NEVER |
+ GRALLOC_USAGE_HW_RENDER);
mRootNode.reset(new android::uirenderer::RenderNode());
mRootNode->incStrong(nullptr);
- mRootNode->mutateStagingProperties().setLeftTopRightBottom
- (0, 0, mSize.width(), mSize.height());
+ mRootNode->mutateStagingProperties().setLeftTopRightBottom(0, 0, mSize.width(),
+ mSize.height());
mRootNode->mutateStagingProperties().setClipToBounds(false);
mRootNode->setPropertyFieldsDirty(android::uirenderer::RenderNode::GENERIC);
ContextFactory factory;
- mProxy.reset
- (new android::uirenderer::renderthread::RenderProxy(false,
- mRootNode.get(),
- &factory));
+ mProxy.reset(new android::uirenderer::renderthread::RenderProxy(false, mRootNode.get(),
+ &factory));
mProxy->loadSystemProperties();
mProxy->initialize(mAndroidSurface.get());
float lightX = mSize.width() / 2.0f;
- android::uirenderer::Vector3 lightVector { lightX, -200.0f, 800.0f };
+ android::uirenderer::Vector3 lightVector{lightX, -200.0f, 800.0f};
mProxy->setup(800.0f, 255 * 0.075f, 255 * 0.15f);
mProxy->setLightCenter(lightVector);
mCanvas.reset(new android::uirenderer::RecordingCanvas(mSize.width(), mSize.height()));
}
SkCanvas* prepareToDraw() {
- //mCanvas->reset(mSize.width(), mSize.height());
+ // mCanvas->reset(mSize.width(), mSize.height());
mCanvas->clipRect(0, 0, mSize.width(), mSize.height(), SkClipOp::kReplace_deprecated);
return mCanvas->asSkCanvas();
}
@@ -104,17 +97,15 @@
// the timings we record.
}
- void fence() {
- mProxy->fence();
- }
+ void fence() { mProxy->fence(); }
bool capturePixels(SkBitmap* bmp) {
sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB();
SkImageInfo destinationConfig =
- SkImageInfo::Make(mSize.width(), mSize.height(),
- kRGBA_8888_SkColorType, kPremul_SkAlphaType, colorSpace);
+ SkImageInfo::Make(mSize.width(), mSize.height(), kRGBA_8888_SkColorType,
+ kPremul_SkAlphaType, colorSpace);
bmp->allocPixels(destinationConfig);
- android_memset32((uint32_t*) bmp->getPixels(), SK_ColorRED,
+ android_memset32((uint32_t*)bmp->getPixels(), SK_ColorRED,
mSize.width() * mSize.height() * 4);
android::CpuConsumer::LockedBuffer nativeBuffer;
@@ -135,14 +126,13 @@
LOG_ALWAYS_FATAL_IF(nativeBuffer.format != android::PIXEL_FORMAT_RGBA_8888,
"Native buffer not RGBA!");
- SkImageInfo nativeConfig =
- SkImageInfo::Make(nativeBuffer.width, nativeBuffer.height,
- kRGBA_8888_SkColorType, kPremul_SkAlphaType);
+ SkImageInfo nativeConfig = SkImageInfo::Make(nativeBuffer.width, nativeBuffer.height,
+ kRGBA_8888_SkColorType, kPremul_SkAlphaType);
// Android stride is in pixels, Skia stride is in bytes
SkBitmap nativeWrapper;
- bool success =
- nativeWrapper.installPixels(nativeConfig, nativeBuffer.data, nativeBuffer.stride * 4);
+ bool success = nativeWrapper.installPixels(nativeConfig, nativeBuffer.data,
+ nativeBuffer.stride * 4);
if (!success) {
SkDebugf("Failed to wrap HWUI buffer in a SkBitmap");
return false;
@@ -150,8 +140,8 @@
LOG_ALWAYS_FATAL_IF(bmp->colorType() != kRGBA_8888_SkColorType,
"Destination buffer not RGBA!");
- success =
- nativeWrapper.readPixels(destinationConfig, bmp->getPixels(), bmp->rowBytes(), 0, 0);
+ success = nativeWrapper.readPixels(destinationConfig, bmp->getPixels(), bmp->rowBytes(), 0,
+ 0);
if (!success) {
SkDebugf("Failed to extract pixels from HWUI buffer");
return false;
@@ -163,7 +153,6 @@
}
private:
-
std::unique_ptr<android::uirenderer::RenderNode> mRootNode;
std::unique_ptr<android::uirenderer::renderthread::RenderProxy> mProxy;
std::unique_ptr<android::uirenderer::RecordingCanvas> mCanvas;
@@ -174,15 +163,13 @@
SkISize mSize;
};
-
-TestWindowContext::TestWindowContext() :
- mData (nullptr) { }
+TestWindowContext::TestWindowContext() : mData(nullptr) {}
TestWindowContext::~TestWindowContext() {
delete mData;
}
-void TestWindowContext::initialize(int width, int height) {
+void TestWindowContext::initialize(int width, int height) {
mData = new TestWindowData(SkISize::Make(width, height));
}
@@ -206,6 +193,5 @@
return mData ? mData->capturePixels(bmp) : false;
}
-} // namespace uirenderer
-} // namespace android
-
+} // namespace uirenderer
+} // namespace android
diff --git a/libs/hwui/utils/TestWindowContext.h b/libs/hwui/utils/TestWindowContext.h
index 48ec952..17ad1e3 100644
--- a/libs/hwui/utils/TestWindowContext.h
+++ b/libs/hwui/utils/TestWindowContext.h
@@ -31,9 +31,7 @@
*/
class ANDROID_API TestWindowContext {
-
public:
-
TestWindowContext();
~TestWindowContext();
@@ -58,11 +56,9 @@
class TestWindowData;
TestWindowData* mData;
-
};
} // namespace uirenderer
} // namespace android
#endif // TESTWINDOWCONTEXT_H_
-
diff --git a/libs/hwui/utils/TimeUtils.h b/libs/hwui/utils/TimeUtils.h
index ce181b7..f66edea 100644
--- a/libs/hwui/utils/TimeUtils.h
+++ b/libs/hwui/utils/TimeUtils.h
@@ -21,15 +21,15 @@
namespace android {
namespace uirenderer {
-constexpr nsecs_t operator"" _s (unsigned long long s) {
+constexpr nsecs_t operator"" _s(unsigned long long s) {
return seconds_to_nanoseconds(s);
}
-constexpr nsecs_t operator"" _ms (unsigned long long ms) {
+constexpr nsecs_t operator"" _ms(unsigned long long ms) {
return milliseconds_to_nanoseconds(ms);
}
-constexpr nsecs_t operator"" _us (unsigned long long us) {
+constexpr nsecs_t operator"" _us(unsigned long long us) {
return microseconds_to_nanoseconds(us);
}
diff --git a/libs/hwui/utils/Timing.h b/libs/hwui/utils/Timing.h
index 4b1fabe..978c7bc 100644
--- a/libs/hwui/utils/Timing.h
+++ b/libs/hwui/utils/Timing.h
@@ -22,18 +22,16 @@
#define TIME_METHOD() MethodTimer __method_timer(__func__)
class MethodTimer {
public:
- explicit MethodTimer(const char* name)
- : mMethodName(name) {
- gettimeofday(&mStart, nullptr);
- }
+ explicit MethodTimer(const char* name) : mMethodName(name) { gettimeofday(&mStart, nullptr); }
~MethodTimer() {
struct timeval stop;
gettimeofday(&stop, nullptr);
- long long elapsed = (stop.tv_sec * 1000000) - (mStart.tv_sec * 1000000)
- + (stop.tv_usec - mStart.tv_usec);
+ long long elapsed = (stop.tv_sec * 1000000) - (mStart.tv_sec * 1000000) +
+ (stop.tv_usec - mStart.tv_usec);
ALOGD("%s took %.2fms", mMethodName, elapsed / 1000.0);
}
+
private:
const char* mMethodName;
struct timeval mStart;
diff --git a/libs/hwui/utils/TraceUtils.h b/libs/hwui/utils/TraceUtils.h
index ddc272c..1869d00 100644
--- a/libs/hwui/utils/TraceUtils.h
+++ b/libs/hwui/utils/TraceUtils.h
@@ -18,11 +18,11 @@
#include <utils/Trace.h>
-#define ATRACE_FORMAT(fmt, ...) \
- TraceUtils::TraceEnder __traceEnder = (TraceUtils::atraceFormatBegin(fmt, ##__VA_ARGS__), TraceUtils::TraceEnder())
+#define ATRACE_FORMAT(fmt, ...) \
+ TraceUtils::TraceEnder __traceEnder = \
+ (TraceUtils::atraceFormatBegin(fmt, ##__VA_ARGS__), TraceUtils::TraceEnder())
-#define ATRACE_FORMAT_BEGIN(fmt, ...) \
- TraceUtils::atraceFormatBegin(fmt, ##__VA_ARGS__)
+#define ATRACE_FORMAT_BEGIN(fmt, ...) TraceUtils::atraceFormatBegin(fmt, ##__VA_ARGS__)
namespace android {
namespace uirenderer {
@@ -48,7 +48,7 @@
ATRACE_BEGIN(buf);
}
-}; // class TraceUtils
+}; // class TraceUtils
} /* namespace uirenderer */
} /* namespace android */
diff --git a/libs/hwui/utils/VectorDrawableUtils.cpp b/libs/hwui/utils/VectorDrawableUtils.cpp
index 6f0c96d..1931d64 100644
--- a/libs/hwui/utils/VectorDrawableUtils.cpp
+++ b/libs/hwui/utils/VectorDrawableUtils.cpp
@@ -32,8 +32,8 @@
float ctrlPointY = 0;
float currentSegmentStartX = 0;
float currentSegmentStartY = 0;
- void addCommand(SkPath* outPath, char previousCmd,
- char cmd, const std::vector<float>* points, size_t start, size_t end);
+ void addCommand(SkPath* outPath, char previousCmd, char cmd, const std::vector<float>* points,
+ size_t start, size_t end);
};
bool VectorDrawableUtils::canMorph(const PathData& morphFrom, const PathData& morphTo) {
@@ -42,8 +42,8 @@
}
for (unsigned int i = 0; i < morphFrom.verbs.size(); i++) {
- if (morphFrom.verbs[i] != morphTo.verbs[i]
- || morphFrom.verbSizes[i] != morphTo.verbSizes[i]) {
+ if (morphFrom.verbs[i] != morphTo.verbs[i] ||
+ morphFrom.verbSizes[i] != morphTo.verbSizes[i]) {
return false;
}
}
@@ -51,7 +51,7 @@
}
bool VectorDrawableUtils::interpolatePathData(PathData* outData, const PathData& morphFrom,
- const PathData& morphTo, float fraction) {
+ const PathData& morphTo, float fraction) {
if (!canMorph(morphFrom, morphTo)) {
return false;
}
@@ -59,9 +59,9 @@
return true;
}
- /**
- * Convert an array of PathVerb to Path.
- */
+/**
+* Convert an array of PathVerb to Path.
+*/
void VectorDrawableUtils::verbsToPath(SkPath* outPath, const PathData& data) {
PathResolver resolver;
char previousCommand = 'm';
@@ -70,7 +70,7 @@
for (unsigned int i = 0; i < data.verbs.size(); i++) {
size_t verbSize = data.verbSizes[i];
resolver.addCommand(outPath, previousCommand, data.verbs[i], &data.points, start,
- start + verbSize);
+ start + verbSize);
previousCommand = data.verbs[i];
start += verbSize;
}
@@ -85,8 +85,8 @@
* @param nodeTo The end value as a PathVerb
* @param fraction The fraction to interpolate.
*/
-void VectorDrawableUtils::interpolatePaths(PathData* outData,
- const PathData& from, const PathData& to, float fraction) {
+void VectorDrawableUtils::interpolatePaths(PathData* outData, const PathData& from,
+ const PathData& to, float fraction) {
outData->points.resize(from.points.size());
outData->verbSizes = from.verbSizes;
outData->verbs = from.verbs;
@@ -110,16 +110,8 @@
* @param start The start angle of the arc on the ellipse
* @param sweep The angle (positive or negative) of the sweep of the arc on the ellipse
*/
-static void arcToBezier(SkPath* p,
- double cx,
- double cy,
- double a,
- double b,
- double e1x,
- double e1y,
- double theta,
- double start,
- double sweep) {
+static void arcToBezier(SkPath* p, double cx, double cy, double a, double b, double e1x, double e1y,
+ double theta, double start, double sweep) {
// Taken from equations at: http://spaceroots.org/documents/ellipse/node8.html
// and http://www.spaceroots.org/documents/ellipse/node22.html
@@ -144,19 +136,13 @@
double ep2x = -a * cosTheta * sinEta2 - b * sinTheta * cosEta2;
double ep2y = -a * sinTheta * sinEta2 + b * cosTheta * cosEta2;
double tanDiff2 = tan((eta2 - eta1) / 2);
- double alpha =
- sin(eta2 - eta1) * (sqrt(4 + (3 * tanDiff2 * tanDiff2)) - 1) / 3;
+ double alpha = sin(eta2 - eta1) * (sqrt(4 + (3 * tanDiff2 * tanDiff2)) - 1) / 3;
double q1x = e1x + alpha * ep1x;
double q1y = e1y + alpha * ep1y;
double q2x = e2x - alpha * ep2x;
double q2y = e2y - alpha * ep2y;
- p->cubicTo((float) q1x,
- (float) q1y,
- (float) q2x,
- (float) q2y,
- (float) e2x,
- (float) e2y);
+ p->cubicTo((float)q1x, (float)q1y, (float)q2x, (float)q2y, (float)e2x, (float)e2y);
eta1 = eta2;
e1x = e2x;
e1y = e2y;
@@ -165,19 +151,12 @@
}
}
-inline double toRadians(float theta) { return theta * M_PI / 180;}
+inline double toRadians(float theta) {
+ return theta * M_PI / 180;
+}
-static void drawArc(SkPath* p,
- float x0,
- float y0,
- float x1,
- float y1,
- float a,
- float b,
- float theta,
- bool isMoreThanHalf,
- bool isPositiveArc) {
-
+static void drawArc(SkPath* p, float x0, float y0, float x1, float y1, float a, float b,
+ float theta, bool isMoreThanHalf, bool isPositiveArc) {
/* Convert rotation angle from degrees to radians */
double thetaD = toRadians(theta);
/* Pre-compute rotation matrix entries */
@@ -204,9 +183,8 @@
double disc = 1.0 / dsq - 1.0 / 4.0;
if (disc < 0.0) {
VECTOR_DRAWABLE_LOGD("Points are too far apart %f", dsq);
- float adjust = (float) (sqrt(dsq) / 1.99999);
- drawArc(p, x0, y0, x1, y1, a * adjust,
- b * adjust, theta, isMoreThanHalf, isPositiveArc);
+ float adjust = (float)(sqrt(dsq) / 1.99999);
+ drawArc(p, x0, y0, x1, y1, a * adjust, b * adjust, theta, isMoreThanHalf, isPositiveArc);
return; /* Points are too far apart */
}
double s = sqrt(disc);
@@ -244,248 +222,232 @@
arcToBezier(p, cx, cy, a, b, x0, y0, thetaD, eta0, sweep);
}
-
-
// Use the given verb, and points in the range [start, end) to insert a command into the SkPath.
-void PathResolver::addCommand(SkPath* outPath, char previousCmd,
- char cmd, const std::vector<float>* points, size_t start, size_t end) {
-
+void PathResolver::addCommand(SkPath* outPath, char previousCmd, char cmd,
+ const std::vector<float>* points, size_t start, size_t end) {
int incr = 2;
float reflectiveCtrlPointX;
float reflectiveCtrlPointY;
switch (cmd) {
- case 'z':
- case 'Z':
- outPath->close();
- // Path is closed here, but we need to move the pen to the
- // closed position. So we cache the segment's starting position,
- // and restore it here.
- currentX = currentSegmentStartX;
- currentY = currentSegmentStartY;
- ctrlPointX = currentSegmentStartX;
- ctrlPointY = currentSegmentStartY;
- outPath->moveTo(currentX, currentY);
- break;
- case 'm':
- case 'M':
- case 'l':
- case 'L':
- case 't':
- case 'T':
- incr = 2;
- break;
- case 'h':
- case 'H':
- case 'v':
- case 'V':
- incr = 1;
- break;
- case 'c':
- case 'C':
- incr = 6;
- break;
- case 's':
- case 'S':
- case 'q':
- case 'Q':
- incr = 4;
- break;
- case 'a':
- case 'A':
- incr = 7;
- break;
+ case 'z':
+ case 'Z':
+ outPath->close();
+ // Path is closed here, but we need to move the pen to the
+ // closed position. So we cache the segment's starting position,
+ // and restore it here.
+ currentX = currentSegmentStartX;
+ currentY = currentSegmentStartY;
+ ctrlPointX = currentSegmentStartX;
+ ctrlPointY = currentSegmentStartY;
+ outPath->moveTo(currentX, currentY);
+ break;
+ case 'm':
+ case 'M':
+ case 'l':
+ case 'L':
+ case 't':
+ case 'T':
+ incr = 2;
+ break;
+ case 'h':
+ case 'H':
+ case 'v':
+ case 'V':
+ incr = 1;
+ break;
+ case 'c':
+ case 'C':
+ incr = 6;
+ break;
+ case 's':
+ case 'S':
+ case 'q':
+ case 'Q':
+ incr = 4;
+ break;
+ case 'a':
+ case 'A':
+ incr = 7;
+ break;
}
for (unsigned int k = start; k < end; k += incr) {
switch (cmd) {
- case 'm': // moveto - Start a new sub-path (relative)
- currentX += points->at(k + 0);
- currentY += points->at(k + 1);
- if (k > start) {
- // According to the spec, if a moveto is followed by multiple
- // pairs of coordinates, the subsequent pairs are treated as
- // implicit lineto commands.
+ case 'm': // moveto - Start a new sub-path (relative)
+ currentX += points->at(k + 0);
+ currentY += points->at(k + 1);
+ if (k > start) {
+ // According to the spec, if a moveto is followed by multiple
+ // pairs of coordinates, the subsequent pairs are treated as
+ // implicit lineto commands.
+ outPath->rLineTo(points->at(k + 0), points->at(k + 1));
+ } else {
+ outPath->rMoveTo(points->at(k + 0), points->at(k + 1));
+ currentSegmentStartX = currentX;
+ currentSegmentStartY = currentY;
+ }
+ break;
+ case 'M': // moveto - Start a new sub-path
+ currentX = points->at(k + 0);
+ currentY = points->at(k + 1);
+ if (k > start) {
+ // According to the spec, if a moveto is followed by multiple
+ // pairs of coordinates, the subsequent pairs are treated as
+ // implicit lineto commands.
+ outPath->lineTo(points->at(k + 0), points->at(k + 1));
+ } else {
+ outPath->moveTo(points->at(k + 0), points->at(k + 1));
+ currentSegmentStartX = currentX;
+ currentSegmentStartY = currentY;
+ }
+ break;
+ case 'l': // lineto - Draw a line from the current point (relative)
outPath->rLineTo(points->at(k + 0), points->at(k + 1));
- } else {
- outPath->rMoveTo(points->at(k + 0), points->at(k + 1));
- currentSegmentStartX = currentX;
- currentSegmentStartY = currentY;
- }
- break;
- case 'M': // moveto - Start a new sub-path
- currentX = points->at(k + 0);
- currentY = points->at(k + 1);
- if (k > start) {
- // According to the spec, if a moveto is followed by multiple
- // pairs of coordinates, the subsequent pairs are treated as
- // implicit lineto commands.
+ currentX += points->at(k + 0);
+ currentY += points->at(k + 1);
+ break;
+ case 'L': // lineto - Draw a line from the current point
outPath->lineTo(points->at(k + 0), points->at(k + 1));
- } else {
- outPath->moveTo(points->at(k + 0), points->at(k + 1));
- currentSegmentStartX = currentX;
- currentSegmentStartY = currentY;
- }
- break;
- case 'l': // lineto - Draw a line from the current point (relative)
- outPath->rLineTo(points->at(k + 0), points->at(k + 1));
- currentX += points->at(k + 0);
- currentY += points->at(k + 1);
- break;
- case 'L': // lineto - Draw a line from the current point
- outPath->lineTo(points->at(k + 0), points->at(k + 1));
- currentX = points->at(k + 0);
- currentY = points->at(k + 1);
- break;
- case 'h': // horizontal lineto - Draws a horizontal line (relative)
- outPath->rLineTo(points->at(k + 0), 0);
- currentX += points->at(k + 0);
- break;
- case 'H': // horizontal lineto - Draws a horizontal line
- outPath->lineTo(points->at(k + 0), currentY);
- currentX = points->at(k + 0);
- break;
- case 'v': // vertical lineto - Draws a vertical line from the current point (r)
- outPath->rLineTo(0, points->at(k + 0));
- currentY += points->at(k + 0);
- break;
- case 'V': // vertical lineto - Draws a vertical line from the current point
- outPath->lineTo(currentX, points->at(k + 0));
- currentY = points->at(k + 0);
- break;
- case 'c': // curveto - Draws a cubic Bézier curve (relative)
- outPath->rCubicTo(points->at(k + 0), points->at(k + 1), points->at(k + 2), points->at(k + 3),
- points->at(k + 4), points->at(k + 5));
+ currentX = points->at(k + 0);
+ currentY = points->at(k + 1);
+ break;
+ case 'h': // horizontal lineto - Draws a horizontal line (relative)
+ outPath->rLineTo(points->at(k + 0), 0);
+ currentX += points->at(k + 0);
+ break;
+ case 'H': // horizontal lineto - Draws a horizontal line
+ outPath->lineTo(points->at(k + 0), currentY);
+ currentX = points->at(k + 0);
+ break;
+ case 'v': // vertical lineto - Draws a vertical line from the current point (r)
+ outPath->rLineTo(0, points->at(k + 0));
+ currentY += points->at(k + 0);
+ break;
+ case 'V': // vertical lineto - Draws a vertical line from the current point
+ outPath->lineTo(currentX, points->at(k + 0));
+ currentY = points->at(k + 0);
+ break;
+ case 'c': // curveto - Draws a cubic Bézier curve (relative)
+ outPath->rCubicTo(points->at(k + 0), points->at(k + 1), points->at(k + 2),
+ points->at(k + 3), points->at(k + 4), points->at(k + 5));
- ctrlPointX = currentX + points->at(k + 2);
- ctrlPointY = currentY + points->at(k + 3);
- currentX += points->at(k + 4);
- currentY += points->at(k + 5);
+ ctrlPointX = currentX + points->at(k + 2);
+ ctrlPointY = currentY + points->at(k + 3);
+ currentX += points->at(k + 4);
+ currentY += points->at(k + 5);
- break;
- case 'C': // curveto - Draws a cubic Bézier curve
- outPath->cubicTo(points->at(k + 0), points->at(k + 1), points->at(k + 2), points->at(k + 3),
- points->at(k + 4), points->at(k + 5));
- currentX = points->at(k + 4);
- currentY = points->at(k + 5);
- ctrlPointX = points->at(k + 2);
- ctrlPointY = points->at(k + 3);
- break;
- case 's': // smooth curveto - Draws a cubic Bézier curve (reflective cp)
- reflectiveCtrlPointX = 0;
- reflectiveCtrlPointY = 0;
- if (previousCmd == 'c' || previousCmd == 's'
- || previousCmd == 'C' || previousCmd == 'S') {
- reflectiveCtrlPointX = currentX - ctrlPointX;
- reflectiveCtrlPointY = currentY - ctrlPointY;
- }
- outPath->rCubicTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
- points->at(k + 0), points->at(k + 1),
- points->at(k + 2), points->at(k + 3));
- ctrlPointX = currentX + points->at(k + 0);
- ctrlPointY = currentY + points->at(k + 1);
- currentX += points->at(k + 2);
- currentY += points->at(k + 3);
- break;
- case 'S': // shorthand/smooth curveto Draws a cubic Bézier curve(reflective cp)
- reflectiveCtrlPointX = currentX;
- reflectiveCtrlPointY = currentY;
- if (previousCmd == 'c' || previousCmd == 's'
- || previousCmd == 'C' || previousCmd == 'S') {
- reflectiveCtrlPointX = 2 * currentX - ctrlPointX;
- reflectiveCtrlPointY = 2 * currentY - ctrlPointY;
- }
- outPath->cubicTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
- points->at(k + 0), points->at(k + 1), points->at(k + 2), points->at(k + 3));
- ctrlPointX = points->at(k + 0);
- ctrlPointY = points->at(k + 1);
- currentX = points->at(k + 2);
- currentY = points->at(k + 3);
- break;
- case 'q': // Draws a quadratic Bézier (relative)
- outPath->rQuadTo(points->at(k + 0), points->at(k + 1), points->at(k + 2), points->at(k + 3));
- ctrlPointX = currentX + points->at(k + 0);
- ctrlPointY = currentY + points->at(k + 1);
- currentX += points->at(k + 2);
- currentY += points->at(k + 3);
- break;
- case 'Q': // Draws a quadratic Bézier
- outPath->quadTo(points->at(k + 0), points->at(k + 1), points->at(k + 2), points->at(k + 3));
- ctrlPointX = points->at(k + 0);
- ctrlPointY = points->at(k + 1);
- currentX = points->at(k + 2);
- currentY = points->at(k + 3);
- break;
- case 't': // Draws a quadratic Bézier curve(reflective control point)(relative)
- reflectiveCtrlPointX = 0;
- reflectiveCtrlPointY = 0;
- if (previousCmd == 'q' || previousCmd == 't'
- || previousCmd == 'Q' || previousCmd == 'T') {
- reflectiveCtrlPointX = currentX - ctrlPointX;
- reflectiveCtrlPointY = currentY - ctrlPointY;
- }
- outPath->rQuadTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
- points->at(k + 0), points->at(k + 1));
- ctrlPointX = currentX + reflectiveCtrlPointX;
- ctrlPointY = currentY + reflectiveCtrlPointY;
- currentX += points->at(k + 0);
- currentY += points->at(k + 1);
- break;
- case 'T': // Draws a quadratic Bézier curve (reflective control point)
- reflectiveCtrlPointX = currentX;
- reflectiveCtrlPointY = currentY;
- if (previousCmd == 'q' || previousCmd == 't'
- || previousCmd == 'Q' || previousCmd == 'T') {
- reflectiveCtrlPointX = 2 * currentX - ctrlPointX;
- reflectiveCtrlPointY = 2 * currentY - ctrlPointY;
- }
- outPath->quadTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
- points->at(k + 0), points->at(k + 1));
- ctrlPointX = reflectiveCtrlPointX;
- ctrlPointY = reflectiveCtrlPointY;
- currentX = points->at(k + 0);
- currentY = points->at(k + 1);
- break;
- case 'a': // Draws an elliptical arc
- // (rx ry x-axis-rotation large-arc-flag sweep-flag x y)
- drawArc(outPath,
- currentX,
- currentY,
- points->at(k + 5) + currentX,
- points->at(k + 6) + currentY,
- points->at(k + 0),
- points->at(k + 1),
- points->at(k + 2),
- points->at(k + 3) != 0,
- points->at(k + 4) != 0);
- currentX += points->at(k + 5);
- currentY += points->at(k + 6);
- ctrlPointX = currentX;
- ctrlPointY = currentY;
- break;
- case 'A': // Draws an elliptical arc
- drawArc(outPath,
- currentX,
- currentY,
- points->at(k + 5),
- points->at(k + 6),
- points->at(k + 0),
- points->at(k + 1),
- points->at(k + 2),
- points->at(k + 3) != 0,
- points->at(k + 4) != 0);
- currentX = points->at(k + 5);
- currentY = points->at(k + 6);
- ctrlPointX = currentX;
- ctrlPointY = currentY;
- break;
- default:
- LOG_ALWAYS_FATAL("Unsupported command: %c", cmd);
- break;
+ break;
+ case 'C': // curveto - Draws a cubic Bézier curve
+ outPath->cubicTo(points->at(k + 0), points->at(k + 1), points->at(k + 2),
+ points->at(k + 3), points->at(k + 4), points->at(k + 5));
+ currentX = points->at(k + 4);
+ currentY = points->at(k + 5);
+ ctrlPointX = points->at(k + 2);
+ ctrlPointY = points->at(k + 3);
+ break;
+ case 's': // smooth curveto - Draws a cubic Bézier curve (reflective cp)
+ reflectiveCtrlPointX = 0;
+ reflectiveCtrlPointY = 0;
+ if (previousCmd == 'c' || previousCmd == 's' || previousCmd == 'C' ||
+ previousCmd == 'S') {
+ reflectiveCtrlPointX = currentX - ctrlPointX;
+ reflectiveCtrlPointY = currentY - ctrlPointY;
+ }
+ outPath->rCubicTo(reflectiveCtrlPointX, reflectiveCtrlPointY, points->at(k + 0),
+ points->at(k + 1), points->at(k + 2), points->at(k + 3));
+ ctrlPointX = currentX + points->at(k + 0);
+ ctrlPointY = currentY + points->at(k + 1);
+ currentX += points->at(k + 2);
+ currentY += points->at(k + 3);
+ break;
+ case 'S': // shorthand/smooth curveto Draws a cubic Bézier curve(reflective cp)
+ reflectiveCtrlPointX = currentX;
+ reflectiveCtrlPointY = currentY;
+ if (previousCmd == 'c' || previousCmd == 's' || previousCmd == 'C' ||
+ previousCmd == 'S') {
+ reflectiveCtrlPointX = 2 * currentX - ctrlPointX;
+ reflectiveCtrlPointY = 2 * currentY - ctrlPointY;
+ }
+ outPath->cubicTo(reflectiveCtrlPointX, reflectiveCtrlPointY, points->at(k + 0),
+ points->at(k + 1), points->at(k + 2), points->at(k + 3));
+ ctrlPointX = points->at(k + 0);
+ ctrlPointY = points->at(k + 1);
+ currentX = points->at(k + 2);
+ currentY = points->at(k + 3);
+ break;
+ case 'q': // Draws a quadratic Bézier (relative)
+ outPath->rQuadTo(points->at(k + 0), points->at(k + 1), points->at(k + 2),
+ points->at(k + 3));
+ ctrlPointX = currentX + points->at(k + 0);
+ ctrlPointY = currentY + points->at(k + 1);
+ currentX += points->at(k + 2);
+ currentY += points->at(k + 3);
+ break;
+ case 'Q': // Draws a quadratic Bézier
+ outPath->quadTo(points->at(k + 0), points->at(k + 1), points->at(k + 2),
+ points->at(k + 3));
+ ctrlPointX = points->at(k + 0);
+ ctrlPointY = points->at(k + 1);
+ currentX = points->at(k + 2);
+ currentY = points->at(k + 3);
+ break;
+ case 't': // Draws a quadratic Bézier curve(reflective control point)(relative)
+ reflectiveCtrlPointX = 0;
+ reflectiveCtrlPointY = 0;
+ if (previousCmd == 'q' || previousCmd == 't' || previousCmd == 'Q' ||
+ previousCmd == 'T') {
+ reflectiveCtrlPointX = currentX - ctrlPointX;
+ reflectiveCtrlPointY = currentY - ctrlPointY;
+ }
+ outPath->rQuadTo(reflectiveCtrlPointX, reflectiveCtrlPointY, points->at(k + 0),
+ points->at(k + 1));
+ ctrlPointX = currentX + reflectiveCtrlPointX;
+ ctrlPointY = currentY + reflectiveCtrlPointY;
+ currentX += points->at(k + 0);
+ currentY += points->at(k + 1);
+ break;
+ case 'T': // Draws a quadratic Bézier curve (reflective control point)
+ reflectiveCtrlPointX = currentX;
+ reflectiveCtrlPointY = currentY;
+ if (previousCmd == 'q' || previousCmd == 't' || previousCmd == 'Q' ||
+ previousCmd == 'T') {
+ reflectiveCtrlPointX = 2 * currentX - ctrlPointX;
+ reflectiveCtrlPointY = 2 * currentY - ctrlPointY;
+ }
+ outPath->quadTo(reflectiveCtrlPointX, reflectiveCtrlPointY, points->at(k + 0),
+ points->at(k + 1));
+ ctrlPointX = reflectiveCtrlPointX;
+ ctrlPointY = reflectiveCtrlPointY;
+ currentX = points->at(k + 0);
+ currentY = points->at(k + 1);
+ break;
+ case 'a': // Draws an elliptical arc
+ // (rx ry x-axis-rotation large-arc-flag sweep-flag x y)
+ drawArc(outPath, currentX, currentY, points->at(k + 5) + currentX,
+ points->at(k + 6) + currentY, points->at(k + 0), points->at(k + 1),
+ points->at(k + 2), points->at(k + 3) != 0, points->at(k + 4) != 0);
+ currentX += points->at(k + 5);
+ currentY += points->at(k + 6);
+ ctrlPointX = currentX;
+ ctrlPointY = currentY;
+ break;
+ case 'A': // Draws an elliptical arc
+ drawArc(outPath, currentX, currentY, points->at(k + 5), points->at(k + 6),
+ points->at(k + 0), points->at(k + 1), points->at(k + 2),
+ points->at(k + 3) != 0, points->at(k + 4) != 0);
+ currentX = points->at(k + 5);
+ currentY = points->at(k + 6);
+ ctrlPointX = currentX;
+ ctrlPointY = currentY;
+ break;
+ default:
+ LOG_ALWAYS_FATAL("Unsupported command: %c", cmd);
+ break;
}
previousCmd = cmd;
}
}
-} // namespace uirenderer
-} // namespace android
+} // namespace uirenderer
+} // namespace android
diff --git a/libs/hwui/utils/VectorDrawableUtils.h b/libs/hwui/utils/VectorDrawableUtils.h
index b5ef510..4be48fb 100644
--- a/libs/hwui/utils/VectorDrawableUtils.h
+++ b/libs/hwui/utils/VectorDrawableUtils.h
@@ -20,8 +20,8 @@
#include "VectorDrawable.h"
#include <cutils/compiler.h>
-#include "SkPath.h"
#include <vector>
+#include "SkPath.h"
namespace android {
namespace uirenderer {
@@ -30,11 +30,11 @@
public:
ANDROID_API static bool canMorph(const PathData& morphFrom, const PathData& morphTo);
ANDROID_API static bool interpolatePathData(PathData* outData, const PathData& morphFrom,
- const PathData& morphTo, float fraction);
+ const PathData& morphTo, float fraction);
ANDROID_API static void verbsToPath(SkPath* outPath, const PathData& data);
static void interpolatePaths(PathData* outPathData, const PathData& from, const PathData& to,
- float fraction);
+ float fraction);
};
-} // namespace uirenderer
-} // namespace android
+} // namespace uirenderer
+} // namespace android
#endif /* ANDROID_HWUI_VECTORDRAWABLE_UTILS_H*/