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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 209233004: Revert of implement readPixels and writePixels natively, w/o using the (deprecated) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGr.h" 8 #include "SkGr.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkMessageBus.h" 10 #include "SkMessageBus.h"
(...skipping 16 matching lines...) Expand all
27 27
28 SkAutoLockPixels alp(bitmap); 28 SkAutoLockPixels alp(bitmap);
29 if (!bitmap.readyToDraw()) { 29 if (!bitmap.readyToDraw()) {
30 SkDEBUGFAIL("bitmap not ready to draw!"); 30 SkDEBUGFAIL("bitmap not ready to draw!");
31 return; 31 return;
32 } 32 }
33 33
34 SkColorTable* ctable = bitmap.getColorTable(); 34 SkColorTable* ctable = bitmap.getColorTable();
35 char* dst = (char*)buffer; 35 char* dst = (char*)buffer;
36 36
37 const int count = ctable->count(); 37 uint32_t* colorTableDst = reinterpret_cast<uint32_t*>(dst);
38 38 const uint32_t* colorTableSrc = reinterpret_cast<const uint32_t*>(ctable->lo ckColors());
39 SkDstPixelInfo dstPI; 39 SkConvertConfig8888Pixels(colorTableDst, 0, SkCanvas::kRGBA_Premul_Config888 8,
40 dstPI.fColorType = kRGBA_8888_SkColorType; 40 colorTableSrc, 0, SkCanvas::kNative_Premul_Config8 888,
41 dstPI.fAlphaType = kPremul_SkAlphaType; 41 ctable->count(), 1);
42 dstPI.fPixels = buffer;
43 dstPI.fRowBytes = count * sizeof(SkPMColor);
44
45 SkSrcPixelInfo srcPI;
46 srcPI.fColorType = kPMColor_SkColorType;
47 srcPI.fAlphaType = kPremul_SkAlphaType;
48 srcPI.fPixels = ctable->lockColors();
49 srcPI.fRowBytes = count * sizeof(SkPMColor);
50
51 srcPI.convertPixelsTo(&dstPI, count, 1);
52
53 ctable->unlockColors(); 42 ctable->unlockColors();
54 43
55 // always skip a full 256 number of entries, even if we memcpy'd fewer 44 // always skip a full 256 number of entries, even if we memcpy'd fewer
56 dst += kGrColorTableSize; 45 dst += kGrColorTableSize;
57 46
58 if ((unsigned)bitmap.width() == bitmap.rowBytes()) { 47 if ((unsigned)bitmap.width() == bitmap.rowBytes()) {
59 memcpy(dst, bitmap.getPixels(), bitmap.getSize()); 48 memcpy(dst, bitmap.getPixels(), bitmap.getSize());
60 } else { 49 } else {
61 // need to trim off the extra bytes per row 50 // need to trim off the extra bytes per row
62 size_t width = bitmap.width(); 51 size_t width = bitmap.width();
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ct = kBGRA_8888_SkColorType; 305 ct = kBGRA_8888_SkColorType;
317 break; 306 break;
318 default: 307 default:
319 return false; 308 return false;
320 } 309 }
321 if (ctOut) { 310 if (ctOut) {
322 *ctOut = ct; 311 *ctOut = ct;
323 } 312 }
324 return true; 313 return true;
325 } 314 }
OLDNEW
« 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