Change GR_COMPRESS_ALPHA_MASK from compile-time flag to run-time. We do this by introducing an Options struct to be passed to a GrContext on creation.
R=robertphillips@google.com, bsalomon@google.com Author: krajcevski@google.com Review URL: https://codereview.chromium.org/459033002
This commit is contained in:
parent
03bde3e6fa
commit
9c6d4d744a
@ -74,9 +74,6 @@
|
|||||||
'../include/gpu',
|
'../include/gpu',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'defines': [
|
|
||||||
'GR_COMPRESS_ALPHA_MASK=0',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
'targets': [
|
'targets': [
|
||||||
{
|
{
|
||||||
|
@ -49,10 +49,19 @@ class SK_API GrContext : public SkRefCnt {
|
|||||||
public:
|
public:
|
||||||
SK_DECLARE_INST_COUNT(GrContext)
|
SK_DECLARE_INST_COUNT(GrContext)
|
||||||
|
|
||||||
|
struct Options {
|
||||||
|
Options() : fDrawPathToCompressedTexture(false) { }
|
||||||
|
|
||||||
|
// EXPERIMENTAL
|
||||||
|
// May be removed in the future, or may become standard depending
|
||||||
|
// on the outcomes of a variety of internal tests.
|
||||||
|
bool fDrawPathToCompressedTexture;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a GrContext for a backend context.
|
* Creates a GrContext for a backend context.
|
||||||
*/
|
*/
|
||||||
static GrContext* Create(GrBackend, GrBackendContext);
|
static GrContext* Create(GrBackend, GrBackendContext, const Options* opts = NULL);
|
||||||
|
|
||||||
virtual ~GrContext();
|
virtual ~GrContext();
|
||||||
|
|
||||||
@ -939,6 +948,12 @@ public:
|
|||||||
GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType,
|
GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType,
|
||||||
GrPathRendererChain::StencilSupport* stencilSupport = NULL);
|
GrPathRendererChain::StencilSupport* stencilSupport = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns a copy of the the GrContext::Options that was passed to the
|
||||||
|
* constructor of this class.
|
||||||
|
*/
|
||||||
|
const Options& getOptions() const { return fOptions; }
|
||||||
|
|
||||||
#if GR_CACHE_STATS
|
#if GR_CACHE_STATS
|
||||||
void printCacheStats() const;
|
void printCacheStats() const;
|
||||||
#endif
|
#endif
|
||||||
@ -987,7 +1002,9 @@ private:
|
|||||||
|
|
||||||
int fMaxTextureSizeOverride;
|
int fMaxTextureSizeOverride;
|
||||||
|
|
||||||
GrContext(); // init must be called after the constructor.
|
const Options fOptions;
|
||||||
|
|
||||||
|
GrContext(const Options&); // init must be called after the constructor.
|
||||||
bool init(GrBackend, GrBackendContext);
|
bool init(GrBackend, GrBackendContext);
|
||||||
|
|
||||||
void setupDrawBuffer();
|
void setupDrawBuffer();
|
||||||
|
@ -84,8 +84,15 @@ private:
|
|||||||
GrContext* fContext;
|
GrContext* fContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
|
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
|
||||||
GrContext* context = SkNEW(GrContext);
|
const Options* opts) {
|
||||||
|
GrContext* context;
|
||||||
|
if (NULL == opts) {
|
||||||
|
context = SkNEW_ARGS(GrContext, (Options()));
|
||||||
|
} else {
|
||||||
|
context = SkNEW_ARGS(GrContext, (*opts));
|
||||||
|
}
|
||||||
|
|
||||||
if (context->init(backend, backendContext)) {
|
if (context->init(backend, backendContext)) {
|
||||||
return context;
|
return context;
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +101,7 @@ GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GrContext::GrContext() {
|
GrContext::GrContext(const Options& opts) : fOptions(opts) {
|
||||||
fDrawState = NULL;
|
fDrawState = NULL;
|
||||||
fGpu = NULL;
|
fGpu = NULL;
|
||||||
fClip = NULL;
|
fClip = NULL;
|
||||||
|
@ -66,7 +66,6 @@ static inline GrPixelConfig fmt_to_config(SkTextureCompressor::Format fmt) {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GR_COMPRESS_ALPHA_MASK
|
|
||||||
static bool choose_compressed_fmt(const GrDrawTargetCaps* caps,
|
static bool choose_compressed_fmt(const GrDrawTargetCaps* caps,
|
||||||
SkTextureCompressor::Format *fmt) {
|
SkTextureCompressor::Format *fmt) {
|
||||||
if (NULL == fmt) {
|
if (NULL == fmt) {
|
||||||
@ -95,7 +94,6 @@ static bool choose_compressed_fmt(const GrDrawTargetCaps* caps,
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,11 +169,10 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds,
|
|||||||
SkIRect bounds = SkIRect::MakeWH(resultBounds.width(),
|
SkIRect bounds = SkIRect::MakeWH(resultBounds.width(),
|
||||||
resultBounds.height());
|
resultBounds.height());
|
||||||
|
|
||||||
#if GR_COMPRESS_ALPHA_MASK
|
if (fContext->getOptions().fDrawPathToCompressedTexture &&
|
||||||
if (choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) {
|
choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) {
|
||||||
fCompressionMode = kCompress_CompressionMode;
|
fCompressionMode = kCompress_CompressionMode;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Make sure that the width is a multiple of the desired block dimensions
|
// Make sure that the width is a multiple of the desired block dimensions
|
||||||
// to allow for specialized SIMD instructions that compress multiple blocks at a time.
|
// to allow for specialized SIMD instructions that compress multiple blocks at a time.
|
||||||
|
Loading…
Reference in New Issue
Block a user