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

Unified Diff: src/utils/SkTextureCompressor_LATC.cpp

Issue 446103002: Pass compressed blitters to our mask drawing algorithm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix compiler error Created 6 years, 4 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/utils/SkTextureCompressor_LATC.h ('k') | src/utils/SkTextureCompressor_R11EAC.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkTextureCompressor_LATC.cpp
diff --git a/src/utils/SkTextureCompressor_LATC.cpp b/src/utils/SkTextureCompressor_LATC.cpp
index 5db0fc6c04e609c4ad3c72a0393a3ec9ee870e51..0b9cf17ad635b0f7470f75047d7b975be6b51875 100644
--- a/src/utils/SkTextureCompressor_LATC.cpp
+++ b/src/utils/SkTextureCompressor_LATC.cpp
@@ -8,6 +8,7 @@
#include "SkTextureCompressor_LATC.h"
#include "SkTextureCompressor_Blitter.h"
+#include "SkBlitter.h"
#include "SkEndian.h"
// Compression options. In general, the slow version is much more accurate, but
@@ -427,10 +428,23 @@ bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i
#endif
}
-SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer) {
+SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer,
+ SkTBlitterAllocator* allocator) {
+ if ((width % 4) != 0 || (height % 4) != 0) {
+ return NULL;
+ }
+
#if COMPRESS_LATC_FAST
- return new
- SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical>
+ // Memset the output buffer to an encoding that decodes to zero. We must do this
+ // in order to avoid having uninitialized values in the buffer if the blitter
+ // decides not to write certain scanlines (and skip entire rows of blocks).
+ // In the case of LATC, if everything is zero, then LUM0 and LUM1 are also zero,
+ // and they will only be non-zero (0xFF) if the index is 7. So bzero will do just fine.
+ // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2
+ sk_bzero(outputBuffer, width * height / 2);
+
+ return allocator->createT<
+ SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical>, int, int, void* >
(width, height, outputBuffer);
#elif COMPRESS_LATC_SLOW
// TODO (krajcevski)
« no previous file with comments | « src/utils/SkTextureCompressor_LATC.h ('k') | src/utils/SkTextureCompressor_R11EAC.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698