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

Unified Diff: src/utils/SkTextureCompressor_R11EAC.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_R11EAC.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkTextureCompressor_R11EAC.cpp
diff --git a/src/utils/SkTextureCompressor_R11EAC.cpp b/src/utils/SkTextureCompressor_R11EAC.cpp
index 7baa219a28de88d05e2a6966b85b9d45ab2534e6..1d2b8e54aa84899d93347cb9625d55f4d05597be 100644
--- a/src/utils/SkTextureCompressor_R11EAC.cpp
+++ b/src/utils/SkTextureCompressor_R11EAC.cpp
@@ -8,6 +8,7 @@
#include "SkTextureCompressor.h"
#include "SkTextureCompressor_Blitter.h"
+#include "SkBlitter.h"
#include "SkEndian.h"
// #define COMPRESS_R11_EAC_SLOW 1
@@ -608,9 +609,26 @@ bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height,
#endif
}
-SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer) {
- return new
- SkTCompressedAlphaBlitter<4, 8, compress_block_vertical>
+SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer,
+ SkTBlitterAllocator* allocator) {
+
+ if ((width % 4) != 0 || (height % 4) != 0) {
+ return NULL;
+ }
+
+ // 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 R11, we use the encoding from recognizing all zero pixels from above.
+ const int nBlocks = (width * height / 16); // 4x4 pixel blocks.
+ uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer);
+ for (int i = 0; i < nBlocks; ++i) {
+ *dst = 0x0020000000002000ULL;
+ ++dst;
+ }
+
+ return allocator->createT<
+ SkTCompressedAlphaBlitter<4, 8, compress_block_vertical>, int, int, void*>
(width, height, outputBuffer);
}
« no previous file with comments | « src/utils/SkTextureCompressor_R11EAC.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698