Reland "Remove use of legacy display globals."

This is a reland of c1916c34fe

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>
This commit is contained in:
Ben Wagner 2020-09-24 14:49:00 -04:00 committed by Skia Commit-Bot
parent 4c3486e6f1
commit ae4bb98f13
32 changed files with 130 additions and 51 deletions

View File

@ -43,7 +43,8 @@ class DirectMaskGlyphVertexFillBenchmark : public Benchmark {
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()};

View File

@ -220,8 +220,9 @@ class DiffCanvasBench : public Benchmark {
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) {

View File

@ -251,7 +251,7 @@ struct GPUTarget : public Target {
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);

View File

@ -1474,7 +1474,7 @@ sk_sp<SkSurface> GPUSink::createDstSurface(GrDirectContext* context, SkISize siz
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 @@ Result RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) co
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);
}

View File

@ -229,8 +229,8 @@ int main(int argc, char** argv) {
// 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,

View File

@ -61,8 +61,10 @@ protected:
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

View File

@ -66,8 +66,10 @@ protected:
}
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

View File

@ -72,7 +72,8 @@ protected:
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);

View File

@ -110,8 +110,11 @@ protected:
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

View File

@ -178,7 +178,7 @@ public:
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.

View File

@ -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 @@ public:
/** @deprecated get from Device. */
static LCDOrder GetSubpixelOrder();
};
#endif
#endif

View File

@ -56,13 +56,18 @@ public:
/** 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 @@ public:
return !(*this == that);
}
private:
#ifdef SK_LEGACY_SURFACE_PROPS
SkSurfaceProps();
#endif
uint32_t fFlags;
SkPixelGeometry fPixelGeometry;

View File

@ -32,7 +32,7 @@ class TextureUploadSample : public Sample {
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,

View File

@ -213,7 +213,11 @@ static bool valid_for_bitmap_device(const SkImageInfo& info,
}
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(const SkBitmap& bitmap)
}
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,

View File

@ -523,7 +523,11 @@ void SkCanvas::init(sk_sp<SkBaseDevice> device) {
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(int width, int height, const SkSurfaceProps* props)
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, const SkSurfaceProps& props)
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 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap, nullptr, nullptr)
#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();

View File

@ -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 @@ SkFontLCDConfig::LCDOrder SkFontLCDConfig::GetSubpixelOrder() {
void SkFontLCDConfig::SetSubpixelOrder(LCDOrder order) {
gLCDOrder = order;
}
#endif

View File

@ -316,7 +316,11 @@ public:
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);
}

View File

@ -102,7 +102,11 @@ SkStrikeSpec SkStrikeSpec::MakeCanonicalized(const SkFont& font, const SkPaint*
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 @@ SkStrikeSpec SkStrikeSpec::MakeWithNoDevice(const SkFont& font, const SkPaint* p
storage.commonSetup(font,
setupPaint,
#ifdef SK_LEGACY_SURFACE_PROPS
SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
#else
SkSurfaceProps(),
#endif
kFakeGammaAndBoostContrast,
SkMatrix::I());

View File

@ -16,7 +16,11 @@ static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* p
if (props) {
return *props;
} else {
#ifdef SK_LEGACY_SURFACE_PROPS
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
#else
return SkSurfaceProps();
#endif
}
}

View File

@ -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 @@ static SkPixelGeometry compute_default_geometry() {
}
}
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)

View File

@ -248,7 +248,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_ReleaseTypeFace, reporter,
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 @@ DEF_TEST(SkRemoteGlyphCache_StrikeLockingServer, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_StrikeDeletionServer, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_StrikePinningClient, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_ClientMemoryAccounting, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_PurgesServerEntries, reporter) {
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 @@ DEF_TEST(SkRemoteGlyphCache_PurgesServerEntries, reporter) {
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsDFT, reporter, c
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);

View File

@ -67,7 +67,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrDirectContext*
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) {

View File

@ -31,7 +31,7 @@ static sk_sp<SkSurface> create_protected_sksurface(GrDirectContext* dContext,
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 @@ DEF_GPUTEST(VkProtectedContext_CreateProtectedSkSurface, reporter, options) {
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);

View File

@ -306,7 +306,7 @@ static sk_sp<SkImage> draw_with_gpu(std::function<bool(SkCanvas*)> draw,
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;

View File

@ -135,7 +135,7 @@ private:
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);

View File

@ -18,7 +18,7 @@ struct DisplayParams {
: fColorType(kN32_SkColorType)
, fColorSpace(nullptr)
, fMSAASampleCount(1)
, fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
, fSurfaceProps(0, kRGB_H_SkPixelGeometry)
, fDisableVsync(false)
{}

View File

@ -22,7 +22,7 @@ sk_sp<SkSurface> SkMtkViewToSurface(MTKView* mtkView, GrRecordingContext* rConte
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,

View File

@ -25,7 +25,7 @@ static void configure_glkview_for_skia(GLKView* view) {
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;
}

View File

@ -590,7 +590,7 @@ int main(int argc, char** argv) {
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) {

View File

@ -289,7 +289,7 @@ std::tuple<SkQP::RenderOutcome, std::string> SkQP::evaluateGM(SkQP::SkiaBackend
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(),

View File

@ -369,6 +369,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
displayParams.fGrContextOptions.fShaderErrorHandler = &gShaderErrorHandler;
displayParams.fGrContextOptions.fSuppressPrints = true;
fWindow->setRequestedDisplayParams(displayParams);
fDisplay = fWindow->getRequestedDisplayParams();
fRefresh = FLAGS_redraw;
// Configure timers
@ -493,8 +494,9 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
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 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
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 @@ void Viewer::updateTitle() {
}
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 @@ void Viewer::drawSlide(SkSurface* surface) {
}
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 @@ void Viewer::drawImGui() {
}
int pixelGeometryIdx = 0;
if (fPixelGeometryOverrides) {
if (fDisplayOverrides.fSurfaceProps.fPixelGeometry) {
pixelGeometryIdx = params.fSurfaceProps.pixelGeometry() + 1;
}
if (ImGui::Combo("Pixel Geometry", &pixelGeometryIdx,
@ -1836,10 +1838,11 @@ void Viewer::drawImGui() {
{
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);
}

View File

@ -92,6 +92,18 @@ public:
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 @@ private:
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;