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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkRect.h" | 9 #include "SkRect.h" |
10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 632 } |
633 } | 633 } |
634 | 634 |
635 #if SK_SUPPORT_GPU | 635 #if SK_SUPPORT_GPU |
636 | 636 |
637 #include "GrContext.h" | 637 #include "GrContext.h" |
638 #include "SkGr.h" | 638 #include "SkGr.h" |
639 #include "SkColorPriv.h" | 639 #include "SkColorPriv.h" |
640 /** Tests calling copyTo on a texture backed bitmap. Tests that all BGRA_8888/RG
BA_8888 combinations | 640 /** Tests calling copyTo on a texture backed bitmap. Tests that all BGRA_8888/RG
BA_8888 combinations |
641 of src and dst work. This test should be removed when SkGrPixelRef is remove
d. */ | 641 of src and dst work. This test should be removed when SkGrPixelRef is remove
d. */ |
642 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BitmapCopy_Texture, reporter, ctx) { | 642 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BitmapCopy_Texture, reporter, ctxInfo) { |
643 static const SkPMColor kData[] = { | 643 static const SkPMColor kData[] = { |
644 0xFF112233, 0xAF224499, | 644 0xFF112233, 0xAF224499, |
645 0xEF004466, 0x80773311 | 645 0xEF004466, 0x80773311 |
646 }; | 646 }; |
647 | 647 |
648 uint32_t swizData[SK_ARRAY_COUNT(kData)]; | 648 uint32_t swizData[SK_ARRAY_COUNT(kData)]; |
649 for (size_t i = 0; i < SK_ARRAY_COUNT(kData); ++i) { | 649 for (size_t i = 0; i < SK_ARRAY_COUNT(kData); ++i) { |
650 swizData[i] = SkSwizzle_RB(kData[i]); | 650 swizData[i] = SkSwizzle_RB(kData[i]); |
651 } | 651 } |
652 | 652 |
653 static const GrPixelConfig kSrcConfigs[] = { | 653 static const GrPixelConfig kSrcConfigs[] = { |
654 kRGBA_8888_GrPixelConfig, | 654 kRGBA_8888_GrPixelConfig, |
655 kBGRA_8888_GrPixelConfig, | 655 kBGRA_8888_GrPixelConfig, |
656 }; | 656 }; |
657 | 657 |
658 for (size_t srcC = 0; srcC < SK_ARRAY_COUNT(kSrcConfigs); ++srcC) { | 658 for (size_t srcC = 0; srcC < SK_ARRAY_COUNT(kSrcConfigs); ++srcC) { |
659 for (int rt = 0; rt < 2; ++rt) { | 659 for (int rt = 0; rt < 2; ++rt) { |
660 GrSurfaceDesc desc; | 660 GrSurfaceDesc desc; |
661 desc.fConfig = kSrcConfigs[srcC]; | 661 desc.fConfig = kSrcConfigs[srcC]; |
662 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlag
s; | 662 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlag
s; |
663 desc.fWidth = 2; | 663 desc.fWidth = 2; |
664 desc.fHeight = 2; | 664 desc.fHeight = 2; |
665 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 665 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
666 | 666 |
667 const void* srcData = (kSkia8888_GrPixelConfig == desc.fConfig) ? kD
ata : swizData; | 667 const void* srcData = (kSkia8888_GrPixelConfig == desc.fConfig) ? kD
ata : swizData; |
668 | 668 |
669 SkAutoTUnref<GrTexture> texture( | 669 SkAutoTUnref<GrTexture> texture( |
670 ctx->textureProvider()->createTexture(desc, SkBudgeted::kNo, src
Data, 0)); | 670 ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBud
geted::kNo, srcData, |
| 671 0)); |
671 | 672 |
672 if (!texture) { | 673 if (!texture) { |
673 continue; | 674 continue; |
674 } | 675 } |
675 | 676 |
676 SkBitmap srcBmp; | 677 SkBitmap srcBmp; |
677 GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp); | 678 GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp); |
678 if (srcBmp.isNull()) { | 679 if (srcBmp.isNull()) { |
679 ERRORF(reporter, "Could not wrap texture in bitmap."); | 680 ERRORF(reporter, "Could not wrap texture in bitmap."); |
680 continue; | 681 continue; |
(...skipping 28 matching lines...) Expand all Loading... |
709 } | 710 } |
710 } | 711 } |
711 dstBmpPixels += dstBmp.rowBytes(); | 712 dstBmpPixels += dstBmp.rowBytes(); |
712 } | 713 } |
713 } | 714 } |
714 } | 715 } |
715 } | 716 } |
716 } | 717 } |
717 | 718 |
718 #endif | 719 #endif |
OLD | NEW |