|
29 | 29 | #include "src/gpu/ops/GrMeshDrawOp.h" |
30 | 30 | #include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h" |
31 | 31 |
|
32 | | -#define ATLAS_TEXTURE_WIDTH 2048 |
33 | | -#define ATLAS_TEXTURE_HEIGHT 2048 |
34 | | -#define PLOT_WIDTH 512 |
35 | | -#define PLOT_HEIGHT 256 |
36 | | - |
37 | | -#define NUM_PLOTS_X (ATLAS_TEXTURE_WIDTH / PLOT_WIDTH) |
38 | | -#define NUM_PLOTS_Y (ATLAS_TEXTURE_HEIGHT / PLOT_HEIGHT) |
| 32 | +static constexpr size_t kMaxAtlasTextureBytes = 2048 * 2048; |
| 33 | +static constexpr size_t kPlotWidth = 512; |
| 34 | +static constexpr size_t kPlotHeight = 256; |
39 | 35 |
|
40 | 36 | #ifdef DF_PATH_TRACKING |
41 | 37 | static int g_NumCachedShapes = 0; |
42 | 38 | static int g_NumFreedShapes = 0; |
43 | 39 | #endif |
44 | 40 |
|
45 | 41 | // mip levels |
46 | | -static const SkScalar kIdealMinMIP = 12; |
47 | | -static const SkScalar kMaxMIP = 162; |
| 42 | +static constexpr SkScalar kIdealMinMIP = 12; |
| 43 | +static constexpr SkScalar kMaxMIP = 162; |
48 | 44 |
|
49 | | -static const SkScalar kMaxDim = 73; |
50 | | -static const SkScalar kMinSize = SK_ScalarHalf; |
51 | | -static const SkScalar kMaxSize = 2*kMaxMIP; |
| 45 | +static constexpr SkScalar kMaxDim = 73; |
| 46 | +static constexpr SkScalar kMinSize = SK_ScalarHalf; |
| 47 | +static constexpr SkScalar kMaxSize = 2*kMaxMIP; |
52 | 48 |
|
53 | 49 | class ShapeDataKey { |
54 | 50 | public: |
@@ -893,13 +889,13 @@ bool GrSmallPathRenderer::onDrawPath(const DrawPathArgs& args) { |
893 | 889 | if (!fAtlas) { |
894 | 890 | const GrBackendFormat format = args.fContext->priv().caps()->getDefaultBackendFormat( |
895 | 891 | GrColorType::kAlpha_8, GrRenderable::kNo); |
896 | | - fAtlas = GrDrawOpAtlas::Make(args.fContext->priv().proxyProvider(), |
897 | | - format, |
898 | | - GrColorType::kAlpha_8, |
899 | | - ATLAS_TEXTURE_WIDTH, ATLAS_TEXTURE_HEIGHT, |
900 | | - PLOT_WIDTH, PLOT_HEIGHT, |
901 | | - GrDrawOpAtlas::AllowMultitexturing::kYes, |
902 | | - this); |
| 892 | + |
| 893 | + GrDrawOpAtlasConfig atlasConfig(args.fContext->priv().caps()->maxTextureSize(), |
| 894 | + kMaxAtlasTextureBytes); |
| 895 | + SkISize size = atlasConfig.atlasDimensions(kA8_GrMaskFormat); |
| 896 | + fAtlas = GrDrawOpAtlas::Make(args.fContext->priv().proxyProvider(), format, |
| 897 | + GrColorType::kAlpha_8, size.width(), size.height(), kPlotWidth, |
| 898 | + kPlotHeight, GrDrawOpAtlas::AllowMultitexturing::kYes, this); |
903 | 899 | if (!fAtlas) { |
904 | 900 | return false; |
905 | 901 | } |
@@ -981,12 +977,13 @@ GR_DRAW_OP_TEST_DEFINE(SmallPathOp) { |
981 | 977 | gTestStruct.reset(); |
982 | 978 | const GrBackendFormat format = context->priv().caps()->getDefaultBackendFormat( |
983 | 979 | GrColorType::kAlpha_8, GrRenderable::kNo); |
984 | | - gTestStruct.fAtlas = GrDrawOpAtlas::Make(context->priv().proxyProvider(), |
985 | | - format, GrColorType::kAlpha_8, |
986 | | - ATLAS_TEXTURE_WIDTH, ATLAS_TEXTURE_HEIGHT, |
987 | | - PLOT_WIDTH, PLOT_HEIGHT, |
988 | | - GrDrawOpAtlas::AllowMultitexturing::kYes, |
989 | | - &gTestStruct); |
| 980 | + GrDrawOpAtlasConfig atlasConfig(context->priv().caps()->maxTextureSize(), |
| 981 | + kMaxAtlasTextureBytes); |
| 982 | + SkISize size = atlasConfig.atlasDimensions(kA8_GrMaskFormat); |
| 983 | + gTestStruct.fAtlas = |
| 984 | + GrDrawOpAtlas::Make(context->priv().proxyProvider(), format, GrColorType::kAlpha_8, |
| 985 | + size.width(), size.height(), kPlotWidth, kPlotHeight, |
| 986 | + GrDrawOpAtlas::AllowMultitexturing::kYes, &gTestStruct); |
990 | 987 | } |
991 | 988 |
|
992 | 989 | SkMatrix viewMatrix = GrTest::TestMatrix(random); |
|
0 commit comments