Centralize the predicate for a glyph being too large for the atlas
Centralize the calculation to SkGlyphCacheCommon. This allows this function to be used with NO_GPU. In addition, this was used in the last remaining function in GrTest. That function was used in a single place. I made the function a static and remove GrTest.h. This had massive knock-on effects. Change-Id: I80f874a988f9af4383a83acf7c273d23b8d67c22 Reviewed-on: https://skia-review.googlesource.com/151480 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
20ea47a5d9
commit
d3895d867c
@ -15,7 +15,6 @@
|
||||
#include "GrOpFlushState.h"
|
||||
#include "GrPathUtils.h"
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkGeometry.h"
|
||||
#include "SkPoint3.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrOpFlushState.h"
|
||||
#include "GrPathUtils.h"
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkGeometry.h"
|
||||
#include "SkPointPriv.h"
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
#include "gm.h"
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkImage.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrTest.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkGradientShader.h"
|
||||
|
@ -73,6 +73,8 @@ public:
|
||||
return {lookupX, lookupY};
|
||||
}
|
||||
|
||||
// An atlas consists of plots, and plots hold glyphs. The minimum a plot can be is 256x256.
|
||||
// This means that the maximum size a glyph can be is 256x256.
|
||||
static constexpr uint16_t kSkSideTooBigForAtlas = 256;
|
||||
|
||||
inline static bool GlyphTooBigForAtlas(const SkGlyph& glyph) {
|
||||
|
@ -83,10 +83,6 @@ private:
|
||||
SkAutoTMalloc<SkPoint> fPositions;
|
||||
};
|
||||
|
||||
inline static bool glyph_too_big_for_atlas(const SkGlyph& glyph) {
|
||||
return glyph.fWidth > 256 || glyph.fHeight > 256;
|
||||
}
|
||||
|
||||
inline static SkRect rect_to_draw(
|
||||
const SkGlyph& glyph, SkPoint origin, SkScalar textScale, bool isDFT) {
|
||||
|
||||
@ -146,7 +142,7 @@ void SkGlyphRunListPainter::drawGlyphRunAsBMPWithPathFallback(
|
||||
auto eachGlyph =
|
||||
[perGlyph{std::move(perGlyph)}, perPath{std::move(perPath)}]
|
||||
(const SkGlyph& glyph, SkPoint pt, SkPoint mappedPt) {
|
||||
if (glyph_too_big_for_atlas(glyph)) {
|
||||
if (SkGlyphCacheCommon::GlyphTooBigForAtlas(glyph)) {
|
||||
SkScalar sx = SkScalarFloorToScalar(mappedPt.fX),
|
||||
sy = SkScalarFloorToScalar(mappedPt.fY);
|
||||
|
||||
|
@ -593,11 +593,8 @@ void SkStrikeServer::SkGlyphCacheState::writePendingGlyphs(Serializer* serialize
|
||||
// Glyphs which are too large for the atlas still request images when computing the bounds
|
||||
// for the glyph, which is why its necessary to send both. See related code in
|
||||
// get_packed_glyph_bounds in GrGlyphCache.cpp and crbug.com/510931.
|
||||
bool tooLargeForAtlas = false;
|
||||
#if SK_SUPPORT_GPU
|
||||
tooLargeForAtlas = GrDrawOpAtlas::GlyphTooLargeForAtlas(stationaryGlyph.fWidth,
|
||||
stationaryGlyph.fHeight);
|
||||
#endif
|
||||
bool tooLargeForAtlas = SkGlyphCacheCommon::GlyphTooBigForAtlas(stationaryGlyph);
|
||||
|
||||
if (tooLargeForAtlas) {
|
||||
// Add this to the path cache, since we will always fall back to using paths
|
||||
// for this glyph.
|
||||
@ -793,10 +790,8 @@ bool SkStrikeClient::readStrikeData(const volatile void* memory, size_t memorySi
|
||||
allocatedGlyph->fPathData = glyphPath;
|
||||
}
|
||||
|
||||
bool tooLargeForAtlas = false;
|
||||
#if SK_SUPPORT_GPU
|
||||
tooLargeForAtlas = GrDrawOpAtlas::GlyphTooLargeForAtlas(glyph.fWidth, glyph.fHeight);
|
||||
#endif
|
||||
bool tooLargeForAtlas = SkGlyphCacheCommon::GlyphTooBigForAtlas(glyph);
|
||||
|
||||
if (tooLargeForAtlas) {
|
||||
if (!read_path(&deserializer, allocatedGlyph, strike.get())) READ_FAILURE
|
||||
}
|
||||
|
@ -228,11 +228,6 @@ public:
|
||||
|
||||
void compact(GrDeferredUploadToken startTokenForNextFlush);
|
||||
|
||||
static constexpr auto kGlyphMaxDim = 256;
|
||||
static bool GlyphTooLargeForAtlas(int width, int height) {
|
||||
return width > kGlyphMaxDim || height > kGlyphMaxDim;
|
||||
}
|
||||
|
||||
static uint32_t GetPageIndexFromID(AtlasID id) {
|
||||
return id & 0xff;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrShaderCaps.h"
|
||||
#include "GrSurfacePriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "GrTextureContext.h"
|
||||
#include "GrTexturePriv.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "GrDrawingManager.h"
|
||||
#include "GrPipeline.h"
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrXferProcessor.h"
|
||||
#include "SkChecksum.h"
|
||||
#include "SkRandom.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrSemaphore.h"
|
||||
#include "GrSurfaceProxyPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexturePriv.h"
|
||||
#include "GrTextureProxy.h"
|
||||
#include "SkCanvas.h"
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include "Test.h"
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrContextOptions.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrXferProcessor.h"
|
||||
#include "effects/GrPorterDuffXferProcessor.h"
|
||||
#include "gl/GrGLCaps.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrRenderTarget.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "SkMipMap.h"
|
||||
#include "Test.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrSurfaceProxy.h"
|
||||
#include "GrTest.h"
|
||||
#include "ProxyUtils.h"
|
||||
#include "SkGr.h"
|
||||
#include "Test.h"
|
||||
|
@ -196,7 +196,6 @@ DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrSurfaceProxyPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "GrTextureProxy.h"
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkDeferredDisplayListRecorder.h"
|
||||
#include "SkImage_Gpu.h"
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrSurfacePriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexturePriv.h"
|
||||
#include "GrTextureProxyPriv.h"
|
||||
#include "gl/GLTestContext.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrResourceAllocator.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrSurfaceProxyPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "GrTextureProxy.h"
|
||||
#include "GrUninstantiateProxyTracker.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "GrRenderTargetPriv.h"
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
|
||||
#include "SkCanvas.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrTest.h"
|
||||
#include "Test.h"
|
||||
|
||||
#include "GrBackendSemaphore.h"
|
||||
|
@ -8,13 +8,13 @@
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkData.h"
|
||||
#include "SkDevice.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkFontMgr.h"
|
||||
#include "SkGlyphRun.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPoint.h"
|
||||
@ -25,7 +26,6 @@
|
||||
|
||||
#include "GrContext.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
|
||||
static void draw(SkCanvas* canvas, int redraw, const SkTArray<sk_sp<SkTextBlob>>& blobs) {
|
||||
int yOffset = 0;
|
||||
@ -43,6 +43,29 @@ static void draw(SkCanvas* canvas, int redraw, const SkTArray<sk_sp<SkTextBlob>>
|
||||
static const int kWidth = 1024;
|
||||
static const int kHeight = 768;
|
||||
|
||||
static void setup_always_evict_atlas(GrContext* context) {
|
||||
int dim = SkGlyphCacheCommon::kSkSideTooBigForAtlas;
|
||||
// These sizes were selected because they allow each atlas to hold a single plot and will thus
|
||||
// stress the atlas
|
||||
GrDrawOpAtlasConfig 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->contextPriv().setTextContextAtlasSizes_ForTesting(configs);
|
||||
}
|
||||
|
||||
// This test hammers the GPU textblobcache and font atlas
|
||||
static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* context,
|
||||
int maxTotalText, int maxGlyphID, int maxFamilies, bool normal,
|
||||
@ -53,7 +76,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
|
||||
|
||||
// configure our context for maximum stressing of cache and atlas
|
||||
if (stressTest) {
|
||||
GrTest::SetupAlwaysEvictAtlas(context);
|
||||
setup_always_evict_atlas(context);
|
||||
context->contextPriv().setTextBlobCacheLimit_ForTesting(0);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "GrTextureProxy.h"
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrResourceProvider.h"
|
||||
#include "GrSurfaceProxy.h"
|
||||
#include "GrTexture.h"
|
||||
#include "GrTest.h"
|
||||
#include "SkGr.h"
|
||||
#include "SkSurface.h"
|
||||
#include "Test.h"
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#if defined(SK_VULKAN)
|
||||
|
||||
#include "GrTest.h"
|
||||
#include "Test.h"
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
#if defined(SK_VULKAN)
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "Test.h"
|
||||
#include "vk/GrVkCopyPipeline.h"
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
#if defined(SK_VULKAN)
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrRenderTarget.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
|
||||
#include "Test.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrProxyProvider.h"
|
||||
#include "GrTest.h"
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "GrContext.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "Test.h"
|
||||
|
||||
static SkBitmap read_pixels(sk_sp<SkSurface> surface) {
|
||||
|
@ -23,7 +23,6 @@ DEFINE_double(frame, 1.0, "A double value in [0, 1] that specifies the point in
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
#include "GrTest.h"
|
||||
#include "gl/GLTestContext.h"
|
||||
|
||||
// Globals externed in fiddle_main.h
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "GrResourceCache.h"
|
||||
#include "GrSemaphore.h"
|
||||
#include "GrSurfaceContextPriv.h"
|
||||
#include "GrTest.h"
|
||||
#include "GrTexture.h"
|
||||
#include "SkGr.h"
|
||||
#include "SkImage_Gpu.h"
|
||||
@ -32,32 +31,6 @@
|
||||
#include "text/GrTextBlobCache.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace GrTest {
|
||||
|
||||
void SetupAlwaysEvictAtlas(GrContext* context, int dim) {
|
||||
// These sizes were selected because they allow each atlas to hold a single plot and will thus
|
||||
// stress the atlas
|
||||
GrDrawOpAtlasConfig 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->contextPriv().setTextContextAtlasSizes_ForTesting(configs);
|
||||
}
|
||||
|
||||
} // namespace GrTest
|
||||
|
||||
bool GrSurfaceProxy::isWrapped_ForTesting() const {
|
||||
return SkToBool(fTarget);
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrTest_DEFINED
|
||||
#define GrTest_DEFINED
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawOpAtlas.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*, int dim = GrDrawOpAtlas::kGlyphMaxDim);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user