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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 295243006: hide discardable factory from public imagegenerator api (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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
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"
11 #include "SkData.h" 11 #include "SkData.h"
12 #include "SkDecodingImageGenerator.h" 12 #include "SkDecodingImageGenerator.h"
13 #include "SkDiscardableMemoryPool.h" 13 #include "SkDiscardableMemoryPool.h"
14 #include "SkImageDecoder.h" 14 #include "SkImageDecoder.h"
15 #include "SkImageGeneratorPriv.h"
15 #include "SkScaledImageCache.h" 16 #include "SkScaledImageCache.h"
16 #include "SkStream.h" 17 #include "SkStream.h"
17 #include "SkUtils.h" 18 #include "SkUtils.h"
18 19
19 #include "Test.h" 20 #include "Test.h"
20 21
21 /** 22 /**
22 * Fill this bitmap with some color. 23 * Fill this bitmap with some color.
23 */ 24 */
24 static void make_test_image(SkBitmap* bm) { 25 static void make_test_image(SkBitmap* bm) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 //////////////////////////////////////////////////////////////////////////////// 146 ////////////////////////////////////////////////////////////////////////////////
146 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { 147 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) {
147 return SkCachingPixelRef::Install( 148 return SkCachingPixelRef::Install(
148 SkDecodingImageGenerator::Create( 149 SkDecodingImageGenerator::Create(
149 encoded, SkDecodingImageGenerator::Options()), dst); 150 encoded, SkDecodingImageGenerator::Options()), dst);
150 } 151 }
151 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { 152 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
152 // Use system-default discardable memory. 153 // Use system-default discardable memory.
153 return SkInstallDiscardablePixelRef( 154 return SkInstallDiscardablePixelRef(
154 SkDecodingImageGenerator::Create( 155 SkDecodingImageGenerator::Create(
155 encoded, SkDecodingImageGenerator::Options()), dst, NULL); 156 encoded, SkDecodingImageGenerator::Options()), dst);
156 } 157 }
157 158
158 //////////////////////////////////////////////////////////////////////////////// 159 ////////////////////////////////////////////////////////////////////////////////
159 /** 160 /**
160 * This checks to see that a SkCachingPixelRef and a 161 * This checks to see that a SkCachingPixelRef and a
161 * SkDiscardablePixelRef works as advertised with a 162 * SkDiscardablePixelRef works as advertised with a
162 * SkDecodingImageGenerator. 163 * SkDecodingImageGenerator.
163 */ 164 */
164 DEF_TEST(DecodingImageGenerator, reporter) { 165 DEF_TEST(DecodingImageGenerator, reporter) {
165 test_three_encodings(reporter, install_skCachingPixelRef); 166 test_three_encodings(reporter, install_skCachingPixelRef);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 SkAutoLockPixels autoLockPixels(lazy); 270 SkAutoLockPixels autoLockPixels(lazy);
270 REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); 271 REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
271 } 272 }
272 } 273 }
273 274
274 // new/lock/delete is an odd pattern for a pixelref, but it needs to not assert 275 // new/lock/delete is an odd pattern for a pixelref, but it needs to not assert
275 static void test_newlockdelete(skiatest::Reporter* reporter) { 276 static void test_newlockdelete(skiatest::Reporter* reporter) {
276 SkBitmap bm; 277 SkBitmap bm;
277 SkImageGenerator* ig = new TestImageGenerator( 278 SkImageGenerator* ig = new TestImageGenerator(
278 TestImageGenerator::kSucceedGetPixels_TestType, reporter); 279 TestImageGenerator::kSucceedGetPixels_TestType, reporter);
279 SkInstallDiscardablePixelRef(ig, &bm, NULL); 280 SkInstallDiscardablePixelRef(ig, &bm);
280 bm.pixelRef()->lockPixels(); 281 bm.pixelRef()->lockPixels();
281 } 282 }
282 283
283 /** 284 /**
284 * This tests the basic functionality of SkDiscardablePixelRef with a 285 * This tests the basic functionality of SkDiscardablePixelRef with a
285 * basic SkImageGenerator implementation and several 286 * basic SkImageGenerator implementation and several
286 * SkDiscardableMemory::Factory choices. 287 * SkDiscardableMemory::Factory choices.
287 */ 288 */
288 DEF_TEST(DiscardableAndCachingPixelRef, reporter) { 289 DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
289 test_newlockdelete(reporter); 290 test_newlockdelete(reporter);
(...skipping 24 matching lines...) Expand all
314 315
315 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); 316 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
316 // Only acts differently from NULL on a platform that has a 317 // Only acts differently from NULL on a platform that has a
317 // default discardable memory implementation that differs from the 318 // default discardable memory implementation that differs from the
318 // global DM pool. 319 // global DM pool.
319 check_pixelref(TestImageGenerator::kFailGetPixels_TestType, 320 check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
320 reporter, kSkDiscardable_PixelRefType, globalPool); 321 reporter, kSkDiscardable_PixelRefType, globalPool);
321 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, 322 check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
322 reporter, kSkDiscardable_PixelRefType, globalPool); 323 reporter, kSkDiscardable_PixelRefType, globalPool);
323 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698