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

Side by Side Diff: src/pdf/SkPDFImage.cpp

Issue 17740003: remove kRLE_Index8_Config from SkBitmap (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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/SkGr.cpp ('k') | tests/BitmapCopyTest.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
2 /* 1 /*
3 * Copyright 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #include "SkPDFImage.h" 8 #include "SkPDFImage.h"
11 9
12 #include "SkBitmap.h" 10 #include "SkBitmap.h"
13 #include "SkColor.h" 11 #include "SkColor.h"
14 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
15 #include "SkPackBits.h"
16 #include "SkPDFCatalog.h" 13 #include "SkPDFCatalog.h"
17 #include "SkRect.h" 14 #include "SkRect.h"
18 #include "SkStream.h" 15 #include "SkStream.h"
19 #include "SkString.h" 16 #include "SkString.h"
20 #include "SkUnPreMultiply.h" 17 #include "SkUnPreMultiply.h"
21 18
22 namespace { 19 namespace {
23 20
24 void extractImageData(const SkBitmap& bitmap, const SkIRect& srcRect, 21 void extractImageData(const SkBitmap& bitmap, const SkIRect& srcRect,
25 SkStream** imageData, SkStream** alphaData) { 22 SkStream** imageData, SkStream** alphaData) {
26 SkMemoryStream* image = NULL; 23 SkMemoryStream* image = NULL;
27 SkMemoryStream* alpha = NULL; 24 SkMemoryStream* alpha = NULL;
28 bool hasAlpha = false; 25 bool hasAlpha = false;
29 bool isTransparent = false; 26 bool isTransparent = false;
30 27
31 bitmap.lockPixels(); 28 bitmap.lockPixels();
32 switch (bitmap.getConfig()) { 29 switch (bitmap.getConfig()) {
33 case SkBitmap::kIndex8_Config: { 30 case SkBitmap::kIndex8_Config: {
34 const int rowBytes = srcRect.width(); 31 const int rowBytes = srcRect.width();
35 image = new SkMemoryStream(rowBytes * srcRect.height()); 32 image = new SkMemoryStream(rowBytes * srcRect.height());
36 uint8_t* dst = (uint8_t*)image->getMemoryBase(); 33 uint8_t* dst = (uint8_t*)image->getMemoryBase();
37 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) { 34 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
38 memcpy(dst, bitmap.getAddr8(srcRect.fLeft, y), rowBytes); 35 memcpy(dst, bitmap.getAddr8(srcRect.fLeft, y), rowBytes);
39 dst += rowBytes; 36 dst += rowBytes;
40 } 37 }
41 break; 38 break;
42 } 39 }
43 case SkBitmap::kRLE_Index8_Config: {
44 const int rowBytes = srcRect.width();
45 image = new SkMemoryStream(rowBytes * srcRect.height());
46 uint8_t* dst = (uint8_t*)image->getMemoryBase();
47 const SkBitmap::RLEPixels* rle =
48 (const SkBitmap::RLEPixels*)bitmap.getPixels();
49 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
50 SkPackBits::Unpack8(dst, srcRect.fLeft, rowBytes,
51 rle->packedAtY(y));
52 dst += rowBytes;
53 }
54 break;
55 }
56 case SkBitmap::kARGB_4444_Config: { 40 case SkBitmap::kARGB_4444_Config: {
57 isTransparent = true; 41 isTransparent = true;
58 const int rowBytes = (srcRect.width() * 3 + 1) / 2; 42 const int rowBytes = (srcRect.width() * 3 + 1) / 2;
59 const int alphaRowBytes = (srcRect.width() + 1) / 2; 43 const int alphaRowBytes = (srcRect.width() + 1) / 2;
60 image = new SkMemoryStream(rowBytes * srcRect.height()); 44 image = new SkMemoryStream(rowBytes * srcRect.height());
61 alpha = new SkMemoryStream(alphaRowBytes * srcRect.height()); 45 alpha = new SkMemoryStream(alphaRowBytes * srcRect.height());
62 uint8_t* dst = (uint8_t*)image->getMemoryBase(); 46 uint8_t* dst = (uint8_t*)image->getMemoryBase();
63 uint8_t* alphaDst = (uint8_t*)alpha->getMemoryBase(); 47 uint8_t* alphaDst = (uint8_t*)alpha->getMemoryBase();
64 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) { 48 for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
65 uint16_t* src = bitmap.getAddr16(0, y); 49 uint16_t* src = bitmap.getAddr16(0, y);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 insert("Width", one.get()); 296 insert("Width", one.get());
313 insert("Height", one.get()); 297 insert("Height", one.get());
314 } else { 298 } else {
315 insertInt("Width", srcRect.width()); 299 insertInt("Width", srcRect.width());
316 insertInt("Height", srcRect.height()); 300 insertInt("Height", srcRect.height());
317 } 301 }
318 302
319 // if (!image mask) { 303 // if (!image mask) {
320 if (doingAlpha || alphaOnly) { 304 if (doingAlpha || alphaOnly) {
321 insertName("ColorSpace", "DeviceGray"); 305 insertName("ColorSpace", "DeviceGray");
322 } else if (config == SkBitmap::kIndex8_Config || 306 } else if (config == SkBitmap::kIndex8_Config) {
323 config == SkBitmap::kRLE_Index8_Config) {
324 SkAutoLockPixels alp(bitmap); 307 SkAutoLockPixels alp(bitmap);
325 insert("ColorSpace", 308 insert("ColorSpace",
326 makeIndexedColorSpace(bitmap.getColorTable()))->unref(); 309 makeIndexedColorSpace(bitmap.getColorTable()))->unref();
327 } else { 310 } else {
328 insertName("ColorSpace", "DeviceRGB"); 311 insertName("ColorSpace", "DeviceRGB");
329 } 312 }
330 // } 313 // }
331 314
332 int bitsPerComp = 8; 315 int bitsPerComp = 8;
333 if (config == SkBitmap::kARGB_4444_Config) { 316 if (config == SkBitmap::kARGB_4444_Config) {
(...skipping 13 matching lines...) Expand all
347 decodeValue->reserve(6); 330 decodeValue->reserve(6);
348 decodeValue->append(zeroVal.get()); 331 decodeValue->append(zeroVal.get());
349 decodeValue->append(scale5Val.get()); 332 decodeValue->append(scale5Val.get());
350 decodeValue->append(zeroVal.get()); 333 decodeValue->append(zeroVal.get());
351 decodeValue->append(scale6Val.get()); 334 decodeValue->append(scale6Val.get());
352 decodeValue->append(zeroVal.get()); 335 decodeValue->append(zeroVal.get());
353 decodeValue->append(scale5Val.get()); 336 decodeValue->append(scale5Val.get());
354 insert("Decode", decodeValue.get()); 337 insert("Decode", decodeValue.get());
355 } 338 }
356 } 339 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698