diff options
| author | 2019-06-19 17:25:12 +0000 | |
|---|---|---|
| committer | 2019-06-19 17:25:12 +0000 | |
| commit | f1218eebee9163173823e1edb5e25c1a33a775ea (patch) | |
| tree | 2c9c5b85faa3b724fa8f9d6f2c76149edc8b0d64 /services/surfaceflinger/RegionSamplingThread.cpp | |
| parent | 7fbb0831bf1f803e8faa9e34e43efdd6b0dc05c7 (diff) | |
| parent | d0b44a52f815fb20cb470aca8ac17da498797c1e (diff) | |
Merge "sf: optimize luma sampling code" into qt-r1-dev
Diffstat (limited to 'services/surfaceflinger/RegionSamplingThread.cpp')
| -rw-r--r-- | services/surfaceflinger/RegionSamplingThread.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 66906e950c..8b85d4cdbf 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -258,7 +258,7 @@ void RegionSamplingThread::binderDied(const wp<IBinder>& who) { namespace { // Using Rec. 709 primaries -float getLuma(float r, float g, float b) { +inline float getLuma(float r, float g, float b) { constexpr auto rec709_red_primary = 0.2126f; constexpr auto rec709_green_primary = 0.7152f; constexpr auto rec709_blue_primary = 0.0722f; @@ -293,10 +293,10 @@ float sampleArea(const uint32_t* data, int32_t width, int32_t height, int32_t st const uint32_t* rowBase = data + row * stride; for (int32_t column = area.left; column < area.right; ++column) { uint32_t pixel = rowBase[column]; - const float r = (pixel & 0xFF) / 255.0f; - const float g = ((pixel >> 8) & 0xFF) / 255.0f; - const float b = ((pixel >> 16) & 0xFF) / 255.0f; - const uint8_t luma = std::round(getLuma(r, g, b) * 255.0f); + const float r = pixel & 0xFF; + const float g = (pixel >> 8) & 0xFF; + const float b = (pixel >> 16) & 0xFF; + const uint8_t luma = std::round(getLuma(r, g, b)); ++brightnessBuckets[luma]; if (brightnessBuckets[luma] > majoritySampleNum) return luma / 255.0f; } |