diff options
Diffstat (limited to 'libs/hwui/utils')
-rw-r--r-- | libs/hwui/utils/PaintUtils.h | 64 | ||||
-rw-r--r-- | libs/hwui/utils/SortedList.h | 14 | ||||
-rw-r--r-- | libs/hwui/utils/SortedListImpl.h | 2 | ||||
-rw-r--r-- | libs/hwui/utils/Timing.h | 4 |
4 files changed, 74 insertions, 10 deletions
diff --git a/libs/hwui/utils/PaintUtils.h b/libs/hwui/utils/PaintUtils.h new file mode 100644 index 0000000..fa0ae03 --- /dev/null +++ b/libs/hwui/utils/PaintUtils.h @@ -0,0 +1,64 @@ +/* + * 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 + +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 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/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); |