Merge "Add a debug assert to track down infinite loop"
This commit is contained in:
@@ -252,7 +252,8 @@ LOCAL_SRC_FILES += \
|
||||
tests/unit/SkiaBehaviorTests.cpp \
|
||||
tests/unit/StringUtilsTests.cpp \
|
||||
tests/unit/TextDropShadowCacheTests.cpp \
|
||||
tests/unit/VectorDrawableTests.cpp
|
||||
tests/unit/VectorDrawableTests.cpp \
|
||||
tests/unit/GradientCacheTests.cpp
|
||||
|
||||
ifeq (true, $(HWUI_NEW_OPS))
|
||||
LOCAL_SRC_FILES += \
|
||||
|
||||
@@ -168,10 +168,13 @@ Texture* GradientCache::addLinearGradient(GradientCacheEntry& gradient,
|
||||
texture->blend = info.hasAlpha;
|
||||
texture->generation = 1;
|
||||
|
||||
// Asume the cache is always big enough
|
||||
// Assume the cache is always big enough
|
||||
const uint32_t size = info.width * 2 * bytesPerPixel();
|
||||
while (getSize() + size > mMaxSize) {
|
||||
mCache.removeOldest();
|
||||
LOG_ALWAYS_FATAL_IF(!mCache.removeOldest(),
|
||||
"Ran out of things to remove from the cache? getSize() = %" PRIu32
|
||||
", size = %" PRIu32 ", mMaxSize = %" PRIu32 ", width = %" PRIu32,
|
||||
getSize(), size, mMaxSize, info.width);
|
||||
}
|
||||
|
||||
generateTexture(colors, positions, info.width, 2, texture);
|
||||
|
||||
40
libs/hwui/tests/unit/GradientCacheTests.cpp
Normal file
40
libs/hwui/tests/unit/GradientCacheTests.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "Extensions.h"
|
||||
#include "GradientCache.h"
|
||||
#include "tests/common/TestUtils.h"
|
||||
|
||||
using namespace android;
|
||||
using namespace android::uirenderer;
|
||||
|
||||
RENDERTHREAD_TEST(GradientCache, addRemove) {
|
||||
Extensions extensions;
|
||||
GradientCache cache(extensions);
|
||||
cache.setMaxSize(5000);
|
||||
|
||||
SkColor colors[] = { 0xFF00FF00, 0xFFFF0000, 0xFF0000FF };
|
||||
float positions[] = { 1, 2, 3 };
|
||||
Texture* texture = cache.get(colors, positions, 3);
|
||||
ASSERT_TRUE(texture);
|
||||
ASSERT_FALSE(texture->cleanup);
|
||||
ASSERT_EQ((uint32_t) texture->objectSize(), cache.getSize());
|
||||
ASSERT_TRUE(cache.getSize());
|
||||
cache.clear();
|
||||
ASSERT_EQ(cache.getSize(), 0u);
|
||||
}
|
||||
Reference in New Issue
Block a user