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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 536003002: Hide fields in SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix qt Created 6 years, 3 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 | « tests/BlitRowTest.cpp ('k') | tests/CanvasTest.cpp » ('j') | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkCachingPixelRef.h" 9 #include "SkCachingPixelRef.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 SkASSERT((fType <= kLast_TestType) && (fType >= 0)); 181 SkASSERT((fType <= kLast_TestType) && (fType >= 0));
182 } 182 }
183 virtual ~TestImageGenerator() { } 183 virtual ~TestImageGenerator() { }
184 184
185 protected: 185 protected:
186 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { 186 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
187 REPORTER_ASSERT(fReporter, NULL != info); 187 REPORTER_ASSERT(fReporter, NULL != info);
188 if ((NULL == info) || (kFailGetInfo_TestType == fType)) { 188 if ((NULL == info) || (kFailGetInfo_TestType == fType)) {
189 return false; 189 return false;
190 } 190 }
191 info->fWidth = TestImageGenerator::Width(); 191 *info = SkImageInfo::MakeN32(TestImageGenerator::Width(),
192 info->fHeight = TestImageGenerator::Height(); 192 TestImageGenerator::Height(),
193 info->fColorType = kN32_SkColorType; 193 kOpaque_SkAlphaType);
194 info->fAlphaType = kOpaque_SkAlphaType;
195 return true; 194 return true;
196 } 195 }
197 196
198 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, 197 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes,
199 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE { 198 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE {
200 REPORTER_ASSERT(fReporter, pixels != NULL); 199 REPORTER_ASSERT(fReporter, pixels != NULL);
201 size_t minRowBytes 200 size_t minRowBytes = static_cast<size_t>(info.width() * info.bytesPerPix el());
202 = static_cast<size_t>(info.fWidth * info.bytesPerPixel());
203 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); 201 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes);
204 if ((NULL == pixels) 202 if ((NULL == pixels)
205 || (fType != kSucceedGetPixels_TestType) 203 || (fType != kSucceedGetPixels_TestType)
206 || (info.fColorType != kN32_SkColorType)) { 204 || (info.colorType() != kN32_SkColorType)) {
207 return false; 205 return false;
208 } 206 }
209 char* bytePtr = static_cast<char*>(pixels); 207 char* bytePtr = static_cast<char*>(pixels);
210 for (int y = 0; y < info.fHeight; ++y) { 208 for (int y = 0; y < info.height(); ++y) {
211 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), 209 sk_memset32(reinterpret_cast<SkColor*>(bytePtr),
212 TestImageGenerator::Color(), info.fWidth); 210 TestImageGenerator::Color(), info.width());
213 bytePtr += rowBytes; 211 bytePtr += rowBytes;
214 } 212 }
215 return true; 213 return true;
216 } 214 }
217 215
218 private: 216 private:
219 const TestType fType; 217 const TestType fType;
220 skiatest::Reporter* const fReporter; 218 skiatest::Reporter* const fReporter;
221 }; 219 };
222 220
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 canvas.clear(kDefaultColor); 352 canvas.clear(kDefaultColor);
355 image->draw(&canvas, 0, 0, NULL); 353 image->draw(&canvas, 0, 0, NULL);
356 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { 354 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
357 REPORTER_ASSERT( 355 REPORTER_ASSERT(
358 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); 356 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0));
359 } else { 357 } else {
360 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); 358 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0));
361 } 359 }
362 } 360 }
363 } 361 }
OLDNEW
« no previous file with comments | « tests/BlitRowTest.cpp ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698