OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 417 |
418 // if the bitmap has pixels allocated before the readPixels, | 418 // if the bitmap has pixels allocated before the readPixels, |
419 // note that and fill them with pattern | 419 // note that and fill them with pattern |
420 bool startsWithPixels = !bmp.isNull(); | 420 bool startsWithPixels = !bmp.isNull(); |
421 // Try doing the read directly from a non-renderable texture | 421 // Try doing the read directly from a non-renderable texture |
422 if (startsWithPixels) { | 422 if (startsWithPixels) { |
423 fill_dst_bmp_with_init_data(&bmp); | 423 fill_dst_bmp_with_init_data(&bmp); |
424 GrPixelConfig dstConfig = | 424 GrPixelConfig dstConfig = |
425 SkImageInfo2GrPixelConfig(gReadPixelsConfigs[c].fCol
orType, | 425 SkImageInfo2GrPixelConfig(gReadPixelsConfigs[c].fCol
orType, |
426 gReadPixelsConfigs[c].fAlp
haType, | 426 gReadPixelsConfigs[c].fAlp
haType, |
427 kLinear_SkColorProfileType
, | 427 kLinear_SkColorProfileType
); |
428 *texture->getContext()->ca
ps()); | |
429 uint32_t flags = 0; | 428 uint32_t flags = 0; |
430 if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaTyp
e) { | 429 if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaTyp
e) { |
431 flags = GrContext::kUnpremul_PixelOpsFlag; | 430 flags = GrContext::kUnpremul_PixelOpsFlag; |
432 } | 431 } |
433 bmp.lockPixels(); | 432 bmp.lockPixels(); |
434 bool success = texture->readPixels(srcRect.fLeft, srcRect.fT
op, bmp.width(), | 433 bool success = texture->readPixels(srcRect.fLeft, srcRect.fT
op, bmp.width(), |
435 bmp.height(), dstConfig,
bmp.getPixels(), | 434 bmp.height(), dstConfig,
bmp.getPixels(), |
436 bmp.rowBytes(), flags); | 435 bmp.rowBytes(), flags); |
437 bmp.unlockPixels(); | 436 bmp.unlockPixels(); |
438 check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop, | 437 check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality))
; | 617 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality))
; |
619 | 618 |
620 REPORTER_ASSERT(reporter, dataA->equals(dataB)); | 619 REPORTER_ASSERT(reporter, dataA->equals(dataB)); |
621 if (false) { | 620 if (false) { |
622 dump_to_file("test_image_A.png", dataA); | 621 dump_to_file("test_image_A.png", dataA); |
623 dump_to_file("test_image_B.png", dataB); | 622 dump_to_file("test_image_B.png", dataB); |
624 } | 623 } |
625 } | 624 } |
626 } | 625 } |
627 #endif | 626 #endif |
OLD | NEW |