| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 <functional> | 8 #include <functional> |
| 9 #include <initializer_list> | 9 #include <initializer_list> |
| 10 #include "DMGpuSupport.h" | 10 #include "DMGpuSupport.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 SkPaint paint; | 58 SkPaint paint; |
| 59 paint.setColor(SK_ColorBLACK); | 59 paint.setColor(SK_ColorBLACK); |
| 60 canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 10), paint); | 60 canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 10), paint); |
| 61 } | 61 } |
| 62 static SkImage* create_image() { | 62 static SkImage* create_image() { |
| 63 const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); | 63 const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); |
| 64 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); | 64 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); |
| 65 draw_image_test_pattern(surface->getCanvas()); | 65 draw_image_test_pattern(surface->getCanvas()); |
| 66 return surface->newImageSnapshot(); | 66 return surface->newImageSnapshot(); |
| 67 } | 67 } |
| 68 #if 0 | |
| 69 static SkImage* create_image_565() { | 68 static SkImage* create_image_565() { |
| 70 const SkImageInfo info = SkImageInfo::Make(20, 20, kRGB_565_SkColorType, kOp
aque_SkAlphaType); | 69 const SkImageInfo info = SkImageInfo::Make(20, 20, kRGB_565_SkColorType, kOp
aque_SkAlphaType); |
| 71 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); | 70 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); |
| 72 draw_image_test_pattern(surface->getCanvas()); | 71 draw_image_test_pattern(surface->getCanvas()); |
| 73 return surface->newImageSnapshot(); | 72 return surface->newImageSnapshot(); |
| 74 } | 73 } |
| 75 #endif | |
| 76 static SkImage* create_image_ct() { | 74 static SkImage* create_image_ct() { |
| 77 SkPMColor colors[] = { | 75 SkPMColor colors[] = { |
| 78 SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00), | 76 SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00), |
| 79 SkPreMultiplyARGB(0x80, 0x00, 0xA0, 0xFF), | 77 SkPreMultiplyARGB(0x80, 0x00, 0xA0, 0xFF), |
| 80 SkPreMultiplyARGB(0xFF, 0xBB, 0x00, 0xBB) | 78 SkPreMultiplyARGB(0xFF, 0xBB, 0x00, 0xBB) |
| 81 }; | 79 }; |
| 82 SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, SK_ARRAY_COUN
T(colors))); | 80 SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, SK_ARRAY_COUN
T(colors))); |
| 83 uint8_t data[] = { | 81 uint8_t data[] = { |
| 84 0, 0, 0, 0, 0, | 82 0, 0, 0, 0, 0, |
| 85 0, 1, 1, 1, 0, | 83 0, 1, 1, 1, 0, |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 if (pixelA != pixelB) { | 791 if (pixelA != pixelB) { |
| 794 ERRORF(reporter, "Expected image pixels to be the same. At %d,%d
0x%08x != 0x%08x", | 792 ERRORF(reporter, "Expected image pixels to be the same. At %d,%d
0x%08x != 0x%08x", |
| 795 x, y, pixelA, pixelB); | 793 x, y, pixelA, pixelB); |
| 796 return; | 794 return; |
| 797 } | 795 } |
| 798 } | 796 } |
| 799 } | 797 } |
| 800 } | 798 } |
| 801 | 799 |
| 802 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(NewTextureFromPixmap, reporter, context) { | 800 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(NewTextureFromPixmap, reporter, context) { |
| 803 for (auto create : {&create_image | 801 for (auto create : {&create_image, |
| 804 #if 0 // read pixels failing for non RT formats (565 not a RT on some desktop GL
s). | 802 &create_image_565, |
| 805 , &create_image_565 | 803 &create_image_ct}) { |
| 806 #endif | |
| 807 , &create_image_ct | |
| 808 }) { | |
| 809 SkAutoTUnref<SkImage> image((*create)()); | 804 SkAutoTUnref<SkImage> image((*create)()); |
| 810 if (!image) { | 805 if (!image) { |
| 811 ERRORF(reporter, "Could not create image"); | 806 ERRORF(reporter, "Could not create image"); |
| 812 return; | 807 return; |
| 813 } | 808 } |
| 814 | 809 |
| 815 SkPixmap pixmap; | 810 SkPixmap pixmap; |
| 816 if (!image->peekPixels(&pixmap)) { | 811 if (!image->peekPixels(&pixmap)) { |
| 817 ERRORF(reporter, "peek failed"); | 812 ERRORF(reporter, "peek failed"); |
| 818 } else { | 813 } else { |
| 819 SkAutoTUnref<SkImage> texImage(SkImage::NewTextureFromPixmap(context
, pixmap, | 814 SkAutoTUnref<SkImage> texImage(SkImage::NewTextureFromPixmap(context
, pixmap, |
| 820 SkBudge
ted::kNo)); | 815 SkBudge
ted::kNo)); |
| 821 if (!texImage) { | 816 if (!texImage) { |
| 822 ERRORF(reporter, "NewTextureFromPixmap failed."); | 817 ERRORF(reporter, "NewTextureFromPixmap failed."); |
| 823 } else { | 818 } else { |
| 824 check_images_same(reporter, image, texImage); | 819 check_images_same(reporter, image, texImage); |
| 825 } | 820 } |
| 826 } | 821 } |
| 827 } | 822 } |
| 828 } | 823 } |
| 829 | 824 |
| 830 #endif | 825 #endif |
| OLD | NEW |