From 9abf719e67377fca1e2a20b34bf67c7bd4061524 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Fri, 23 Oct 2020 11:29:03 -0400 Subject: [PATCH] Remove code guarded by SK_LEGACY_SURFACE_PROPS. This removes the last of the SkFontHost LCD globals and the SkSurfaceProps::kLegacyFontHost_InitType. Bug: skia:3934 Change-Id: Ic2342a3ea3dbcd075d6817cbd3fc27274e376b8d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329364 Commit-Queue: Ben Wagner Reviewed-by: Mike Reed --- RELEASE_NOTES.txt | 6 ++++ gn/core.gni | 2 -- include/core/SkFontLCDConfig.h | 60 ---------------------------------- include/core/SkSurfaceProps.h | 15 ++------- src/core/SkBitmapDevice.cpp | 8 ----- src/core/SkCanvas.cpp | 13 -------- src/core/SkFontLCDConfig.cpp | 29 ---------------- src/core/SkScalerContext.h | 4 --- src/core/SkStrikeSpec.cpp | 8 ----- src/core/SkSurfacePriv.h | 10 +----- src/image/SkSurface.cpp | 34 ------------------- 11 files changed, 9 insertions(+), 180 deletions(-) delete mode 100644 include/core/SkFontLCDConfig.h delete mode 100644 src/core/SkFontLCDConfig.cpp diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index c3159b459e..3f3c55c118 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -9,6 +9,12 @@ Milestone 88 * + * Removed SkSurfaceProps::kLegacyFontHost_InitType, SkFontLCDConfig, and related code. + The default pixel geometry for SkSurfaceProps is now kUnknown instead of kRGB_H. + The removal was guarded by the SK_LEGACY_SURFACE_PROPS build flag which was later removed. + https://review.skia.org/322490 + https://review.skia.org/329364 + * Legacy 8-bit YUV interface removed from SkImageGenerator. Use more flexible SkYUVAPixmaps- based interface instead. https://review.skia.org/327917 diff --git a/gn/core.gni b/gn/core.gni index 7e149b2326..9019a129de 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -36,7 +36,6 @@ skia_core_public = [ "$_include/core/SkFlattenable.h", "$_include/core/SkFont.h", "$_include/core/SkFontArguments.h", - "$_include/core/SkFontLCDConfig.h", "$_include/core/SkFontMetrics.h", "$_include/core/SkFontMgr.h", "$_include/core/SkFontParameters.h", @@ -205,7 +204,6 @@ skia_core_sources = [ "$_src/core/SkFont.cpp", "$_src/core/SkFontDescriptor.cpp", "$_src/core/SkFontDescriptor.h", - "$_src/core/SkFontLCDConfig.cpp", "$_src/core/SkFontMgr.cpp", "$_src/core/SkFontMgrPriv.h", "$_src/core/SkFontPriv.h", diff --git a/include/core/SkFontLCDConfig.h b/include/core/SkFontLCDConfig.h deleted file mode 100644 index e63d98cc87..0000000000 --- a/include/core/SkFontLCDConfig.h +++ /dev/null @@ -1,60 +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 SkFontLCDConfig_DEFINED -#define SkFontLCDConfig_DEFINED - -#include "include/core/SkTypes.h" - -#ifdef SK_LEGACY_SURFACE_PROPS -class SK_API SkFontLCDConfig { -public: - /** LCDs either have their color elements arranged horizontally or - vertically. When rendering subpixel glyphs we need to know which way - round they are. - - Note, if you change this after startup, you'll need to flush the glyph - cache because it'll have the wrong type of masks cached. - - @deprecated use SkPixelGeometry instead. - */ - enum LCDOrientation { - kHorizontal_LCDOrientation = 0, //!< this is the default - kVertical_LCDOrientation = 1, - }; - - /** @deprecated set on Device creation. */ - static void SetSubpixelOrientation(LCDOrientation orientation); - /** @deprecated get from Device. */ - static LCDOrientation GetSubpixelOrientation(); - - /** LCD color elements can vary in order. For subpixel text we need to know - the order which the LCDs uses so that the color fringes are in the - correct place. - - Note, if you change this after startup, you'll need to flush the glyph - cache because it'll have the wrong type of masks cached. - - kNONE_LCDOrder means that the subpixel elements are not spatially - separated in any usable fashion. - - @deprecated use SkPixelGeometry instead. - */ - enum LCDOrder { - kRGB_LCDOrder = 0, //!< this is the default - kBGR_LCDOrder = 1, - kNONE_LCDOrder = 2, - }; - - /** @deprecated set on Device creation. */ - static void SetSubpixelOrder(LCDOrder order); - /** @deprecated get from Device. */ - static LCDOrder GetSubpixelOrder(); -}; -#endif - -#endif diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h index de8daaa095..9d9c6b18bf 100644 --- a/include/core/SkSurfaceProps.h +++ b/include/core/SkSurfaceProps.h @@ -56,18 +56,10 @@ public: /** Deprecated alias used by Chromium. Will be removed. */ static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag; -#ifndef SK_LEGACY_SURFACE_PROPS + /** No flags, unknown pixel geometry. */ 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&); @@ -85,11 +77,8 @@ public: bool operator!=(const SkSurfaceProps& that) const { return !(*this == that); } -private: -#ifdef SK_LEGACY_SURFACE_PROPS - SkSurfaceProps(); -#endif +private: uint32_t fFlags; SkPixelGeometry fPixelGeometry; }; diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 898bd4860d..af481e4022 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -213,11 +213,7 @@ 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(), @@ -228,11 +224,7 @@ 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, diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index bd576c3d3f..a84e139760 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -515,14 +515,9 @@ void SkCanvas::init(sk_sp device) { SkCanvas::SkCanvas() : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) -#ifdef SK_LEGACY_SURFACE_PROPS - , fProps(SkSurfaceProps::kLegacyFontHost_InitType) -#else , fProps() -#endif { inc_canvas(); - this->init(nullptr); } @@ -537,11 +532,7 @@ 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,11 +562,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props) SkCanvas::SkCanvas(const SkBitmap& bitmap, std::unique_ptr 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(); diff --git a/src/core/SkFontLCDConfig.cpp b/src/core/SkFontLCDConfig.cpp deleted file mode 100644 index ff9c606087..0000000000 --- a/src/core/SkFontLCDConfig.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2009 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "include/core/SkFontLCDConfig.h" - -#ifdef SK_LEGACY_SURFACE_PROPS -static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHorizontal_LCDOrientation; -static SkFontLCDConfig::LCDOrder gLCDOrder = SkFontLCDConfig::kRGB_LCDOrder; - -SkFontLCDConfig::LCDOrientation SkFontLCDConfig::GetSubpixelOrientation() { - return gLCDOrientation; -} - -void SkFontLCDConfig::SetSubpixelOrientation(LCDOrientation orientation) { - gLCDOrientation = orientation; -} - -SkFontLCDConfig::LCDOrder SkFontLCDConfig::GetSubpixelOrder() { - return gLCDOrder; -} - -void SkFontLCDConfig::SetSubpixelOrder(LCDOrder order) { - gLCDOrder = order; -} -#endif diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 49999c068a..3e84e95438 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -316,11 +316,7 @@ 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); } diff --git a/src/core/SkStrikeSpec.cpp b/src/core/SkStrikeSpec.cpp index d64527d408..1277d95b21 100644 --- a/src/core/SkStrikeSpec.cpp +++ b/src/core/SkStrikeSpec.cpp @@ -102,11 +102,7 @@ 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; @@ -122,11 +118,7 @@ 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()); diff --git a/src/core/SkSurfacePriv.h b/src/core/SkSurfacePriv.h index f3e6f55c80..26c70644f9 100644 --- a/src/core/SkSurfacePriv.h +++ b/src/core/SkSurfacePriv.h @@ -13,15 +13,7 @@ struct SkImageInfo; static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* props) { - if (props) { - return *props; - } else { -#ifdef SK_LEGACY_SURFACE_PROPS - return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); -#else - return SkSurfaceProps(); -#endif - } + return props ? *props : SkSurfaceProps(); } constexpr size_t kIgnoreRowBytesValue = static_cast(~0); diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index 8023b73e3a..7606f023f4 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -8,7 +8,6 @@ #include #include #include "include/core/SkCanvas.h" -#include "include/core/SkFontLCDConfig.h" #include "include/gpu/GrBackendSurface.h" #include "src/core/SkAutoPixmapStorage.h" #include "src/core/SkImagePriv.h" @@ -17,39 +16,6 @@ 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) { - return kUnknown_SkPixelGeometry; - } else { - // Bit0 is RGB(0), BGR(1) - // Bit1 is H(0), V(1) - const SkPixelGeometry gGeo[] = { - kRGB_H_SkPixelGeometry, - kBGR_H_SkPixelGeometry, - kRGB_V_SkPixelGeometry, - kBGR_V_SkPixelGeometry, - }; - int index = 0; - if (SkFontLCDConfig::kBGR_LCDOrder == order) { - index |= 1; - } - if (SkFontLCDConfig::kVertical_LCDOrientation == SkFontLCDConfig::GetSubpixelOrientation()){ - index |= 2; - } - return gGeo[index]; - } -} - -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) {}