OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPdfRenderer.h" | 8 #include "SkPdfRenderer.h" |
9 | 9 |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkColorPriv.h" |
12 #include "SkDevice.h" | 13 #include "SkDevice.h" |
13 #include "SkForceLinking.h" | 14 #include "SkForceLinking.h" |
14 #include "SkGraphics.h" | 15 #include "SkGraphics.h" |
15 #include "SkImageDecoder.h" | 16 #include "SkImageDecoder.h" |
16 #include "SkImageEncoder.h" | 17 #include "SkImageEncoder.h" |
17 #include "SkOSFile.h" | 18 #include "SkOSFile.h" |
18 #include "SkPicture.h" | 19 #include "SkPicture.h" |
19 #include "SkPdfFont.h" | 20 #include "SkPdfFont.h" |
20 #include "SkPdfGraphicsState.h" | 21 #include "SkPdfGraphicsState.h" |
21 #include "SkPdfHeaders_autogen.h" | 22 #include "SkPdfHeaders_autogen.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 SkBitmap* bitmap = new SkBitmap(); | 377 SkBitmap* bitmap = new SkBitmap(); |
377 | 378 |
378 //int components = GetColorSpaceComponents(colorSpace); | 379 //int components = GetColorSpaceComponents(colorSpace); |
379 //#define MAX_COMPONENTS 10 | 380 //#define MAX_COMPONENTS 10 |
380 | 381 |
381 // TODO(edisonn): assume start of lines are aligned at 32 bits? | 382 // TODO(edisonn): assume start of lines are aligned at 32 bits? |
382 // Is there a faster way to load the uncompressed stream into a bitmap? | 383 // Is there a faster way to load the uncompressed stream into a bitmap? |
383 | 384 |
384 // minimal support for now | 385 // minimal support for now |
385 if ((colorSpace.equals("DeviceRGB") || colorSpace.equals("RGB")) && bpc == 8
) { | 386 if ((colorSpace.equals("DeviceRGB") || colorSpace.equals("RGB")) && bpc == 8
) { |
386 SkColor* uncompressedStreamArgb = (SkColor*)malloc(width * height * size
of(SkColor)); | 387 uint32_t* uncompressedStreamArgb = (SkColor*)malloc(width * height * siz
eof(uint32_t)); |
387 | 388 |
388 for (int h = 0 ; h < height; h++) { | 389 for (int h = 0 ; h < height; h++) { |
389 long i = width * (h); | 390 long i = width * (h); |
390 for (int w = 0 ; w < width; w++) { | 391 for (int w = 0 ; w < width; w++) { |
391 uncompressedStreamArgb[i] = SkColorSetRGB(uncompressedStream[3 *
w], | 392 uncompressedStreamArgb[i] = SkPackARGB32(0xFF, |
392 uncompressedStream[3 *
w + 1], | 393 uncompressedStream[3 *
w], |
393 uncompressedStream[3 *
w + 2]); | 394 uncompressedStream[3 *
w + 1], |
| 395 uncompressedStream[3 *
w + 2]); |
394 i++; | 396 i++; |
395 } | 397 } |
396 uncompressedStream += bytesPerLine; | 398 uncompressedStream += bytesPerLine; |
397 } | 399 } |
398 | 400 |
399 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 401 const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
400 bitmap->installPixels(info, uncompressedStreamArgb, info.minRowBytes()); | 402 bitmap->installPixels(info, uncompressedStreamArgb, info.minRowBytes()); |
401 } | 403 } |
402 else if ((colorSpace.equals("DeviceGray") || colorSpace.equals("Gray")) && b
pc == 8) { | 404 else if ((colorSpace.equals("DeviceGray") || colorSpace.equals("Gray")) && b
pc == 8) { |
403 unsigned char* uncompressedStreamA8 = (unsigned char*)malloc(width * hei
ght); | 405 unsigned char* uncompressedStreamA8 = (unsigned char*)malloc(width * hei
ght); |
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2906 | 2908 |
2907 rect = SkRect::MakeWH(width, height); | 2909 rect = SkRect::MakeWH(width, height); |
2908 | 2910 |
2909 setup_bitmap(output, SkScalarCeilToInt(width), SkScalarCeilToInt(height)); | 2911 setup_bitmap(output, SkScalarCeilToInt(width), SkScalarCeilToInt(height)); |
2910 | 2912 |
2911 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*output))); | 2913 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*output))); |
2912 SkCanvas canvas(device); | 2914 SkCanvas canvas(device); |
2913 | 2915 |
2914 return renderer->renderPage(page, &canvas, rect); | 2916 return renderer->renderPage(page, &canvas, rect); |
2915 } | 2917 } |
OLD | NEW |