Reland "Remove use of legacy display globals."
This is a reland of c1916c34febe0c6f9805b5d9fc18349ec8b74008
As it turns out, benches are not always given a canvas.
Original change's description:
> Remove use of legacy display globals.
>
> In the ongoing effort to remove the display globals from Skia, allow
> their use only if SK_LEGACY_SURFACE_PROPS is defined. Do not define this
> in a normal Skia build and remove all use from Skia code.
>
> Change-Id: I9ff550f5db246b9024aac687a1bc01321f1be4c8
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319343
> Reviewed-by: Herb Derby <herb@google.com>
> Commit-Queue: Ben Wagner <bungeman@google.com>
Change-Id: I61a2ac058fafc99653e3304876cf4b97350dac8b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322490
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/bench/GlyphQuadFillBench.cpp b/bench/GlyphQuadFillBench.cpp
index 680a16c..01f9886 100644
--- a/bench/GlyphQuadFillBench.cpp
+++ b/bench/GlyphQuadFillBench.cpp
@@ -43,7 +43,8 @@
auto glyphRunList = builder.useGlyphRunList();
SkASSERT(!glyphRunList.empty());
fBlob = GrTextBlob::Make(glyphRunList, view);
- SkSurfaceProps props{SkSurfaceProps::kLegacyFontHost_InitType};
+ SkSurfaceProps props;
+ if (canvas) { canvas->getProps(&props); }
auto colorSpace = SkColorSpace::MakeSRGB();
SkGlyphRunListPainter painter{props, kUnknown_SkColorType,
colorSpace.get(), SkStrikeCache::GlobalStrikeCache()};
diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp
index 695c40c..dded96e 100644
--- a/bench/SkGlyphCacheBench.cpp
+++ b/bench/SkGlyphCacheBench.cpp
@@ -220,8 +220,9 @@
bool isSuitableFor(Backend b) override { return b == kNonRendering_Backend; }
- void onDraw(int loops, SkCanvas*) override {
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ void onDraw(int loops, SkCanvas* modelCanvas) override {
+ SkSurfaceProps props;
+ if (modelCanvas) { modelCanvas->getProps(&props); }
SkTextBlobCacheDiffCanvas canvas{1024, 1024, props, fServer.get()};
loops *= 100;
while (loops --> 0) {
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 3966c83..a293cb2 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -251,7 +251,7 @@
this->factory = std::make_unique<GrContextFactory>(options);
uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag :
0;
- SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps props(flags, kRGB_H_SkPixelGeometry);
this->surface = SkSurface::MakeRenderTarget(
this->factory->get(this->config.ctxType, this->config.ctxOverrides),
SkBudgeted::kNo, info, this->config.samples, &props);
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 88a0d9e..9c1c124 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1474,7 +1474,7 @@
SkImageInfo info = SkImageInfo::Make(size, fColorType, fAlphaType, fColorSpace);
uint32_t flags = fUseDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
- SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps props(flags, kRGB_H_SkPixelGeometry);
switch (fSurfType) {
case SkCommandLineConfigGpu::SurfType::kDefault:
@@ -2122,7 +2122,7 @@
dst->allocPixelsFlags(SkImageInfo::Make(size, fColorType, alphaType, fColorSpace),
SkBitmap::kZeroPixels_AllocFlag);
- SkCanvas canvas(*dst);
+ SkCanvas canvas(*dst, SkSurfaceProps(0, kRGB_H_SkPixelGeometry));
return src.draw(nullptr, &canvas);
}
diff --git a/example/SkiaSDLExample.cpp b/example/SkiaSDLExample.cpp
index 95c0828..793416f 100644
--- a/example/SkiaSDLExample.cpp
+++ b/example/SkiaSDLExample.cpp
@@ -229,8 +229,8 @@
// setup SkSurface
// To use distance field text, use commented out SkSurfaceProps instead
// SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
- // SkSurfaceProps::kLegacyFontHost_InitType);
- SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ // SkSurfaceProps::kUnknown_SkPixelGeometry);
+ SkSurfaceProps props;
sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(grContext.get(), target,
kBottomLeft_GrSurfaceOrigin,
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index a1f6c84..1f2c568 100644
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -61,8 +61,10 @@
SkISize size = onISize();
SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType,
inputCanvas->imageInfo().refColorSpace());
- SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
- SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps inputProps;
+ inputCanvas->getProps(&inputProps);
+ SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | inputProps.flags(),
+ inputProps.pixelGeometry());
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props));
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
diff --git a/gm/dftext_blob_persp.cpp b/gm/dftext_blob_persp.cpp
index 9e50628..f401a1b 100644
--- a/gm/dftext_blob_persp.cpp
+++ b/gm/dftext_blob_persp.cpp
@@ -66,8 +66,10 @@
}
SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType,
inputCanvas->imageInfo().refColorSpace());
- SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
- SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps inputProps;
+ inputCanvas->getProps(&inputProps);
+ SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | inputProps.flags(),
+ inputProps.pixelGeometry());
auto surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index 91c3d63..670a826 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -72,7 +72,8 @@
canvas->drawRect(r, p);
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- auto surface(ToolUtils::makeSurface(canvas, info));
+ SkSurfaceProps props = SkSurfaceProps(0, kRGB_H_SkPixelGeometry);
+ auto surface(ToolUtils::makeSurface(canvas, info, &props));
SkCanvas* surfCanvas = surface->getCanvas();
this->drawColumn(surfCanvas, SK_ColorBLACK, SK_ColorWHITE, false);
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index b891c8f..edba3b8 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -110,8 +110,11 @@
sk_sp<SkColorSpace> colorSpace = inputCanvas->imageInfo().refColorSpace();
SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(),
kPremul_SkAlphaType, colorSpace);
- SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag,
- SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps inputProps;
+ inputCanvas->getProps(&inputProps);
+ SkSurfaceProps props(
+ SkSurfaceProps::kUseDeviceIndependentFonts_Flag | inputProps.flags(),
+ inputProps.pixelGeometry());
surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 8287ce6..b3004ce 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -178,7 +178,7 @@
explicit SkCanvas(sk_sp<SkBaseDevice> device);
/** Constructs a canvas that draws into bitmap.
- Sets SkSurfaceProps::kLegacyFontHost_InitType in constructed SkSurface.
+ Sets kUnknown_SkPixelGeometry in constructed SkSurface.
SkBitmap is copied so that subsequently editing bitmap will not affect
constructed SkCanvas.
diff --git a/include/core/SkFontLCDConfig.h b/include/core/SkFontLCDConfig.h
index 1d40b82..e63d98c 100644
--- a/include/core/SkFontLCDConfig.h
+++ b/include/core/SkFontLCDConfig.h
@@ -10,6 +10,7 @@
#include "include/core/SkTypes.h"
+#ifdef SK_LEGACY_SURFACE_PROPS
class SK_API SkFontLCDConfig {
public:
/** LCDs either have their color elements arranged horizontally or
@@ -54,5 +55,6 @@
/** @deprecated get from Device. */
static LCDOrder GetSubpixelOrder();
};
+#endif
#endif
diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h
index 9d7f4e1..de8daaa 100644
--- a/include/core/SkSurfaceProps.h
+++ b/include/core/SkSurfaceProps.h
@@ -56,13 +56,18 @@
/** Deprecated alias used by Chromium. Will be removed. */
static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag;
+#ifndef SK_LEGACY_SURFACE_PROPS
+ SkSurfaceProps();
+#endif
SkSurfaceProps(uint32_t flags, SkPixelGeometry);
+#ifdef SK_LEGACY_SURFACE_PROPS
enum InitType {
kLegacyFontHost_InitType
};
SkSurfaceProps(InitType);
SkSurfaceProps(uint32_t flags, InitType);
+#endif
SkSurfaceProps(const SkSurfaceProps&);
SkSurfaceProps& operator=(const SkSurfaceProps&);
@@ -81,7 +86,9 @@
return !(*this == that);
}
private:
+#ifdef SK_LEGACY_SURFACE_PROPS
SkSurfaceProps();
+#endif
uint32_t fFlags;
SkPixelGeometry fPixelGeometry;
diff --git a/samplecode/SampleTextureUpload.cpp b/samplecode/SampleTextureUpload.cpp
index 39f82d8..026cb4a 100644
--- a/samplecode/SampleTextureUpload.cpp
+++ b/samplecode/SampleTextureUpload.cpp
@@ -32,7 +32,7 @@
class RenderTargetTexture : public SkRefCnt {
public:
RenderTargetTexture(GrDirectContext* direct, int size) {
- SkSurfaceProps surfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps surfaceProps(0, kRGB_H_SkPixelGeometry);
SkImageInfo imageInfo = SkImageInfo::Make(size, size, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
fSurface = SkSurface::MakeRenderTarget(direct, SkBudgeted::kNo, imageInfo, 0,
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index e7a2792..200e345 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -213,7 +213,11 @@
}
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap)
+#ifdef SK_LEGACY_SURFACE_PROPS
: INHERITED(bitmap.info(), SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType))
+#else
+ : INHERITED(bitmap.info(), SkSurfaceProps())
+#endif
, fBitmap(bitmap)
, fRCStack(bitmap.width(), bitmap.height())
, fGlyphPainter(this->surfaceProps(),
@@ -224,7 +228,11 @@
}
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) {
+#ifdef SK_LEGACY_SURFACE_PROPS
return Create(info, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType));
+#else
+ return Create(info, SkSurfaceProps());
+#endif
}
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps,
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 20fa4cb..222c6f4 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -523,7 +523,11 @@
SkCanvas::SkCanvas()
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
+#ifdef SK_LEGACY_SURFACE_PROPS
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
+#else
+ , fProps()
+#endif
{
inc_canvas();
@@ -541,7 +545,11 @@
SkCanvas::SkCanvas(const SkIRect& bounds)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
+#ifdef SK_LEGACY_SURFACE_PROPS
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
+#else
+ , fProps()
+#endif
{
inc_canvas();
@@ -571,7 +579,11 @@
SkCanvas::SkCanvas(const SkBitmap& bitmap, std::unique_ptr<SkRasterHandleAllocator> alloc,
SkRasterHandleAllocator::Handle hndl)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
+#ifdef SK_LEGACY_SURFACE_PROPS
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
+#else
+ , fProps()
+#endif
, fAllocator(std::move(alloc))
{
inc_canvas();
@@ -584,9 +596,7 @@
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
SkCanvas::SkCanvas(const SkBitmap& bitmap, ColorBehavior)
- : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
- , fProps(SkSurfaceProps::kLegacyFontHost_InitType)
- , fAllocator(nullptr)
+ : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)), fProps(), fAllocator(nullptr)
{
inc_canvas();
diff --git a/src/core/SkFontLCDConfig.cpp b/src/core/SkFontLCDConfig.cpp
index f902e2c..ff9c606 100644
--- a/src/core/SkFontLCDConfig.cpp
+++ b/src/core/SkFontLCDConfig.cpp
@@ -7,6 +7,7 @@
#include "include/core/SkFontLCDConfig.h"
+#ifdef SK_LEGACY_SURFACE_PROPS
static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHorizontal_LCDOrientation;
static SkFontLCDConfig::LCDOrder gLCDOrder = SkFontLCDConfig::kRGB_LCDOrder;
@@ -25,3 +26,4 @@
void SkFontLCDConfig::SetSubpixelOrder(LCDOrder order) {
gLCDOrder = order;
}
+#endif
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 735ea19..49999c0 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -316,7 +316,11 @@
SkScalerContextEffects* effects) {
SkPaint paint;
return MakeRecAndEffects(
+#ifdef SK_LEGACY_SURFACE_PROPS
font, paint, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
+#else
+ font, paint, SkSurfaceProps(),
+#endif
SkScalerContextFlags::kNone, SkMatrix::I(), rec, effects);
}
diff --git a/src/core/SkStrikeSpec.cpp b/src/core/SkStrikeSpec.cpp
index 95a5148..d64527d 100644
--- a/src/core/SkStrikeSpec.cpp
+++ b/src/core/SkStrikeSpec.cpp
@@ -102,7 +102,11 @@
storage.commonSetup(*canonicalizedFont,
canonicalizedPaint,
+#ifdef SK_LEGACY_SURFACE_PROPS
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
+#else
+ SkSurfaceProps(),
+#endif
kFakeGammaAndBoostContrast,
SkMatrix::I());
return storage;
@@ -118,7 +122,11 @@
storage.commonSetup(font,
setupPaint,
+#ifdef SK_LEGACY_SURFACE_PROPS
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
+#else
+ SkSurfaceProps(),
+#endif
kFakeGammaAndBoostContrast,
SkMatrix::I());
diff --git a/src/core/SkSurfacePriv.h b/src/core/SkSurfacePriv.h
index 6e5ff09..f3e6f55 100644
--- a/src/core/SkSurfacePriv.h
+++ b/src/core/SkSurfacePriv.h
@@ -16,7 +16,11 @@
if (props) {
return *props;
} else {
+#ifdef SK_LEGACY_SURFACE_PROPS
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
+#else
+ return SkSurfaceProps();
+#endif
}
}
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index 72e2de6..f7620d6 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -15,6 +15,9 @@
#include "src/image/SkRescaleAndReadPixels.h"
#include "src/image/SkSurface_Base.h"
+SkSurfaceProps::SkSurfaceProps() : fFlags(0), fPixelGeometry(kUnknown_SkPixelGeometry) {}
+
+#ifdef SK_LEGACY_SURFACE_PROPS
static SkPixelGeometry compute_default_geometry() {
SkFontLCDConfig::LCDOrder order = SkFontLCDConfig::GetSubpixelOrder();
if (SkFontLCDConfig::kNONE_LCDOrder == order) {
@@ -39,14 +42,13 @@
}
}
-SkSurfaceProps::SkSurfaceProps() : fFlags(0), fPixelGeometry(kUnknown_SkPixelGeometry) {}
-
SkSurfaceProps::SkSurfaceProps(InitType) : fFlags(0), fPixelGeometry(compute_default_geometry()) {}
SkSurfaceProps::SkSurfaceProps(uint32_t flags, InitType)
: fFlags(flags)
, fPixelGeometry(compute_default_geometry())
{}
+#endif
SkSurfaceProps::SkSurfaceProps(uint32_t flags, SkPixelGeometry pg)
: fFlags(flags), fPixelGeometry(pg)
diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp
index 9635a0a..eb5edb7 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -248,7 +248,7 @@
const SkPaint paint;
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(
10, 10, props, &server, ctxInfo.directContext()->supportsDistanceFieldText());
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -273,7 +273,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server);
SkPaint paint;
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -307,7 +307,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server);
SkPaint paint;
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -344,7 +344,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server);
SkPaint paint;
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -383,7 +383,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server);
SkPaint paint;
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -410,7 +410,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server);
SkPaint paint;
REPORTER_ASSERT(reporter, server.remoteStrikeMapSizeForTesting() == 0u);
@@ -431,7 +431,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server);
SkPaint paint;
REPORTER_ASSERT(reporter, server.remoteStrikeMapSizeForTesting() == 1u);
@@ -693,7 +693,7 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props;
SkTextBlobCacheDiffCanvas cache_diff_canvas(
10, 10, props, &server, direct->supportsDistanceFieldText());
cache_diff_canvas.concat(matrix);
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index c02a9d1..19d0113 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -67,7 +67,7 @@
bool stressTest) {
// setup surface
uint32_t flags = 0;
- SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps props(flags, kRGB_H_SkPixelGeometry);
// configure our context for maximum stressing of cache and atlas
if (stressTest) {
diff --git a/tests/VkProtectedContextTest.cpp b/tests/VkProtectedContextTest.cpp
index 878de67..440a770 100644
--- a/tests/VkProtectedContextTest.cpp
+++ b/tests/VkProtectedContextTest.cpp
@@ -31,7 +31,7 @@
REPORTER_ASSERT(reporter, backendTex.isValid());
REPORTER_ASSERT(reporter, backendTex.isProtected());
- SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps surfaceProps = SkSurfaceProps(0, kRGB_H_SkPixelGeometry);
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(
dContext, backendTex, kTopLeft_GrSurfaceOrigin, 1,
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
@@ -69,7 +69,7 @@
REPORTER_ASSERT(reporter, backendTex.isValid());
REPORTER_ASSERT(reporter, backendTex.isProtected());
- SkSurfaceProps surfaceProps = SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps surfaceProps = SkSurfaceProps(0, kRGB_H_SkPixelGeometry);
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
dContext, backendTex, kTopLeft_GrSurfaceOrigin, 1,
kRGBA_8888_SkColorType, nullptr, &surfaceProps);
diff --git a/tools/fm/fm.cpp b/tools/fm/fm.cpp
index b47c5f9..3cba25e 100644
--- a/tools/fm/fm.cpp
+++ b/tools/fm/fm.cpp
@@ -306,7 +306,7 @@
uint32_t flags = FLAGS_dit ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag
: 0;
- SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps props(flags, kRGB_H_SkPixelGeometry);
sk_sp<SkSurface> surface;
GrBackendTexture backendTexture;
diff --git a/tools/remote_demo.cpp b/tools/remote_demo.cpp
index 35ca41b..3dc6216 100644
--- a/tools/remote_demo.cpp
+++ b/tools/remote_demo.cpp
@@ -135,7 +135,7 @@
static bool push_font_data(const SkPicture& pic, SkStrikeServer* strikeServer,
sk_sp<SkColorSpace> colorSpace, int writeFd) {
const SkIRect bounds = pic.cullRect().round();
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props(0, kRGB_H_SkPixelGeometry);
SkTextBlobCacheDiffCanvas filter(bounds.width(), bounds.height(), props,
strikeServer, std::move(colorSpace), true);
pic.playback(&filter);
diff --git a/tools/sk_app/DisplayParams.h b/tools/sk_app/DisplayParams.h
index afad8e1..c6a3e3d 100644
--- a/tools/sk_app/DisplayParams.h
+++ b/tools/sk_app/DisplayParams.h
@@ -18,7 +18,7 @@
: fColorType(kN32_SkColorType)
, fColorSpace(nullptr)
, fMSAASampleCount(1)
- , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
+ , fSurfaceProps(0, kRGB_H_SkPixelGeometry)
, fDisableVsync(false)
{}
diff --git a/tools/skottie_ios_app/SkMetalViewBridge.mm b/tools/skottie_ios_app/SkMetalViewBridge.mm
index dd5de64..7f1ca2b 100644
--- a/tools/skottie_ios_app/SkMetalViewBridge.mm
+++ b/tools/skottie_ios_app/SkMetalViewBridge.mm
@@ -22,7 +22,7 @@
const SkColorType colorType = kBGRA_8888_SkColorType; // MTLPixelFormatBGRA8Unorm
sk_sp<SkColorSpace> colorSpace = nullptr; // MTLPixelFormatBGRA8Unorm
const GrSurfaceOrigin origin = kTopLeft_GrSurfaceOrigin;
- const SkSurfaceProps surfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps surfaceProps;
int sampleCount = (int)[mtkView sampleCount];
return SkSurface::MakeFromMTKView(rContext, (__bridge GrMTLHandle)mtkView, origin, sampleCount,
diff --git a/tools/skottie_ios_app/SkiaGLContext.mm b/tools/skottie_ios_app/SkiaGLContext.mm
index 916e3f4..9c3f5e4 100644
--- a/tools/skottie_ios_app/SkiaGLContext.mm
+++ b/tools/skottie_ios_app/SkiaGLContext.mm
@@ -25,7 +25,7 @@
static sk_sp<SkSurface> make_gl_surface(GrDirectContext* dContext, int width, int height) {
static constexpr int kStencilBits = 8;
static constexpr int kSampleCount = 1;
- static const SkSurfaceProps surfaceProps = SkSurfaceProps::kLegacyFontHost_InitType;
+ static const SkSurfaceProps surfaceProps;
if (!dContext || width <= 0 || height <= 0) {
return nullptr;
}
diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp
index 5a7527b..15d8cbb 100644
--- a/tools/skpbench/skpbench.cpp
+++ b/tools/skpbench/skpbench.cpp
@@ -590,7 +590,7 @@
SkImageInfo::Make(width, height, config->getColorType(), config->getAlphaType(),
sk_ref_sp(config->getColorSpace()));
uint32_t flags = config->getUseDIText() ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
- SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps props(flags, kRGB_H_SkPixelGeometry);
sk_sp<SkSurface> surface =
SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, config->getSamples(), &props);
if (!surface) {
diff --git a/tools/skqp/src/skqp.cpp b/tools/skqp/src/skqp.cpp
index 48216e0..20a7e75 100644
--- a/tools/skqp/src/skqp.cpp
+++ b/tools/skqp/src/skqp.cpp
@@ -289,7 +289,7 @@
const int h = size.height();
const SkImageInfo info =
SkImageInfo::Make(w, h, skqp::kColorType, kPremul_SkAlphaType, nullptr);
- const SkSurfaceProps props(0, SkSurfaceProps::kLegacyFontHost_InitType);
+ const SkSurfaceProps props(0, kRGB_H_SkPixelGeometry);
sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(
testCtx->makeContext(context_options(gm.get())).get(),
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index daafba4..61c68a0 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -369,6 +369,7 @@
displayParams.fGrContextOptions.fShaderErrorHandler = &gShaderErrorHandler;
displayParams.fGrContextOptions.fSuppressPrints = true;
fWindow->setRequestedDisplayParams(displayParams);
+ fDisplay = fWindow->getRequestedDisplayParams();
fRefresh = FLAGS_redraw;
// Configure timers
@@ -493,8 +494,9 @@
fCommands.addCommand('G', "Modes", "Geometry", [this]() {
DisplayParams params = fWindow->getRequestedDisplayParams();
uint32_t flags = params.fSurfaceProps.flags();
- if (!fPixelGeometryOverrides) {
- fPixelGeometryOverrides = true;
+ SkPixelGeometry defaultPixelGeometry = fDisplay.fSurfaceProps.pixelGeometry();
+ if (!fDisplayOverrides.fSurfaceProps.fPixelGeometry) {
+ fDisplayOverrides.fSurfaceProps.fPixelGeometry = true;
params.fSurfaceProps = SkSurfaceProps(flags, kUnknown_SkPixelGeometry);
} else {
switch (params.fSurfaceProps.pixelGeometry()) {
@@ -511,8 +513,8 @@
params.fSurfaceProps = SkSurfaceProps(flags, kBGR_V_SkPixelGeometry);
break;
case kBGR_V_SkPixelGeometry:
- params.fSurfaceProps = SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
- fPixelGeometryOverrides = false;
+ params.fSurfaceProps = SkSurfaceProps(flags, defaultPixelGeometry);
+ fDisplayOverrides.fSurfaceProps.fPixelGeometry = false;
break;
}
}
@@ -1022,7 +1024,7 @@
}
const DisplayParams& params = fWindow->getRequestedDisplayParams();
- if (fPixelGeometryOverrides) {
+ if (fDisplayOverrides.fSurfaceProps.fPixelGeometry) {
switch (params.fSurfaceProps.pixelGeometry()) {
case kUnknown_SkPixelGeometry:
title.append( " Flat");
@@ -1410,7 +1412,7 @@
}
auto make_surface = [=](int w, int h) {
- SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ SkSurfaceProps props(fWindow->getRequestedDisplayParams().fSurfaceProps);
slideCanvas->getProps(&props);
SkImageInfo info = SkImageInfo::Make(w, h, colorType, kPremul_SkAlphaType, colorSpace);
@@ -1828,7 +1830,7 @@
}
int pixelGeometryIdx = 0;
- if (fPixelGeometryOverrides) {
+ if (fDisplayOverrides.fSurfaceProps.fPixelGeometry) {
pixelGeometryIdx = params.fSurfaceProps.pixelGeometry() + 1;
}
if (ImGui::Combo("Pixel Geometry", &pixelGeometryIdx,
@@ -1836,10 +1838,11 @@
{
uint32_t flags = params.fSurfaceProps.flags();
if (pixelGeometryIdx == 0) {
- fPixelGeometryOverrides = false;
- params.fSurfaceProps = SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
+ fDisplayOverrides.fSurfaceProps.fPixelGeometry = false;
+ SkPixelGeometry pixelGeometry = fDisplay.fSurfaceProps.pixelGeometry();
+ params.fSurfaceProps = SkSurfaceProps(flags, pixelGeometry);
} else {
- fPixelGeometryOverrides = true;
+ fDisplayOverrides.fSurfaceProps.fPixelGeometry = true;
SkPixelGeometry pixelGeometry = SkTo<SkPixelGeometry>(pixelGeometryIdx - 1);
params.fSurfaceProps = SkSurfaceProps(flags, pixelGeometry);
}
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index 47913ae..52d4493 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -92,6 +92,18 @@
bool fStyle = false;
bool fFilterQuality = false;
};
+ struct SkSurfacePropsFields {
+ bool fFlags = false;
+ bool fPixelGeometry = false;
+ };
+ struct DisplayFields {
+ bool fColorType = false;
+ bool fColorSpace = false;
+ bool fMSAASampleCount = false;
+ bool fGrContextOptions = false;
+ SkSurfacePropsFields fSurfaceProps;
+ bool fDisableVsync = false;
+ };
private:
enum class ColorMode {
kLegacy, // 8888, no color management
@@ -190,11 +202,18 @@
SkTArray<std::function<void(void)>> fDeferredActions;
+ // fPaint contains override values, fPaintOverrides controls if overrides are applied.
SkPaint fPaint;
SkPaintFields fPaintOverrides;
+
+ // fFont contains override values, fFontOverrides controls if overrides are applied.
SkFont fFont;
SkFontFields fFontOverrides;
- bool fPixelGeometryOverrides = false;
+
+ // fDisplay contains default values (fWindow.fRequestedDisplayParams contains the overrides),
+ // fDisplayOverrides controls if overrides are applied.
+ sk_app::DisplayParams fDisplay;
+ DisplayFields fDisplayOverrides;
struct CachedShader {
bool fHovered = false;