summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-08-08 16:05:42 -0700
committerRomain Guy <romainguy@google.com>2012-08-08 16:05:42 -0700
commit320d46bf844b84351cb80c5d4a4768d86447ac81 (patch)
treefee65370216aee9df6116a46ebae0edfd8de1272 /libs/hwui
parentc89b14bba0f6cc2c91629080617f7ed215f697f3 (diff)
downloadframeworks_base-320d46bf844b84351cb80c5d4a4768d86447ac81.zip
frameworks_base-320d46bf844b84351cb80c5d4a4768d86447ac81.tar.gz
frameworks_base-320d46bf844b84351cb80c5d4a4768d86447ac81.tar.bz2
Reduce gradients textures size whenever possible
Change-Id: Ifd58625ee62edac3b5d20b77553cb98b6fa2b46e
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/GradientCache.cpp9
-rw-r--r--libs/hwui/ProgramCache.cpp16
2 files changed, 14 insertions, 11 deletions
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp
index b1c4dfe..726b57c7 100644
--- a/libs/hwui/GradientCache.cpp
+++ b/libs/hwui/GradientCache.cpp
@@ -18,6 +18,7 @@
#include <utils/threads.h>
+#include "Caches.h"
#include "Debug.h"
#include "GradientCache.h"
#include "Properties.h"
@@ -128,9 +129,13 @@ void GradientCache::clear() {
void GradientCache::getGradientInfo(const uint32_t* colors, const int count,
GradientInfo& info) {
- uint32_t width = 1 << (31 - __builtin_clz(256 * (count - 1)));
- bool hasAlpha = false;
+ uint32_t width = 256 * (count - 1);
+
+ if (!Caches::getInstance().extensions.hasNPot()) {
+ width = 1 << (31 - __builtin_clz(width));
+ }
+ bool hasAlpha = false;
for (int i = 0; i < count; i++) {
if (((colors[i] >> 24) & 0xff) < 255) {
hasAlpha = true;
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 0e77cb2..d67bfbe 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -69,12 +69,10 @@ const char* gVS_Header_Varyings_HasBitmap =
"varying highp vec2 outBitmapTexCoords;\n";
const char* gVS_Header_Varyings_PointHasBitmap =
"varying highp vec2 outPointBitmapTexCoords;\n";
-// TODO: These values are used to sample from textures,
-// they may need to be highp
const char* gVS_Header_Varyings_HasGradient[6] = {
// Linear
"varying highp vec2 linear;\n",
- "varying highp float linear;\n",
+ "varying float linear;\n",
// Circular
"varying highp vec2 circular;\n",
@@ -268,21 +266,21 @@ const char* gFS_Main_FetchA8Texture[2] = {
};
const char* gFS_Main_FetchGradient[6] = {
// Linear
- " highp vec4 gradientColor = texture2D(gradientSampler, linear);\n",
+ " vec4 gradientColor = texture2D(gradientSampler, linear);\n",
- " highp vec4 gradientColor = mix(startColor, endColor, clamp(linear, 0.0, 1.0));\n",
+ " vec4 gradientColor = mix(startColor, endColor, clamp(linear, 0.0, 1.0));\n",
// Circular
- " highp vec4 gradientColor = texture2D(gradientSampler, vec2(length(circular), 0.5));\n",
+ " vec4 gradientColor = texture2D(gradientSampler, vec2(length(circular), 0.5));\n",
- " highp vec4 gradientColor = mix(startColor, endColor, clamp(length(circular), 0.0, 1.0));\n",
+ " vec4 gradientColor = mix(startColor, endColor, clamp(length(circular), 0.0, 1.0));\n",
// Sweep
" highp float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n"
- " highp vec4 gradientColor = texture2D(gradientSampler, vec2(index - floor(index), 0.5));\n",
+ " vec4 gradientColor = texture2D(gradientSampler, vec2(index - floor(index), 0.5));\n",
" highp float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n"
- " highp vec4 gradientColor = mix(startColor, endColor, clamp(index - floor(index), 0.0, 1.0));\n"
+ " vec4 gradientColor = mix(startColor, endColor, clamp(index - floor(index), 0.0, 1.0));\n"
};
const char* gFS_Main_FetchBitmap =
" vec4 bitmapColor = texture2D(bitmapSampler, outBitmapTexCoords);\n";