OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "Test.h" | 7 #include "Test.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkGraphics.h" | 9 #include "SkGraphics.h" |
10 #include "SkBitmapCache.h" | 10 #include "SkBitmapCache.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); | 79 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); |
80 if (NULL != allocator) { | 80 if (NULL != allocator) { |
81 allocator->allocPixelRef(&cachedBitmap, 0); | 81 allocator->allocPixelRef(&cachedBitmap, 0); |
82 } else { | 82 } else { |
83 cachedBitmap.allocPixels(); | 83 cachedBitmap.allocPixels(); |
84 } | 84 } |
85 | 85 |
86 return cachedBitmap; | 86 return cachedBitmap; |
87 } | 87 } |
88 | 88 |
89 #if 0 // skia:2912 | |
tfarina
2014/09/04 17:30:31
OK
| |
89 // http://skbug.com/2894 | 90 // http://skbug.com/2894 |
90 DEF_TEST(BitmapCache_add_rect, reporter) { | 91 DEF_TEST(BitmapCache_add_rect, reporter) { |
91 SkBitmap bm; | 92 SkBitmap bm; |
92 SkIRect rect = SkIRect::MakeWH(5, 5); | 93 SkIRect rect = SkIRect::MakeWH(5, 5); |
93 SkBitmap cachedBitmap = createAllocatedBitmap(SkImageInfo::MakeN32Premul(5, 5)); | 94 SkBitmap cachedBitmap = createAllocatedBitmap(SkImageInfo::MakeN32Premul(5, 5)); |
94 cachedBitmap.setImmutable(); | 95 cachedBitmap.setImmutable(); |
95 | 96 |
96 // Wrong subset size | 97 // Wrong subset size |
97 REPORTER_ASSERT(reporter, ! SkBitmapCache::Add(cachedBitmap.getGenerationID( ), SkIRect::MakeWH(4, 6), cachedBitmap)); | 98 REPORTER_ASSERT(reporter, ! SkBitmapCache::Add(cachedBitmap.getGenerationID( ), SkIRect::MakeWH(4, 6), cachedBitmap)); |
98 REPORTER_ASSERT(reporter, ! SkBitmapCache::Find(cachedBitmap.getGenerationID (), rect, &bm)); | 99 REPORTER_ASSERT(reporter, ! SkBitmapCache::Find(cachedBitmap.getGenerationID (), rect, &bm)); |
99 // Wrong offset value | 100 // Wrong offset value |
100 REPORTER_ASSERT(reporter, ! SkBitmapCache::Add(cachedBitmap.getGenerationID( ), SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap)); | 101 REPORTER_ASSERT(reporter, ! SkBitmapCache::Add(cachedBitmap.getGenerationID( ), SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap)); |
101 REPORTER_ASSERT(reporter, ! SkBitmapCache::Find(cachedBitmap.getGenerationID (), rect, &bm)); | 102 REPORTER_ASSERT(reporter, ! SkBitmapCache::Find(cachedBitmap.getGenerationID (), rect, &bm)); |
102 | 103 |
103 // Should not be in the cache | 104 // Should not be in the cache |
104 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID( ), rect, &bm)); | 105 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID( ), rect, &bm)); |
105 | 106 |
106 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedBitmap.getGenerationID(), rect, cachedBitmap)); | 107 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedBitmap.getGenerationID(), rect, cachedBitmap)); |
107 // Should be in the cache, we just added it | 108 // Should be in the cache, we just added it |
108 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID() , rect, &bm)); | 109 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID() , rect, &bm)); |
109 } | 110 } |
111 #endif | |
OLD | NEW |