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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 304443003: add colortable support to imagegenerator (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix spelling Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.cpp ('k') | tests/DrawBitmapRectTest.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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 kLast_TestType = kSucceedGetPixels_TestType 176 kLast_TestType = kSucceedGetPixels_TestType
177 }; 177 };
178 static int Width() { return 10; } 178 static int Width() { return 10; }
179 static int Height() { return 10; } 179 static int Height() { return 10; }
180 static SkColor Color() { return SK_ColorCYAN; } 180 static SkColor Color() { return SK_ColorCYAN; }
181 TestImageGenerator(TestType type, skiatest::Reporter* reporter) 181 TestImageGenerator(TestType type, skiatest::Reporter* reporter)
182 : fType(type), fReporter(reporter) { 182 : fType(type), fReporter(reporter) {
183 SkASSERT((fType <= kLast_TestType) && (fType >= 0)); 183 SkASSERT((fType <= kLast_TestType) && (fType >= 0));
184 } 184 }
185 virtual ~TestImageGenerator() { } 185 virtual ~TestImageGenerator() { }
186 virtual bool getInfo(SkImageInfo* info) SK_OVERRIDE { 186
187 protected:
188 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
187 REPORTER_ASSERT(fReporter, NULL != info); 189 REPORTER_ASSERT(fReporter, NULL != info);
188 if ((NULL == info) || (kFailGetInfo_TestType == fType)) { 190 if ((NULL == info) || (kFailGetInfo_TestType == fType)) {
189 return false; 191 return false;
190 } 192 }
191 info->fWidth = TestImageGenerator::Width(); 193 info->fWidth = TestImageGenerator::Width();
192 info->fHeight = TestImageGenerator::Height(); 194 info->fHeight = TestImageGenerator::Height();
193 info->fColorType = kN32_SkColorType; 195 info->fColorType = kN32_SkColorType;
194 info->fAlphaType = kOpaque_SkAlphaType; 196 info->fAlphaType = kOpaque_SkAlphaType;
195 return true; 197 return true;
196 } 198 }
197 virtual bool getPixels(const SkImageInfo& info, 199
198 void* pixels, 200 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes,
199 size_t rowBytes) SK_OVERRIDE { 201 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE {
200 REPORTER_ASSERT(fReporter, pixels != NULL); 202 REPORTER_ASSERT(fReporter, pixels != NULL);
201 size_t minRowBytes 203 size_t minRowBytes
202 = static_cast<size_t>(info.fWidth * info.bytesPerPixel()); 204 = static_cast<size_t>(info.fWidth * info.bytesPerPixel());
203 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes); 205 REPORTER_ASSERT(fReporter, rowBytes >= minRowBytes);
204 if ((NULL == pixels) 206 if ((NULL == pixels)
205 || (fType != kSucceedGetPixels_TestType) 207 || (fType != kSucceedGetPixels_TestType)
206 || (info.fColorType != kN32_SkColorType)) { 208 || (info.fColorType != kN32_SkColorType)) {
207 return false; 209 return false;
208 } 210 }
209 char* bytePtr = static_cast<char*>(pixels); 211 char* bytePtr = static_cast<char*>(pixels);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 317
316 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); 318 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
317 // Only acts differently from NULL on a platform that has a 319 // Only acts differently from NULL on a platform that has a
318 // default discardable memory implementation that differs from the 320 // default discardable memory implementation that differs from the
319 // global DM pool. 321 // global DM pool.
320 check_pixelref(TestImageGenerator::kFailGetPixels_TestType, 322 check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
321 reporter, kSkDiscardable_PixelRefType, globalPool); 323 reporter, kSkDiscardable_PixelRefType, globalPool);
322 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, 324 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
323 reporter, kSkDiscardable_PixelRefType, globalPool); 325 reporter, kSkDiscardable_PixelRefType, globalPool);
324 } 326 }
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.cpp ('k') | tests/DrawBitmapRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698