[SurfaceFlinger] Remove unused clz.h
The built-in method clz is no longer used anywhere in SurfaceFlinger, thus
remove this file and change all usage of min/max/swap to standard methods.
BUG: 112585051
Test: Build, flash
Change-Id: Ia5b47afae1ecbbda3c60d19de62ff9c76db743a4
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index e724666..2c91da0 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -23,7 +23,6 @@
#include "Colorizer.h"
#include "DisplayDevice.h"
#include "LayerRejecter.h"
-#include "clz.h"
#include "RenderEngine/RenderEngine.h"
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index 6c339b7..6dd29ba 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -16,7 +16,6 @@
#include "BufferQueueLayer.h"
#include "LayerRejecter.h"
-#include "clz.h"
#include <system/window.h>
@@ -449,7 +448,7 @@
status_t BufferQueueLayer::setDefaultBufferProperties(uint32_t w, uint32_t h, PixelFormat format) {
uint32_t const maxSurfaceDims =
- min(mFlinger->getMaxTextureSize(), mFlinger->getMaxViewportDims());
+ std::min(mFlinger->getMaxTextureSize(), mFlinger->getMaxViewportDims());
// never allow a surface larger than what our underlying GL implementation
// can handle.
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index 44fa760..276e0e1 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -21,7 +21,6 @@
#include "BufferStateLayer.h"
#include "RenderEngine/Image.h"
-#include "clz.h"
#include <private/gui/SyncFeatures.h>
@@ -401,13 +400,13 @@
uint32_t bufferHeight = s.buffer->height;
if (s.transform & Transform::ROT_90) {
- swap(bufferWidth, bufferHeight);
+ std::swap(bufferWidth, bufferHeight);
}
if (s.transformToDisplayInverse) {
uint32_t invTransform = DisplayDevice::getPrimaryDisplayOrientationTransform();
if (invTransform & Transform::ROT_90) {
- swap(bufferWidth, bufferHeight);
+ std::swap(bufferWidth, bufferHeight);
}
}
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 4d2b0ea..54c0dbe 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -44,7 +44,6 @@
#include "DisplayHardware/HWC2.h"
#include "RenderEngine/RenderEngine.h"
-#include "clz.h"
#include "DisplayDevice.h"
#include "SurfaceFlinger.h"
#include "Layer.h"
@@ -582,7 +581,7 @@
if (R.getOrientation() & Transform::ROT_90) {
// viewport is always specified in the logical orientation
// of the display (ie: post-rotation).
- swap(viewport.right, viewport.bottom);
+ std::swap(viewport.right, viewport.bottom);
}
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 2a07074..35cbda0 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -50,7 +50,6 @@
#include "LayerRejecter.h"
#include "MonitoredProducer.h"
#include "SurfaceFlinger.h"
-#include "clz.h"
#include "DisplayHardware/HWComposer.h"
diff --git a/services/surfaceflinger/LayerRejecter.cpp b/services/surfaceflinger/LayerRejecter.cpp
index 70558d4..bd59d17 100644
--- a/services/surfaceflinger/LayerRejecter.cpp
+++ b/services/surfaceflinger/LayerRejecter.cpp
@@ -19,8 +19,6 @@
#include <gui/BufferItem.h>
#include <system/window.h>
-#include "clz.h"
-
#define DEBUG_RESIZE 0
namespace android {
@@ -53,13 +51,13 @@
// check that we received a buffer of the right size
// (Take the buffer's orientation into account)
if (item.mTransform & Transform::ROT_90) {
- swap(bufWidth, bufHeight);
+ std::swap(bufWidth, bufHeight);
}
if (mTransformToDisplayInverse) {
uint32_t invTransform = DisplayDevice::getPrimaryDisplayOrientationTransform();
if (invTransform & Transform::ROT_90) {
- swap(bufWidth, bufHeight);
+ std::swap(bufWidth, bufHeight);
}
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 41c7f22..0e88fa0 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -75,7 +75,6 @@
#include "LayerVector.h"
#include "MonitoredProducer.h"
#include "SurfaceFlinger.h"
-#include "clz.h"
#include "DisplayHardware/ComposerHal.h"
#include "DisplayHardware/DisplayIdentification.h"
diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp
index e05ed53..bc9e5cd 100644
--- a/services/surfaceflinger/Transform.cpp
+++ b/services/surfaceflinger/Transform.cpp
@@ -21,7 +21,6 @@
#include <ui/Region.h>
#include "Transform.h"
-#include "clz.h"
// ---------------------------------------------------------------------------
@@ -137,7 +136,7 @@
Transform H, V, R;
if (flags & ROT_90) {
// w & h are inverted when rotating by 90 degrees
- swap(w, h);
+ std::swap(w, h);
}
if (flags & FLIP_H) {
@@ -210,15 +209,15 @@
rb = transform(rb);
if (roundOutwards) {
- r.left = floorf(min(lt[0], rt[0], lb[0], rb[0]));
- r.top = floorf(min(lt[1], rt[1], lb[1], rb[1]));
- r.right = ceilf(max(lt[0], rt[0], lb[0], rb[0]));
- r.bottom = ceilf(max(lt[1], rt[1], lb[1], rb[1]));
+ r.left = floorf(std::min({lt[0], rt[0], lb[0], rb[0]}));
+ r.top = floorf(std::min({lt[1], rt[1], lb[1], rb[1]}));
+ r.right = ceilf(std::max({lt[0], rt[0], lb[0], rb[0]}));
+ r.bottom = ceilf(std::max({lt[1], rt[1], lb[1], rb[1]}));
} else {
- r.left = floorf(min(lt[0], rt[0], lb[0], rb[0]) + 0.5f);
- r.top = floorf(min(lt[1], rt[1], lb[1], rb[1]) + 0.5f);
- r.right = floorf(max(lt[0], rt[0], lb[0], rb[0]) + 0.5f);
- r.bottom = floorf(max(lt[1], rt[1], lb[1], rb[1]) + 0.5f);
+ r.left = floorf(std::min({lt[0], rt[0], lb[0], rb[0]}) + 0.5f);
+ r.top = floorf(std::min({lt[1], rt[1], lb[1], rb[1]}) + 0.5f);
+ r.right = floorf(std::max({lt[0], rt[0], lb[0], rb[0]}) + 0.5f);
+ r.bottom = floorf(std::max({lt[1], rt[1], lb[1], rb[1]}) + 0.5f);
}
return r;
@@ -237,10 +236,10 @@
rb = transform(rb);
FloatRect r;
- r.left = min(lt[0], rt[0], lb[0], rb[0]);
- r.top = min(lt[1], rt[1], lb[1], rb[1]);
- r.right = max(lt[0], rt[0], lb[0], rb[0]);
- r.bottom = max(lt[1], rt[1], lb[1], rb[1]);
+ r.left = std::min({lt[0], rt[0], lb[0], rb[0]});
+ r.top = std::min({lt[1], rt[1], lb[1], rb[1]});
+ r.right = std::max({lt[0], rt[0], lb[0], rb[0]});
+ r.bottom = std::max({lt[1], rt[1], lb[1], rb[1]});
return r;
}
diff --git a/services/surfaceflinger/clz.h b/services/surfaceflinger/clz.h
deleted file mode 100644
index a4c5262..0000000
--- a/services/surfaceflinger/clz.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2007 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 ANDROID_SURFACE_FLINGER_CLZ_H
-
-#include <stdint.h>
-
-namespace android {
-
-int inline clz(int32_t x) {
- return __builtin_clz(x);
-}
-
-template <typename T>
-static inline T min(T a, T b) {
- return a<b ? a : b;
-}
-template <typename T>
-static inline T min(T a, T b, T c) {
- return min(a, min(b, c));
-}
-template <typename T>
-static inline T min(T a, T b, T c, T d) {
- return min(a, b, min(c, d));
-}
-
-template <typename T>
-static inline T max(T a, T b) {
- return a>b ? a : b;
-}
-template <typename T>
-static inline T max(T a, T b, T c) {
- return max(a, max(b, c));
-}
-template <typename T>
-static inline T max(T a, T b, T c, T d) {
- return max(a, b, max(c, d));
-}
-
-template <typename T>
-static inline
-void swap(T& a, T& b) {
- T t(a);
- a = b;
- b = t;
-}
-
-
-}; // namespace android
-
-#endif /* ANDROID_SURFACE_FLINGER_CLZ_H */