aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-08-21 11:08:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-21 11:08:00 -0700
commit7f9c9eb91e65f2d83474f2b34f9ed0d9525245ae (patch)
treef7ddc67b3aaff9cdeb9fb4ecde3b67875b2b1b0d
parentd2b23e0ee6dcb366540b12d13552120289ee3da0 (diff)
wire up reduced atlas and zero textblob cache to test
-rw-r--r--src/gpu/GrTest.cpp26
-rw-r--r--src/gpu/GrTest.h8
-rw-r--r--src/gpu/GrTextBlobCache.h3
-rw-r--r--tests/TextBlobCacheTest.cpp28
4 files changed, 56 insertions, 9 deletions
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index a2efb4829b..2b03238ab4 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -8,6 +8,7 @@
#include "GrTest.h"
+#include "GrBatchAtlas.h"
#include "GrBatchFontCache.h"
#include "GrBufferedDrawTarget.h"
#include "GrContextOptions.h"
@@ -16,6 +17,31 @@
#include "GrTextBlobCache.h"
#include "SkString.h"
+namespace GrTest {
+void SetupAlwaysEvictAtlas(GrContext* context) {
+ // These sizes were selected because they allow each atlas to hold a single plot and will thus
+ // stress the atlas
+ int dim = GrBatchAtlas::kGlyphMaxDim;
+ GrBatchAtlasConfig configs[3];
+ configs[kA8_GrMaskFormat].fWidth = dim;
+ configs[kA8_GrMaskFormat].fHeight = dim;
+ configs[kA8_GrMaskFormat].fPlotWidth = dim;
+ configs[kA8_GrMaskFormat].fPlotHeight = dim;
+
+ configs[kA565_GrMaskFormat].fWidth = dim;
+ configs[kA565_GrMaskFormat].fHeight = dim;
+ configs[kA565_GrMaskFormat].fPlotWidth = dim;
+ configs[kA565_GrMaskFormat].fPlotHeight = dim;
+
+ configs[kARGB_GrMaskFormat].fWidth = dim;
+ configs[kARGB_GrMaskFormat].fHeight = dim;
+ configs[kARGB_GrMaskFormat].fPlotWidth = dim;
+ configs[kARGB_GrMaskFormat].fPlotHeight = dim;
+
+ context->setTextContextAtlasSizes_ForTesting(configs);
+}
+};
+
void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) {
SkASSERT(!fContext);
diff --git a/src/gpu/GrTest.h b/src/gpu/GrTest.h
index eb1d7de25d..92bfb13750 100644
--- a/src/gpu/GrTest.h
+++ b/src/gpu/GrTest.h
@@ -13,6 +13,14 @@
#include "GrDrawTarget.h"
#include "gl/GrGLContext.h"
+namespace GrTest {
+ /**
+ * Forces the GrContext to use a small atlas which only has room for one plot and will thus
+ * constantly be evicting entries
+ */
+ void SetupAlwaysEvictAtlas(GrContext*);
+};
+
/** Allows a test to temporarily draw to a GrDrawTarget owned by a GrContext. Tests that use this
should be careful not to mix using the GrDrawTarget directly and drawing via SkCanvas or
GrContext. In the future this object may provide some guards to prevent this. */
diff --git a/src/gpu/GrTextBlobCache.h b/src/gpu/GrTextBlobCache.h
index ac9ee2bf25..ee1f0d9211 100644
--- a/src/gpu/GrTextBlobCache.h
+++ b/src/gpu/GrTextBlobCache.h
@@ -117,8 +117,7 @@ private:
if (fPool.size() > fBudget) {
BitmapBlobList::Iter iter;
iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart);
- GrAtlasTextBlob* lruBlob = iter.get();
- SkASSERT(lruBlob);
+ GrAtlasTextBlob* lruBlob = NULL;
while (fPool.size() > fBudget && (lruBlob = iter.get()) && lruBlob != blob) {
fCache.remove(lruBlob->fKey);
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index c063040ecf..6f67382a0f 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -6,6 +6,7 @@
*/
#include "sk_tool_utils.h"
+
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPoint.h"
@@ -24,6 +25,7 @@
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
+#include "GrTest.h"
struct TextBlobWrapper {
// This class assumes it 'owns' the textblob it wraps, and thus does not need to take a ref
@@ -51,13 +53,21 @@ static const int kHeight = 768;
// This test hammers the GPU textblobcache and font atlas
static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContextFactory* factory,
- int maxTotalText, int maxGlyphID, int maxFamilies, bool normal) {
+ int maxTotalText, int maxGlyphID, int maxFamilies, bool normal,
+ bool stressTest) {
// setup surface
uint32_t flags = 0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
// We don't typically actually draw with this unittest
GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType);
+
+ // configure our context for maximum stressing of cache and atlas
+ if (stressTest) {
+ GrTest::SetupAlwaysEvictAtlas(ctx);
+ ctx->setTextBlobCacheLimit_ForTesting(0);
+ }
+
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPremul_SkAlphaType);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info,
0, &props));
@@ -151,14 +161,18 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContextFactory
}
DEF_GPUTEST(TextBlobCache, reporter, factory) {
- text_blob_cache_inner(reporter, factory, 4096, 256, 30, true);
+ text_blob_cache_inner(reporter, factory, 1024, 256, 30, true, false);
+}
+
+DEF_GPUTEST(TextBlobStressCache, reporter, factory) {
+ text_blob_cache_inner(reporter, factory, 256, 256, 10, true, true);
}
DEF_GPUTEST(TextBlobAbnormal, reporter, factory) {
-#ifdef SK_BUILD_FOR_ANDROID
- text_blob_cache_inner(reporter, factory, 256, 256, 30, false);
-#else
- text_blob_cache_inner(reporter, factory, 512, 256, 30, false);
-#endif
+ text_blob_cache_inner(reporter, factory, 256, 256, 10, false, false);
+}
+
+DEF_GPUTEST(TextBlobStressAbnormal, reporter, factory) {
+ text_blob_cache_inner(reporter, factory, 256, 256, 10, false, true);
}
#endif