Revert "Reland "added 565 to 8888 conversion for gpu LCD text rendering for macOS""

This reverts commit 0513dd8675.

Reason for revert: Still has static initializer.

Original change's description:
> Reland "added 565 to 8888 conversion for gpu LCD text rendering for macOS"
> 
> This reverts commit cf274da6fa.
> 
> Reason for revert: removed the static initializer
> 
> Original change's description:
> > Revert "added 565 to 8888 conversion for gpu LCD text rendering for macOS"
> >
> > This reverts commit e6f2ecafaf.
> >
> > Reason for revert: breaking chrome roll cause of static initializers
> >
> > Original change's description:
> > > added 565 to 8888 conversion for gpu LCD text rendering for macOS
> > >
> > > Bug: skia:
> > > Change-Id: Ie24160bb098d388bf4ad69d0c2f9f8ed4beb215c
> > > Reviewed-on: https://skia-review.googlesource.com/134508
> > > Commit-Queue: Timothy Liang <timliang@google.com>
> > > Reviewed-by: Jim Van Verth <jvanverth@google.com>
> >
> > TBR=egdaniel@google.com,jvanverth@google.com,timliang@google.com
> >
> > Change-Id: Ida97a4085c93fcb990999ab71f99364ec2ef86b7
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:
> > Reviewed-on: https://skia-review.googlesource.com/135000
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> 
> Change-Id: I40c29b73970c55b3579a0169bbad666a798b2348
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/135021
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Timothy Liang <timliang@google.com>

TBR=egdaniel@google.com,jvanverth@google.com,timliang@google.com

Change-Id: I2632d02adc9ba791e5a55adafe0ad10a63f50073
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/135240
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2018-06-15 16:56:22 +00:00 committed by Skia Commit-Bot
parent b0897650f1
commit 5540528f81
5 changed files with 4 additions and 56 deletions

View File

@ -132,7 +132,6 @@ bool GrContext::initCommon(const GrContextOptions& options) {
options.fSortRenderTargets)); options.fSortRenderTargets));
fGlyphCache = new GrGlyphCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes); fGlyphCache = new GrGlyphCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes);
GrGlyphCache::InitMask();
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB,
this, this->uniqueID())); this, this->uniqueID()));

View File

