Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1945)

Unified Diff: src/gpu/GrSWMaskHelper.cpp

Issue 326223002: Add an LATC compressor to the A8 masks, and hide it behind an ifdef. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrSWMaskHelper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrSWMaskHelper.cpp
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 504f5a0a35aa4d912feea21a08613261f98757a5..044ff7a0944e81318ac9bcbd921b32663a85ea24 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -6,16 +6,22 @@
*/
#include "GrSWMaskHelper.h"
+
#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
#include "SkStrokeRec.h"
+#if GR_COMPRESS_ALPHA_MASK
robertphillips 2014/06/10 22:19:46 no extra space here
krajcevski 2014/06/10 22:28:46 Done.
+# include "SkData.h"
+# include "SkTextureCompressor.h"
+#endif
// TODO: try to remove this #include
#include "GrContext.h"
namespace {
+
/*
* Convert a boolean operation into a transfer mode code
*/
@@ -127,6 +133,26 @@ bool GrSWMaskHelper::getTexture(GrAutoScratchTexture* texture) {
return NULL != texture->texture();
}
+GrTexture* GrSWMaskHelper::toLATCTexture(GrContext* ctx) {
+#if GR_COMPRESS_ALPHA_MASK
+ // Encode the BM into LATC data:
robertphillips 2014/06/10 22:19:46 Can just use fBM - don't need this-> in this case.
krajcevski 2014/06/10 22:28:46 Done.
+ SkAutoLockPixels alp(this->fBM);
+ SkTextureCompressor::Format format = SkTextureCompressor::kLATC_Format;
+ SkAutoDataUnref latcData(SkTextureCompressor::CompressBitmapToFormat(this->fBM, format));
+ if (NULL == latcData) {
+ return NULL;
+ }
+
+ GrTextureDesc desc;
+ desc.fWidth = this->fBM.width();
+ desc.fHeight = this->fBM.height();
+ desc.fConfig = kLATC_GrPixelConfig;
+ return ctx->getGpu()->createTexture(desc, latcData->bytes(), 0);
+#else
+ return NULL;
+#endif
+}
+
/**
* Move the result of the software mask generation back to the gpu
*/
@@ -158,8 +184,6 @@ GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
const SkIRect& resultBounds,
bool antiAlias,
SkMatrix* matrix) {
- GrAutoScratchTexture ast;
-
GrSWMaskHelper helper(context);
if (!helper.init(resultBounds, matrix)) {
@@ -168,6 +192,16 @@ GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF);
robertphillips 2014/06/10 22:19:46 Given the flag usage in toLATCTexture we probably
krajcevski 2014/06/10 22:28:46 Done.
+#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)) {
return NULL;
}
« no previous file with comments | « src/gpu/GrSWMaskHelper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698