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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, false, srcData, 0)); | 670 ctx->textureProvider()->createTexture(desc, false, srcData, 0)); |
671 | 671 |
| 672 if (!texture) { |
| 673 continue; |
| 674 } |
| 675 |
672 SkBitmap srcBmp; | 676 SkBitmap srcBmp; |
673 GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp); | 677 GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp); |
674 if (srcBmp.isNull()) { | 678 if (srcBmp.isNull()) { |
675 ERRORF(reporter, "Could not wrap texture in bitmap."); | 679 ERRORF(reporter, "Could not wrap texture in bitmap."); |
676 continue; | 680 continue; |
677 } | 681 } |
678 static const SkColorType kDstCTs[] = { kRGBA_8888_SkColorType, kBGRA
_8888_SkColorType }; | 682 static const SkColorType kDstCTs[] = { kRGBA_8888_SkColorType, kBGRA
_8888_SkColorType }; |
679 for (size_t dCT = 0; dCT < SK_ARRAY_COUNT(kDstCTs); ++dCT) { | 683 for (size_t dCT = 0; dCT < SK_ARRAY_COUNT(kDstCTs); ++dCT) { |
680 SkBitmap dstBmp; | 684 SkBitmap dstBmp; |
681 if (!srcBmp.copyTo(&dstBmp, kDstCTs[dCT])) { | 685 if (!srcBmp.copyTo(&dstBmp, kDstCTs[dCT])) { |
(...skipping 23 matching lines...) Expand all Loading... |
705 } | 709 } |
706 } | 710 } |
707 dstBmpPixels += dstBmp.rowBytes(); | 711 dstBmpPixels += dstBmp.rowBytes(); |
708 } | 712 } |
709 } | 713 } |
710 } | 714 } |
711 } | 715 } |
712 } | 716 } |
713 | 717 |
714 #endif | 718 #endif |
OLD | NEW |