Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: tests/ImageTest.cpp

Issue 1222683004: add colortable param to newrastercopy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #if SK_SUPPORT_GPU 96 #if SK_SUPPORT_GPU
97 DEF_GPUTEST(Image_Encode_Gpu, reporter, factory) { 97 DEF_GPUTEST(Image_Encode_Gpu, reporter, factory) {
98 GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType); 98 GrContext* ctx = factory->get(GrContextFactory::kNative_GLContextType);
99 if (!ctx) { 99 if (!ctx) {
100 REPORTER_ASSERT(reporter, false); 100 REPORTER_ASSERT(reporter, false);
101 return; 101 return;
102 } 102 }
103 test_encode(reporter, ctx); 103 test_encode(reporter, ctx);
104 } 104 }
105 #endif 105 #endif
106
107 DEF_TEST(Image_NewRasterCopy, reporter) {
108 const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0);
109 const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0);
110 const SkPMColor blue = SkPackARGB32(0xFF, 0, 0, 0xFF);
111 SkPMColor colors[] = { red, green, blue, 0 };
112 SkAutoTUnref<SkColorTable> ctable(SkNEW_ARGS(SkColorTable, (colors, SK_ARRAY _COUNT(colors))));
113 // The colortable made a copy, so we can trash the original colors
114 memset(colors, 0xFF, sizeof(colors));
115
116 const SkImageInfo srcInfo = SkImageInfo::Make(2, 2, kIndex_8_SkColorType, kP remul_SkAlphaType);
117 const size_t srcRowBytes = 2 * sizeof(uint8_t);
118 uint8_t indices[] = { 0, 1, 2, 3 };
119 SkAutoTUnref<SkImage> image(SkImage::NewRasterCopy(srcInfo, indices, srcRowB ytes, ctable));
120 // The image made a copy, so we can trash the original indices
121 memset(indices, 0xFF, sizeof(indices));
122
123 const SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(2, 2);
124 const size_t dstRowBytes = 2 * sizeof(SkPMColor);
125 SkPMColor pixels[4];
126 memset(pixels, 0xFF, sizeof(pixels)); // init with values we don't expect
127 image->readPixels(dstInfo, pixels, dstRowBytes, 0, 0);
128 REPORTER_ASSERT(reporter, red == pixels[0]);
129 REPORTER_ASSERT(reporter, green == pixels[1]);
130 REPORTER_ASSERT(reporter, blue == pixels[2]);
131 REPORTER_ASSERT(reporter, 0 == pixels[3]);
132 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698