From 4bb942083a0d4db746adf95349108dd8ef842e32 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 12 Oct 2010 15:59:26 -0700 Subject: Optimize 9patch rendering. This change detects empty quads in 9patches and removes them from the mesh to avoid unnecessary blending. Change-Id: I4500566fb4cb6845d64dcb59b522c0be7a0ec704 --- libs/hwui/utils/Compare.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libs/hwui/utils/Compare.h (limited to 'libs/hwui/utils') diff --git a/libs/hwui/utils/Compare.h b/libs/hwui/utils/Compare.h new file mode 100644 index 0000000..754b470 --- /dev/null +++ b/libs/hwui/utils/Compare.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 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_UI_COMPARE_H +#define ANDROID_UI_COMPARE_H + +#include + +#define EPSILON 0.00001f + +#define almost(u, v) (fabs((u) - (v)) < EPSILON) + +/** + * Compare floats. + */ +#define compare(a) \ + if (a < rhs.a) return true; \ + if (almost(a, rhs.a)) + +/** + * Compare integers. + */ +#define compareI(a) \ + if (a < rhs.a) return true; \ + if (a == rhs.a) + +#endif // ANDROID_UI_COMPARE_H -- cgit v1.1