OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 const int count = ctable->count(); | 37 const int count = ctable->count(); |
38 | 38 |
39 SkDstPixelInfo dstPI; | 39 SkDstPixelInfo dstPI; |
40 dstPI.fColorType = kRGBA_8888_SkColorType; | 40 dstPI.fColorType = kRGBA_8888_SkColorType; |
41 dstPI.fAlphaType = kPremul_SkAlphaType; | 41 dstPI.fAlphaType = kPremul_SkAlphaType; |
42 dstPI.fPixels = buffer; | 42 dstPI.fPixels = buffer; |
43 dstPI.fRowBytes = count * sizeof(SkPMColor); | 43 dstPI.fRowBytes = count * sizeof(SkPMColor); |
44 | 44 |
45 SkSrcPixelInfo srcPI; | 45 SkSrcPixelInfo srcPI; |
46 srcPI.fColorType = kPMColor_SkColorType; | 46 srcPI.fColorType = kN32_SkColorType; |
47 srcPI.fAlphaType = kPremul_SkAlphaType; | 47 srcPI.fAlphaType = kPremul_SkAlphaType; |
48 srcPI.fPixels = ctable->lockColors(); | 48 srcPI.fPixels = ctable->lockColors(); |
49 srcPI.fRowBytes = count * sizeof(SkPMColor); | 49 srcPI.fRowBytes = count * sizeof(SkPMColor); |
50 | 50 |
51 srcPI.convertPixelsTo(&dstPI, count, 1); | 51 srcPI.convertPixelsTo(&dstPI, count, 1); |
52 | 52 |
53 ctable->unlockColors(); | 53 ctable->unlockColors(); |
54 | 54 |
55 // always skip a full 256 number of entries, even if we memcpy'd fewer | 55 // always skip a full 256 number of entries, even if we memcpy'd fewer |
56 dst += kGrColorTableSize; | 56 dst += kGrColorTableSize; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 return result; | 159 return result; |
160 } else { | 160 } else { |
161 GrTexture* result = ctx->lockAndRefScratchTexture(desc, | 161 GrTexture* result = ctx->lockAndRefScratchTexture(desc, |
162 GrContext::kExact_Sc
ratchTexMatch); | 162 GrContext::kExact_Sc
ratchTexMatch); |
163 result->writePixels(0, 0, bitmap->width(), | 163 result->writePixels(0, 0, bitmap->width(), |
164 bitmap->height(), desc.fConfig, | 164 bitmap->height(), desc.fConfig, |
165 storage.get()); | 165 storage.get()); |
166 return result; | 166 return result; |
167 } | 167 } |
168 } else { | 168 } else { |
169 origBitmap.copyTo(&tmpBitmap, kPMColor_SkColorType); | 169 origBitmap.copyTo(&tmpBitmap, kN32_SkColorType); |
170 // now bitmap points to our temp, which has been promoted to 32bits | 170 // now bitmap points to our temp, which has been promoted to 32bits |
171 bitmap = &tmpBitmap; | 171 bitmap = &tmpBitmap; |
172 desc.fConfig = SkBitmapConfig2GrPixelConfig(bitmap->config()); | 172 desc.fConfig = SkBitmapConfig2GrPixelConfig(bitmap->config()); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 SkAutoLockPixels alp(*bitmap); | 176 SkAutoLockPixels alp(*bitmap); |
177 if (!bitmap->readyToDraw()) { | 177 if (!bitmap->readyToDraw()) { |
178 return NULL; | 178 return NULL; |
179 } | 179 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 ct = kBGRA_8888_SkColorType; | 316 ct = kBGRA_8888_SkColorType; |
317 break; | 317 break; |
318 default: | 318 default: |
319 return false; | 319 return false; |
320 } | 320 } |
321 if (ctOut) { | 321 if (ctOut) { |
322 *ctOut = ct; | 322 *ctOut = ct; |
323 } | 323 } |
324 return true; | 324 return true; |
325 } | 325 } |
OLD | NEW |