Add an LATC compressor to the A8 masks, and hide it behind an ifdef.
R=robertphillips@google.com Author: krajcevski@google.com Review URL: https://codereview.chromium.org/326223002
This commit is contained in:
parent
5a220a1f47
commit
5c2fca040e
@ -74,6 +74,9 @@
|
|||||||
'../include/gpu',
|
'../include/gpu',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'defines': [
|
||||||
|
'GR_COMPRESS_ALPHA_MASK=0',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
'targets': [
|
'targets': [
|
||||||
{
|
{
|
||||||
|
@ -6,16 +6,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GrSWMaskHelper.h"
|
#include "GrSWMaskHelper.h"
|
||||||
|
|
||||||
#include "GrDrawState.h"
|
#include "GrDrawState.h"
|
||||||
#include "GrDrawTargetCaps.h"
|
#include "GrDrawTargetCaps.h"
|
||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
|
|
||||||
|
#include "SkData.h"
|
||||||
#include "SkStrokeRec.h"
|
#include "SkStrokeRec.h"
|
||||||
|
#include "SkTextureCompressor.h"
|
||||||
|
|
||||||
// TODO: try to remove this #include
|
// TODO: try to remove this #include
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a boolean operation into a transfer mode code
|
* Convert a boolean operation into a transfer mode code
|
||||||
*/
|
*/
|
||||||
@ -127,6 +131,22 @@ bool GrSWMaskHelper::getTexture(GrAutoScratchTexture* texture) {
|
|||||||
return NULL != texture->texture();
|
return NULL != texture->texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrTexture* GrSWMaskHelper::toLATCTexture(GrContext* ctx) {
|
||||||
|
// Encode the BM into LATC data:
|
||||||
|
SkAutoLockPixels alp(fBM);
|
||||||
|
SkTextureCompressor::Format format = SkTextureCompressor::kLATC_Format;
|
||||||
|
SkAutoDataUnref latcData(SkTextureCompressor::CompressBitmapToFormat(fBM, format));
|
||||||
|
if (NULL == latcData) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GrTextureDesc desc;
|
||||||
|
desc.fWidth = fBM.width();
|
||||||
|
desc.fHeight = fBM.height();
|
||||||
|
desc.fConfig = kLATC_GrPixelConfig;
|
||||||
|
return ctx->getGpu()->createTexture(desc, latcData->bytes(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the result of the software mask generation back to the gpu
|
* Move the result of the software mask generation back to the gpu
|
||||||
*/
|
*/
|
||||||
@ -158,8 +178,6 @@ GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
|
|||||||
const SkIRect& resultBounds,
|
const SkIRect& resultBounds,
|
||||||
bool antiAlias,
|
bool antiAlias,
|
||||||
SkMatrix* matrix) {
|
SkMatrix* matrix) {
|
||||||
GrAutoScratchTexture ast;
|
|
||||||
|
|
||||||
GrSWMaskHelper helper(context);
|
GrSWMaskHelper helper(context);
|
||||||
|
|
||||||
if (!helper.init(resultBounds, matrix)) {
|
if (!helper.init(resultBounds, matrix)) {
|
||||||
@ -168,6 +186,16 @@ GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
|
|||||||
|
|
||||||
helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
|
helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
|
||||||
|
|
||||||
|
#if GR_COMPRESS_ALPHA_MASK
|
||||||
|
// Can we create an LATC texture?
|
||||||
|
GrTexture *latc = helper.toLATCTexture(context);
|
||||||
|
if (NULL != latc) {
|
||||||
|
return latc;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Looks like we have to send a full A8 texture.
|
||||||
|
GrAutoScratchTexture ast;
|
||||||
if (!helper.getTexture(&ast)) {
|
if (!helper.getTexture(&ast)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
// Move the mask generation results from the internal bitmap to the gpu.
|
// Move the mask generation results from the internal bitmap to the gpu.
|
||||||
void toTexture(GrTexture* texture);
|
void toTexture(GrTexture* texture);
|
||||||
|
|
||||||
|
GrTexture* toLATCTexture(GrContext* ctx);
|
||||||
|
|
||||||
// Reset the internal bitmap
|
// Reset the internal bitmap
|
||||||
void clear(uint8_t alpha) {
|
void clear(uint8_t alpha) {
|
||||||
fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
|
fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
|
||||||
|
Loading…
Reference in New Issue
Block a user