@ -7,8 +7,10 @@
#include "GrAtlasManager.h" #include "GrAtlasManager.h"
#include "GrCaps.h"
#include "GrGlyph.h" #include "GrGlyph.h"
#include "GrGlyphCache.h" #include "GrGlyphCache.h"
#include "GrProxyProvider.h"
void GrAtlasManager::ComputeAtlasLimits(int maxTextureSize, size_t maxTextureBytes, int* maxDim, void GrAtlasManager::ComputeAtlasLimits(int maxTextureSize, size_t maxTextureBytes, int* maxDim,
int* minDim, int* maxPlot, int* minPlot) { int* minDim, int* maxPlot, int* minPlot) {

View File

@ -8,10 +8,8 @@
#ifndef GrAtlasManager_DEFINED #ifndef GrAtlasManager_DEFINED
#define GrAtlasManager_DEFINED #define GrAtlasManager_DEFINED
#include "GrCaps.h"
#include "GrDrawOpAtlas.h" #include "GrDrawOpAtlas.h"
#include "GrOnFlushResourceProvider.h" #include "GrOnFlushResourceProvider.h"
#include "GrProxyProvider.h"
class GrAtlasGlypCache; class GrAtlasGlypCache;
class GrTextStrike; class GrTextStrike;
@ -30,23 +28,11 @@ public:
float maxTextureBytes, GrDrawOpAtlas::AllowMultitexturing); float maxTextureBytes, GrDrawOpAtlas::AllowMultitexturing);
~GrAtlasManager() override; ~GrAtlasManager() override;
// Change an expected 565 mask format to 8888 if 565 is not supported (will happen when using
// Metal on macOS). The actual conversion of the data is handled in get_packed_glyph_image() in
// GrGlyphCache.cpp
GrMaskFormat resolveMaskFormat(GrMaskFormat format) const {
if (kA565_GrMaskFormat == format &&
!fProxyProvider->caps()->isConfigTexturable(kRGB_565_GrPixelConfig)) {
format = kARGB_GrMaskFormat;
}
return format;
}
// if getProxies returns nullptr, the client must not try to use other functions on the // if getProxies returns nullptr, the client must not try to use other functions on the
// GrGlyphCache which use the atlas. This function *must* be called first, before other // GrGlyphCache which use the atlas. This function *must* be called first, before other
// functions which use the atlas. Note that we can have proxies available but none active // functions which use the atlas. Note that we can have proxies available but none active
// (i.e., none instantiated). // (i.e., none instantiated).
const sk_sp<GrTextureProxy>* getProxies(GrMaskFormat format, unsigned int* numActiveProxies) { const sk_sp<GrTextureProxy>* getProxies(GrMaskFormat format, unsigned int* numActiveProxies) {
format = this->resolveMaskFormat(format);
if (this->initAtlas(format)) { if (this->initAtlas(format)) {
*numActiveProxies = this->getAtlas(format)->numActivePages(); *numActiveProxies = this->getAtlas(format)->numActivePages();
return this->getAtlas(format)->getProxies(); return this->getAtlas(format)->getProxies();
@ -141,7 +127,6 @@ private:
} }
GrDrawOpAtlas* getAtlas(GrMaskFormat format) const { GrDrawOpAtlas* getAtlas(GrMaskFormat format) const {
format = this->resolveMaskFormat(format);
int atlasIndex = MaskFormatToAtlasIndex(format); int atlasIndex = MaskFormatToAtlasIndex(format);
SkASSERT(fAtlases[atlasIndex]); SkASSERT(fAtlases[atlasIndex]);
return fAtlases[atlasIndex].get(); return fAtlases[atlasIndex].get();

View File

@ -8,14 +8,11 @@
#include "GrGlyphCache.h" #include "GrGlyphCache.h"
#include "GrAtlasManager.h" #include "GrAtlasManager.h"
#include "GrCaps.h" #include "GrCaps.h"
#include "GrColor.h"
#include "GrDistanceFieldGenFromVector.h" #include "GrDistanceFieldGenFromVector.h"
#include "SkAutoMalloc.h" #include "SkAutoMalloc.h"
#include "SkDistanceFieldGen.h" #include "SkDistanceFieldGen.h"
std::unique_ptr<const SkMasks> GrGlyphCache::k565Masks;
GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes) GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes)
: fPreserveStrike(nullptr), fGlyphSizeLimit(0) { : fPreserveStrike(nullptr), fGlyphSizeLimit(0) {
fGlyphSizeLimit = ComputeGlyphSizeLimit(caps->maxTextureSize(), maxTextureBytes); fGlyphSizeLimit = ComputeGlyphSizeLimit(caps->maxTextureSize(), maxTextureBytes);
@ -123,7 +120,7 @@ static void expand_bits(INT_TYPE* dst,
static bool get_packed_glyph_image(SkGlyphCache* cache, const SkGlyph& glyph, int width, static bool get_packed_glyph_image(SkGlyphCache* cache, const SkGlyph& glyph, int width,
int height, int dstRB, GrMaskFormat expectedMaskFormat, int height, int dstRB, GrMaskFormat expectedMaskFormat,
void* dst, const SkMasks& masks) { void* dst) {
SkASSERT(glyph.fWidth == width); SkASSERT(glyph.fWidth == width);
SkASSERT(glyph.fHeight == height); SkASSERT(glyph.fHeight == height);
const void* src = cache->findImage(glyph); const void* src = cache->findImage(glyph);
@ -131,29 +128,6 @@ static bool get_packed_glyph_image(SkGlyphCache* cache, const SkGlyph& glyph, in
return false; return false;
} }
// Convert if the glyph uses a 565 mask format since it is using LCD text rendering but the
// expected format is 8888 (will happen on macOS with Metal since that combination does not
// support 565).
if (kA565_GrMaskFormat == get_packed_glyph_mask_format(glyph) &&
kARGB_GrMaskFormat == expectedMaskFormat) {
const int a565Bpp = GrMaskFormatBytesPerPixel(kA565_GrMaskFormat);
const int argbBpp = GrMaskFormatBytesPerPixel(kARGB_GrMaskFormat);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
uint16_t color565 = 0;
memcpy(&color565, src, a565Bpp);
uint32_t colorRGBA = GrColorPackRGBA(masks.getRed(color565),
masks.getGreen(color565),
masks.getBlue(color565),
0xFF);
memcpy(dst, &colorRGBA, argbBpp);
src = (char*)src + a565Bpp;
dst = (char*)dst + argbBpp;
}
}
return true;
}
// crbug:510931 // crbug:510931
// Retrieving the image from the cache can actually change the mask format. This case is very // Retrieving the image from the cache can actually change the mask format. This case is very
// uncommon so for now we just draw a clear box for these glyphs. // uncommon so for now we just draw a clear box for these glyphs.
@ -263,7 +237,6 @@ GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas(
SkASSERT(cache); SkASSERT(cache);
SkASSERT(fCache.find(glyph->fPackedID)); SkASSERT(fCache.find(glyph->fPackedID));
expectedMaskFormat = fullAtlasManager->resolveMaskFormat(expectedMaskFormat);
int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat);
int width = glyph->width(); int width = glyph->width();
int height = glyph->height(); int height = glyph->height();
@ -289,7 +262,7 @@ GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas(
} }
if (!get_packed_glyph_image(cache, skGlyph, glyph->width(), glyph->height(), if (!get_packed_glyph_image(cache, skGlyph, glyph->width(), glyph->height(),
rowBytes, expectedMaskFormat, rowBytes, expectedMaskFormat,
dataPtr, *GrGlyphCache::k565Masks)) { dataPtr)) {
return GrDrawOpAtlas::ErrorCode::kError; return GrDrawOpAtlas::ErrorCode::kError;
} }

View File

@ -12,7 +12,6 @@
#include "GrGlyph.h" #include "GrGlyph.h"
#include "SkArenaAlloc.h" #include "SkArenaAlloc.h"
#include "SkGlyphCache.h" #include "SkGlyphCache.h"
#include "SkMasks.h"
#include "SkTDynamicHash.h" #include "SkTDynamicHash.h"
class GrGlyphCache; class GrGlyphCache;
@ -109,8 +108,6 @@ private:
*/ */
class GrGlyphCache { class GrGlyphCache {
public: public:
static std::unique_ptr<const SkMasks> k565Masks;
GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes); GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes);
~GrGlyphCache(); ~GrGlyphCache();
@ -132,14 +129,6 @@ public:
void freeAll(); void freeAll();
static void InitMask() {
static SkOnce once;
once([] {
k565Masks.reset(SkMasks::CreateMasks({0xF800, 0x07E0, 0x001F, 0},
GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8));
});
}
static void HandleEviction(GrDrawOpAtlas::AtlasID, void*); static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
static SkScalar ComputeGlyphSizeLimit(int maxTextureSize, size_t maxTextureBytes); static SkScalar ComputeGlyphSizeLimit(int maxTextureSize, size_t maxTextureBytes);