summaryrefslogtreecommitdiffstats
path: root/libs/hwui/utils
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/utils')
-rw-r--r--libs/hwui/utils/Macros.h4
-rw-r--r--libs/hwui/utils/PaintUtils.h74
-rw-r--r--libs/hwui/utils/Pair.h2
-rw-r--r--libs/hwui/utils/SortedList.h14
-rw-r--r--libs/hwui/utils/SortedListImpl.h2
-rw-r--r--libs/hwui/utils/Timing.h4
6 files changed, 88 insertions, 12 deletions
diff --git a/libs/hwui/utils/Macros.h b/libs/hwui/utils/Macros.h
index 5b7c87c..fe43fdb 100644
--- a/libs/hwui/utils/Macros.h
+++ b/libs/hwui/utils/Macros.h
@@ -18,8 +18,8 @@
#define PREVENT_COPY_AND_ASSIGN(Type) \
private: \
- Type(const Type&); \
- void operator=(const Type&)
+ Type(const Type&) = delete; \
+ void operator=(const Type&) = delete
#define DESCRIPTION_TYPE(Type) \
int compare(const Type& rhs) const { return memcmp(this, &rhs, sizeof(Type));} \
diff --git a/libs/hwui/utils/PaintUtils.h b/libs/hwui/utils/PaintUtils.h
new file mode 100644
index 0000000..679e2bf
--- /dev/null
+++ b/libs/hwui/utils/PaintUtils.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef PAINT_UTILS_H
+#define PAINT_UTILS_H
+
+#include <SkColorFilter.h>
+#include <SkXfermode.h>
+
+namespace android {
+namespace uirenderer {
+
+class PaintUtils {
+public:
+
+ /**
+ * Safely retrieves the mode from the specified xfermode. If the specified
+ * xfermode is null, the mode is assumed to be SkXfermode::kSrcOver_Mode.
+ */
+ static inline SkXfermode::Mode getXfermode(SkXfermode* mode) {
+ SkXfermode::Mode resultMode;
+ if (!SkXfermode::AsMode(mode, &resultMode)) {
+ resultMode = SkXfermode::kSrcOver_Mode;
+ }
+ return resultMode;
+ }
+
+ // TODO: move to a method on android:Paint? replace with SkPaint::nothingToDraw()?
+ static inline bool paintWillNotDraw(const SkPaint& paint) {
+ return paint.getAlpha() == 0
+ && !paint.getColorFilter()
+ && getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode;
+ }
+
+ // TODO: move to a method on android:Paint? replace with SkPaint::nothingToDraw()?
+ static inline bool paintWillNotDrawText(const SkPaint& paint) {
+ return paint.getAlpha() == 0
+ && paint.getLooper() == nullptr
+ && !paint.getColorFilter()
+ && getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode;
+ }
+
+ static bool isBlendedShader(const SkShader* shader) {
+ if (shader == nullptr) {
+ return false;
+ }
+ return !shader->isOpaque();
+ }
+
+ static bool isBlendedColorFilter(const SkColorFilter* filter) {
+ if (filter == nullptr) {
+ return false;
+ }
+ return (filter->getFlags() & SkColorFilter::kAlphaUnchanged_Flag) == 0;
+ }
+
+}; // class PaintUtils
+
+} /* namespace uirenderer */
+} /* namespace android */
+
+#endif /* PAINT_UTILS_H */
diff --git a/libs/hwui/utils/Pair.h b/libs/hwui/utils/Pair.h
index 172606a..0db3aa3 100644
--- a/libs/hwui/utils/Pair.h
+++ b/libs/hwui/utils/Pair.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_HWUI_PAIR_H
#define ANDROID_HWUI_PAIR_H
+#include <utils/TypeHelpers.h>
+
namespace android {
namespace uirenderer {
diff --git a/libs/hwui/utils/SortedList.h b/libs/hwui/utils/SortedList.h
index 2fa890a..a2c8c52 100644
--- a/libs/hwui/utils/SortedList.h
+++ b/libs/hwui/utils/SortedList.h
@@ -93,13 +93,13 @@ public:
}
protected:
- virtual void do_construct(void* storage, size_t num) const;
- virtual void do_destroy(void* storage, size_t num) const;
- virtual void do_copy(void* dest, const void* from, size_t num) const;
- virtual void do_splat(void* dest, const void* item, size_t num) const;
- virtual void do_move_forward(void* dest, const void* from, size_t num) const;
- virtual void do_move_backward(void* dest, const void* from, size_t num) const;
- virtual int do_compare(const void* lhs, const void* rhs) const;
+ virtual void do_construct(void* storage, size_t num) const override;
+ virtual void do_destroy(void* storage, size_t num) const override;
+ virtual void do_copy(void* dest, const void* from, size_t num) const override;
+ virtual void do_splat(void* dest, const void* item, size_t num) const override;
+ virtual void do_move_forward(void* dest, const void* from, size_t num) const override;
+ virtual void do_move_backward(void* dest, const void* from, size_t num) const override;
+ virtual int do_compare(const void* lhs, const void* rhs) const override;
}; // class SortedList
///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/utils/SortedListImpl.h b/libs/hwui/utils/SortedListImpl.h
index dc385b5..b101826 100644
--- a/libs/hwui/utils/SortedListImpl.h
+++ b/libs/hwui/utils/SortedListImpl.h
@@ -41,7 +41,7 @@ protected:
virtual int do_compare(const void* lhs, const void* rhs) const = 0;
private:
- ssize_t _indexOrderOf(const void* item, size_t* order = 0) const;
+ ssize_t _indexOrderOf(const void* item, size_t* order = nullptr) const;
// these are made private, because they can't be used on a SortedVector
// (they don't have an implementation either)
diff --git a/libs/hwui/utils/Timing.h b/libs/hwui/utils/Timing.h
index eced987..dd8847a 100644
--- a/libs/hwui/utils/Timing.h
+++ b/libs/hwui/utils/Timing.h
@@ -24,12 +24,12 @@ class MethodTimer {
public:
MethodTimer(const char* name)
: mMethodName(name) {
- gettimeofday(&mStart, NULL);
+ gettimeofday(&mStart, nullptr);
}
~MethodTimer() {
struct timeval stop;
- gettimeofday(&stop, NULL);
+ gettimeofday(&stop, nullptr);
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);