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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 103753007: Revert of Change SkDecodingImageGenerator API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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/ImageDecodingTest.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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 } 140 }
141 bool comparePixels = (SkImageEncoder::kPNG_Type == type); 141 bool comparePixels = (SkImageEncoder::kPNG_Type == type);
142 compare_bitmaps(reporter, original, lazy, comparePixels); 142 compare_bitmaps(reporter, original, lazy, comparePixels);
143 } 143 }
144 } 144 }
145 145
146 //////////////////////////////////////////////////////////////////////////////// 146 ////////////////////////////////////////////////////////////////////////////////
147 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { 147 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) {
148 return SkCachingPixelRef::Install( 148 return SkCachingPixelRef::Install(
149 SkDecodingImageGenerator::Create( 149 SkNEW_ARGS(SkDecodingImageGenerator, (encoded)), dst);
150 encoded, SkDecodingImageGenerator::Options()), dst);
151 } 150 }
152 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { 151 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
153 // Use system-default discardable memory. 152 // Use system-default discardable memory.
154 return SkInstallDiscardablePixelRef( 153 return SkDecodingImageGenerator::Install(encoded, dst, NULL);
155 SkDecodingImageGenerator::Create(
156 encoded, SkDecodingImageGenerator::Options()), dst, NULL);
157 } 154 }
158 155
159 //////////////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////////////////
160 /** 157 /**
161 * This checks to see that a SkCachingPixelRef and a 158 * This checks to see that a SkCachingPixelRef and a
162 * SkDiscardablePixelRef works as advertised with a 159 * SkDiscardablePixelRef works as advertised with a
163 * SkDecodingImageGenerator. 160 * SkDecodingImageGenerator.
164 */ 161 */
165 DEF_TEST(DecodingImageGenerator, reporter) { 162 DEF_TEST(DecodingImageGenerator, reporter) {
166 test_three_encodings(reporter, install_skCachingPixelRef); 163 test_three_encodings(reporter, install_skCachingPixelRef);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return false; 206 return false;
210 } 207 }
211 char* bytePtr = static_cast<char*>(pixels); 208 char* bytePtr = static_cast<char*>(pixels);
212 for (int y = 0; y < info.fHeight; ++y) { 209 for (int y = 0; y < info.fHeight; ++y) {
213 sk_memset32(reinterpret_cast<SkColor*>(bytePtr), 210 sk_memset32(reinterpret_cast<SkColor*>(bytePtr),
214 TestImageGenerator::Color(), info.fWidth); 211 TestImageGenerator::Color(), info.fWidth);
215 bytePtr += rowBytes; 212 bytePtr += rowBytes;
216 } 213 }
217 return true; 214 return true;
218 } 215 }
219
220 private: 216 private:
221 const TestType fType; 217 const TestType fType;
222 skiatest::Reporter* const fReporter; 218 skiatest::Reporter* const fReporter;
223 }; 219 };
224
225 void CheckTestImageGeneratorBitmap(skiatest::Reporter* reporter, 220 void CheckTestImageGeneratorBitmap(skiatest::Reporter* reporter,
226 const SkBitmap& bm) { 221 const SkBitmap& bm) {
227 REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width()); 222 REPORTER_ASSERT(reporter, TestImageGenerator::Width() == bm.width());
228 REPORTER_ASSERT(reporter, TestImageGenerator::Height() == bm.height()); 223 REPORTER_ASSERT(reporter, TestImageGenerator::Height() == bm.height());
229 SkAutoLockPixels autoLockPixels(bm); 224 SkAutoLockPixels autoLockPixels(bm);
230 REPORTER_ASSERT(reporter, NULL != bm.getPixels()); 225 REPORTER_ASSERT(reporter, NULL != bm.getPixels());
231 if (NULL == bm.getPixels()) { 226 if (NULL == bm.getPixels()) {
232 return; 227 return;
233 } 228 }
234 int errors = 0; 229 int errors = 0;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); 314 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
320 // Only acts differently from NULL on a platform that has a 315 // Only acts differently from NULL on a platform that has a
321 // default discardable memory implementation that differs from the 316 // default discardable memory implementation that differs from the
322 // global DM pool. 317 // global DM pool.
323 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, 318 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType,
324 reporter, kSkDiscardable_PixelRefType, globalPool); 319 reporter, kSkDiscardable_PixelRefType, globalPool);
325 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, 320 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType,
326 reporter, kSkDiscardable_PixelRefType, globalPool); 321 reporter, kSkDiscardable_PixelRefType, globalPool);
327 } 322 }
328 //////////////////////////////////////////////////////////////////////////////// 323 ////////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.cpp ('k') | tests/ImageDecodingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698