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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 834633006: add ImageGenerator::NewFromData to porting layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add helper for SkInstallDiscardablePixelRef(SkData*, ...) Created 5 years, 11 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
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"
13 #include "SkDiscardableMemoryPool.h" 12 #include "SkDiscardableMemoryPool.h"
14 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
15 #include "SkImageGeneratorPriv.h" 14 #include "SkImageGeneratorPriv.h"
16 #include "SkResourceCache.h" 15 #include "SkResourceCache.h"
17 #include "SkStream.h" 16 #include "SkStream.h"
18 #include "SkUtils.h" 17 #include "SkUtils.h"
19 18
20 #include "Test.h" 19 #include "Test.h"
21 20
22 /** 21 /**
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 continue; 135 continue;
137 } 136 }
138 } 137 }
139 bool comparePixels = (SkImageEncoder::kPNG_Type == type); 138 bool comparePixels = (SkImageEncoder::kPNG_Type == type);
140 compare_bitmaps(reporter, original, lazy, comparePixels); 139 compare_bitmaps(reporter, original, lazy, comparePixels);
141 } 140 }
142 } 141 }
143 142
144 //////////////////////////////////////////////////////////////////////////////// 143 ////////////////////////////////////////////////////////////////////////////////
145 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) { 144 static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) {
146 return SkCachingPixelRef::Install( 145 return SkCachingPixelRef::Install(SkImageGenerator::NewFromData(encoded), ds t);
147 SkDecodingImageGenerator::Create(
148 encoded, SkDecodingImageGenerator::Options()), dst);
149 } 146 }
150 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { 147 static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
151 // Use system-default discardable memory. 148 // Use system-default discardable memory.
152 return SkInstallDiscardablePixelRef( 149 return SkInstallDiscardablePixelRef(encoded, dst);
153 SkDecodingImageGenerator::Create(
154 encoded, SkDecodingImageGenerator::Options()), dst);
155 } 150 }
156 151
157 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
158 /** 153 /**
159 * This checks to see that a SkCachingPixelRef and a 154 * This checks to see that a SkCachingPixelRef and a
160 * SkDiscardablePixelRef works as advertised with a 155 * SkDiscardablePixelRef works as advertised with a
161 * SkDecodingImageGenerator. 156 * SkDecodingImageGenerator.
162 */ 157 */
163 DEF_TEST(DecodingImageGenerator, reporter) { 158 DEF_TEST(DecodingImageGenerator, reporter) {
164 test_three_encodings(reporter, install_skCachingPixelRef); 159 test_three_encodings(reporter, install_skCachingPixelRef);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 canvas.clear(kDefaultColor); 347 canvas.clear(kDefaultColor);
353 canvas.drawImage(image, 0, 0, NULL); 348 canvas.drawImage(image, 0, 0, NULL);
354 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { 349 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
355 REPORTER_ASSERT( 350 REPORTER_ASSERT(
356 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); 351 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0));
357 } else { 352 } else {
358 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); 353 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0));
359 } 354 }
360 } 355 }
361 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698