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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 1226023003: Remove SkImageGenerator pieces only for SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@severIG
Patch Set: Change the public interface without staging it. 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/ports/SkImageGenerator_skia.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 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 SkASSERT((fType <= kLast_TestType) && (fType >= 0)); 175 SkASSERT((fType <= kLast_TestType) && (fType >= 0));
176 } 176 }
177 virtual ~TestImageGenerator() { } 177 virtual ~TestImageGenerator() { }
178 178
179 protected: 179 protected:
180 static SkImageInfo GetMyInfo() { 180 static SkImageInfo GetMyInfo() {
181 return SkImageInfo::MakeN32(TestImageGenerator::Width(), TestImageGenera tor::Height(), 181 return SkImageInfo::MakeN32(TestImageGenerator::Width(), TestImageGenera tor::Height(),
182 kOpaque_SkAlphaType); 182 kOpaque_SkAlphaType);
183 } 183 }
184 184
185 virtual Result onGetPixels(const SkImageInfo& info, void* pixels, size_t row Bytes, 185 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
186 const Options&, 186 Result onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
187 SkPMColor ctable[], int* ctableCount) override { 187 const Options&,
188 SkPMColor ctable[], int* ctableCount) override {
189 #else
190 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
191 SkPMColor ctable[], int* ctableCount) override {
192 #endif
188 REPORTER_ASSERT(fReporter, pixels != NULL); 193 REPORTER_ASSERT(fReporter, pixels != NULL);
189 REPORTER_ASSERT(fReporter, rowBytes >= info.minRowBytes()); 194 REPORTER_ASSERT(fReporter, rowBytes >= info.minRowBytes());
190 if (fType != kSucceedGetPixels_TestType) { 195 if (fType != kSucceedGetPixels_TestType) {
196 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
191 return kUnimplemented; 197 return kUnimplemented;
198 #else
199 return false;
200 #endif
192 } 201 }
193 if (info.colorType() != kN32_SkColorType) { 202 if (info.colorType() != kN32_SkColorType) {
203 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
194 return kInvalidConversion; 204 return kInvalidConversion;
205 #else
206 return false;
207 #endif
195 } 208 }
196 char* bytePtr = static_cast<char*>(pixels); 209 char* bytePtr = static_cast<char*>(pixels);
197 for (int y = 0; y < info.height(); ++y) { 210 for (int y = 0; y < info.height(); ++y) {
198 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), 211 sk_memset32(reinterpret_cast<SkColor*>(bytePtr),
199 TestImageGenerator::Color(), info.width()); 212 TestImageGenerator::Color(), info.width());
200 bytePtr += rowBytes; 213 bytePtr += rowBytes;
201 } 214 }
215 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
202 return kSuccess; 216 return kSuccess;
217 #else
218 return true;
219 #endif
203 } 220 }
204 221
205 private: 222 private:
206 const TestType fType; 223 const TestType fType;
207 skiatest::Reporter* const fReporter; 224 skiatest::Reporter* const fReporter;
208 225
209 typedef SkImageGenerator INHERITED; 226 typedef SkImageGenerator INHERITED;
210 }; 227 };
211 228
212 static void check_test_image_generator_bitmap(skiatest::Reporter* reporter, 229 static void check_test_image_generator_bitmap(skiatest::Reporter* reporter,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 canvas.clear(kDefaultColor); 352 canvas.clear(kDefaultColor);
336 canvas.drawImage(image, 0, 0, NULL); 353 canvas.drawImage(image, 0, 0, NULL);
337 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { 354 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
338 REPORTER_ASSERT( 355 REPORTER_ASSERT(
339 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); 356 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0));
340 } else { 357 } else {
341 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); 358 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0));
342 } 359 }
343 } 360 }
344 } 361 }
OLDNEW
« no previous file with comments | « src/ports/SkImageGenerator_skia.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698