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

Unified Diff: src/gpu/SkGr.cpp

Issue 199733016: implement readPixels and writePixels natively, w/o using the (deprecated) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 9 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/GrContext.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 94e4c8c35dd4b2e488a16730b584ae8116b15881..db46b8690126c557d691767e55a5749725dc08ed 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -34,11 +34,22 @@ static void build_compressed_data(void* buffer, const SkBitmap& bitmap) {
SkColorTable* ctable = bitmap.getColorTable();
char* dst = (char*)buffer;
- uint32_t* colorTableDst = reinterpret_cast<uint32_t*>(dst);
- const uint32_t* colorTableSrc = reinterpret_cast<const uint32_t*>(ctable->lockColors());
- SkConvertConfig8888Pixels(colorTableDst, 0, SkCanvas::kRGBA_Premul_Config8888,
- colorTableSrc, 0, SkCanvas::kNative_Premul_Config8888,
- ctable->count(), 1);
+ const int count = ctable->count();
+
+ SkDstPixelInfo dstPI;
+ dstPI.fColorType = kRGBA_8888_SkColorType;
+ dstPI.fAlphaType = kPremul_SkAlphaType;
+ dstPI.fPixels = buffer;
+ dstPI.fRowBytes = count * sizeof(SkPMColor);
+
+ SkSrcPixelInfo srcPI;
+ srcPI.fColorType = kPMColor_SkColorType;
+ srcPI.fAlphaType = kPremul_SkAlphaType;
+ srcPI.fPixels = ctable->lockColors();
+ srcPI.fRowBytes = count * sizeof(SkPMColor);
+
+ srcPI.convertPixelsTo(&dstPI, count, 1);
+
ctable->unlockColors();
// always skip a full 256 number of entries, even if we memcpy'd fewer
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698