| 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 "Test.h" | 10 #include "Test.h" |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurface
Flags; | 677 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurface
Flags; |
| 678 desc.fWidth = 2; | 678 desc.fWidth = 2; |
| 679 desc.fHeight = 2; | 679 desc.fHeight = 2; |
| 680 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 680 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 681 | 681 |
| 682 const void* srcData = (kSkia8888_GrPixelConfig == desc.fConfig)
? kData : swizData; | 682 const void* srcData = (kSkia8888_GrPixelConfig == desc.fConfig)
? kData : swizData; |
| 683 | 683 |
| 684 SkAutoTUnref<GrTexture> texture( | 684 SkAutoTUnref<GrTexture> texture( |
| 685 ctx->textureProvider()->createTexture(desc, false, srcData,
0)); | 685 ctx->textureProvider()->createTexture(desc, false, srcData,
0)); |
| 686 | 686 |
| 687 if (!texture) { |
| 688 continue; |
| 689 } |
| 690 |
| 687 SkBitmap srcBmp; | 691 SkBitmap srcBmp; |
| 688 GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp); | 692 GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp); |
| 689 if (srcBmp.isNull()) { | 693 if (srcBmp.isNull()) { |
| 690 ERRORF(reporter, "Could not wrap texture in bitmap."); | 694 ERRORF(reporter, "Could not wrap texture in bitmap."); |
| 691 continue; | 695 continue; |
| 692 } | 696 } |
| 693 static const SkColorType kDstCTs[] = { kRGBA_8888_SkColorType, k
BGRA_8888_SkColorType }; | 697 static const SkColorType kDstCTs[] = { kRGBA_8888_SkColorType, k
BGRA_8888_SkColorType }; |
| 694 for (size_t dCT = 0; dCT < SK_ARRAY_COUNT(kDstCTs); ++dCT) { | 698 for (size_t dCT = 0; dCT < SK_ARRAY_COUNT(kDstCTs); ++dCT) { |
| 695 SkBitmap dstBmp; | 699 SkBitmap dstBmp; |
| 696 if (!srcBmp.copyTo(&dstBmp, kDstCTs[dCT])) { | 700 if (!srcBmp.copyTo(&dstBmp, kDstCTs[dCT])) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 721 } | 725 } |
| 722 dstBmpPixels += dstBmp.rowBytes(); | 726 dstBmpPixels += dstBmp.rowBytes(); |
| 723 } | 727 } |
| 724 } | 728 } |
| 725 } | 729 } |
| 726 } | 730 } |
| 727 } | 731 } |
| 728 } | 732 } |
| 729 | 733 |
| 730 #endif | 734 #endif |
| OLD | NEW |