OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
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 "SkPDFImage.h" | 8 #include "SkPDFImage.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 void SkPDFImage::getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 384 void SkPDFImage::getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
385 SkTSet<SkPDFObject*>* newResourceObjects) { | 385 SkTSet<SkPDFObject*>* newResourceObjects) { |
386 GetResourcesHelper(&fResources, knownResourceObjects, newResourceObjects); | 386 GetResourcesHelper(&fResources, knownResourceObjects, newResourceObjects); |
387 } | 387 } |
388 | 388 |
389 SkPDFImage::SkPDFImage(SkStream* stream, | 389 SkPDFImage::SkPDFImage(SkStream* stream, |
390 const SkBitmap& bitmap, | 390 const SkBitmap& bitmap, |
391 bool isAlpha, | 391 bool isAlpha, |
392 const SkIRect& srcRect, | 392 const SkIRect& srcRect, |
393 EncodeToDCTStream encoder) | 393 EncodeToDCTStream encoder) |
394 : fBitmap(bitmap), | 394 : fIsAlpha(isAlpha), |
395 fIsAlpha(isAlpha), | |
396 fSrcRect(srcRect), | 395 fSrcRect(srcRect), |
397 fEncoder(encoder) { | 396 fEncoder(encoder) { |
398 | 397 |
| 398 if (bitmap.isImmutable()) { |
| 399 fBitmap = bitmap; |
| 400 } else { |
| 401 bitmap.deepCopyTo(&fBitmap, bitmap.config()); |
| 402 fBitmap.setImmutable(); |
| 403 } |
| 404 |
399 if (stream != NULL) { | 405 if (stream != NULL) { |
400 setData(stream); | 406 setData(stream); |
401 fStreamValid = true; | 407 fStreamValid = true; |
402 } else { | 408 } else { |
403 fStreamValid = false; | 409 fStreamValid = false; |
404 } | 410 } |
405 | 411 |
406 SkBitmap::Config config = fBitmap.getConfig(); | 412 SkBitmap::Config config = fBitmap.getConfig(); |
407 | 413 |
408 insertName("Type", "XObject"); | 414 insertName("Type", "XObject"); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // but the new catalog wants it compressed. | 511 // but the new catalog wants it compressed. |
506 if (!getSubstitute()) { | 512 if (!getSubstitute()) { |
507 SkPDFStream* substitute = SkNEW_ARGS(SkPDFImage, (*this)); | 513 SkPDFStream* substitute = SkNEW_ARGS(SkPDFImage, (*this)); |
508 setSubstitute(substitute); | 514 setSubstitute(substitute); |
509 catalog->setSubstitute(this, substitute); | 515 catalog->setSubstitute(this, substitute); |
510 } | 516 } |
511 return false; | 517 return false; |
512 } | 518 } |
513 return true; | 519 return true; |
514 } | 520 } |
OLD | NEW |