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 <vector> | 10 #include <vector> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SkPaint paint; | 61 SkPaint paint; |
62 paint.setColor(SK_ColorBLACK); | 62 paint.setColor(SK_ColorBLACK); |
63 canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 10), paint); | 63 canvas->drawRect(SkRect::MakeXYWH(5, 5, 10, 10), paint); |
64 } | 64 } |
65 static sk_sp<SkImage> create_image() { | 65 static sk_sp<SkImage> create_image() { |
66 const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); | 66 const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); |
67 auto surface(SkSurface::MakeRaster(info)); | 67 auto surface(SkSurface::MakeRaster(info)); |
68 draw_image_test_pattern(surface->getCanvas()); | 68 draw_image_test_pattern(surface->getCanvas()); |
69 return surface->makeImageSnapshot(); | 69 return surface->makeImageSnapshot(); |
70 } | 70 } |
71 static sk_sp<SkImage> create_image_large() { | |
72 const SkImageInfo info = SkImageInfo::MakeN32(32000, 32, kOpaque_SkAlphaType
); | |
73 auto surface(SkSurface::MakeRaster(info)); | |
74 surface->getCanvas()->clear(SK_ColorWHITE); | |
75 SkPaint paint; | |
76 paint.setColor(SK_ColorBLACK); | |
77 surface->getCanvas()->drawRect(SkRect::MakeXYWH(4000, 2, 28000, 30), paint); | |
78 return surface->makeImageSnapshot(); | |
79 } | |
80 | |
81 static SkData* create_image_data(SkImageInfo* info) { | 71 static SkData* create_image_data(SkImageInfo* info) { |
82 *info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); | 72 *info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); |
83 const size_t rowBytes = info->minRowBytes(); | 73 const size_t rowBytes = info->minRowBytes(); |
84 SkAutoTUnref<SkData> data(SkData::NewUninitialized(rowBytes * info->height()
)); | 74 SkAutoTUnref<SkData> data(SkData::NewUninitialized(rowBytes * info->height()
)); |
85 { | 75 { |
86 SkBitmap bm; | 76 SkBitmap bm; |
87 bm.installPixels(*info, data->writable_data(), rowBytes); | 77 bm.installPixels(*info, data->writable_data(), rowBytes); |
88 SkCanvas canvas(bm); | 78 SkCanvas canvas(bm); |
89 draw_image_test_pattern(&canvas); | 79 draw_image_test_pattern(&canvas); |
90 } | 80 } |
91 return data.release(); | 81 return data.release(); |
92 } | 82 } |
93 static sk_sp<SkImage> create_data_image() { | 83 static sk_sp<SkImage> create_data_image() { |
94 SkImageInfo info; | 84 SkImageInfo info; |
95 sk_sp<SkData> data(create_image_data(&info)); | 85 sk_sp<SkData> data(create_image_data(&info)); |
96 return SkImage::MakeRasterData(info, data, info.minRowBytes()); | 86 return SkImage::MakeRasterData(info, data, info.minRowBytes()); |
97 } | 87 } |
98 #if SK_SUPPORT_GPU // not gpu-specific but currently only used in GPU tests | 88 #if SK_SUPPORT_GPU // not gpu-specific but currently only used in GPU tests |
99 static sk_sp<SkImage> create_image_565() { | 89 static sk_sp<SkImage> create_image_565() { |
100 const SkImageInfo info = SkImageInfo::Make(20, 20, kRGB_565_SkColorType, kOp
aque_SkAlphaType); | 90 const SkImageInfo info = SkImageInfo::Make(20, 20, kRGB_565_SkColorType, kOp
aque_SkAlphaType); |
101 auto surface(SkSurface::MakeRaster(info)); | 91 auto surface(SkSurface::MakeRaster(info)); |
102 draw_image_test_pattern(surface->getCanvas()); | 92 draw_image_test_pattern(surface->getCanvas()); |
103 return surface->makeImageSnapshot(); | 93 return surface->makeImageSnapshot(); |
104 } | 94 } |
| 95 static sk_sp<SkImage> create_image_large() { |
| 96 const SkImageInfo info = SkImageInfo::MakeN32(32000, 32, kOpaque_SkAlphaType
); |
| 97 auto surface(SkSurface::MakeRaster(info)); |
| 98 surface->getCanvas()->clear(SK_ColorWHITE); |
| 99 SkPaint paint; |
| 100 paint.setColor(SK_ColorBLACK); |
| 101 surface->getCanvas()->drawRect(SkRect::MakeXYWH(4000, 2, 28000, 30), paint); |
| 102 return surface->makeImageSnapshot(); |
| 103 } |
105 static sk_sp<SkImage> create_image_ct() { | 104 static sk_sp<SkImage> create_image_ct() { |
106 SkPMColor colors[] = { | 105 SkPMColor colors[] = { |
107 SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00), | 106 SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00), |
108 SkPreMultiplyARGB(0x80, 0x00, 0xA0, 0xFF), | 107 SkPreMultiplyARGB(0x80, 0x00, 0xA0, 0xFF), |
109 SkPreMultiplyARGB(0xFF, 0xBB, 0x00, 0xBB) | 108 SkPreMultiplyARGB(0xFF, 0xBB, 0x00, 0xBB) |
110 }; | 109 }; |
111 SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, SK_ARRAY_COUN
T(colors))); | 110 SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, SK_ARRAY_COUN
T(colors))); |
112 uint8_t data[] = { | 111 uint8_t data[] = { |
113 0, 0, 0, 0, 0, | 112 0, 0, 0, 0, 0, |
114 0, 1, 1, 1, 0, | 113 0, 1, 1, 1, 0, |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 otherContextInfo.grContext(), buffer, budgeted)); | 926 otherContextInfo.grContext(), buffer, budgeted)); |
928 REPORTER_ASSERT(reporter, !newImage2); | 927 REPORTER_ASSERT(reporter, !newImage2); |
929 testContext->makeCurrent(); | 928 testContext->makeCurrent(); |
930 } | 929 } |
931 } | 930 } |
932 sk_free(buffer); | 931 sk_free(buffer); |
933 } | 932 } |
934 } | 933 } |
935 } | 934 } |
936 #endif | 935 #endif |
OLD | NEW |