OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 virtual size_t frameCount() { return 1; } | 72 virtual size_t frameCount() { return 1; } |
73 virtual int repetitionCount() const { return cAnimationNone; } | 73 virtual int repetitionCount() const { return cAnimationNone; } |
74 virtual float frameDuration() const { return 0; } | 74 virtual float frameDuration() const { return 0; } |
75 | 75 |
76 protected: | 76 protected: |
77 PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size, boo
l discardable = false, size_t index = 0) | 77 PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size, boo
l discardable = false, size_t index = 0) |
78 { | 78 { |
79 SkBitmap bitmap; | 79 SkBitmap bitmap; |
80 bitmap.setConfig(SkImageInfo::MakeN32Premul(size)); | 80 bitmap.setInfo(SkImageInfo::MakeN32Premul(size)); |
81 if (!discardable) { | 81 if (!discardable) { |
82 bitmap.allocPixels(); | 82 bitmap.allocPixels(); |
83 } else { | 83 } else { |
84 MockDiscardablePixelRef::Allocator mockDiscardableAllocator; | 84 MockDiscardablePixelRef::Allocator mockDiscardableAllocator; |
85 bitmap.allocPixels(&mockDiscardableAllocator, 0); | 85 bitmap.allocPixels(&mockDiscardableAllocator, 0); |
86 } | 86 } |
87 return ScaledImageFragment::createComplete(size, index, bitmap); | 87 return ScaledImageFragment::createComplete(size, index, bitmap); |
88 } | 88 } |
89 | 89 |
90 PassOwnPtr<ScaledImageFragment> createIncompleteImage(const SkISize& size, b
ool discardable = false, size_t generation = 0) | 90 PassOwnPtr<ScaledImageFragment> createIncompleteImage(const SkISize& size, b
ool discardable = false, size_t generation = 0) |
91 { | 91 { |
92 SkBitmap bitmap; | 92 SkBitmap bitmap; |
93 bitmap.setConfig(SkImageInfo::MakeN32Premul(size)); | 93 bitmap.setInfo(SkImageInfo::MakeN32Premul(size)); |
94 if (!discardable) { | 94 if (!discardable) { |
95 bitmap.allocPixels(); | 95 bitmap.allocPixels(); |
96 } else { | 96 } else { |
97 MockDiscardablePixelRef::Allocator mockDiscardableAllocator; | 97 MockDiscardablePixelRef::Allocator mockDiscardableAllocator; |
98 bitmap.allocPixels(&mockDiscardableAllocator, 0); | 98 bitmap.allocPixels(&mockDiscardableAllocator, 0); |
99 } | 99 } |
100 return ScaledImageFragment::createPartial(size, 0, generation, bitmap); | 100 return ScaledImageFragment::createPartial(size, 0, generation, bitmap); |
101 } | 101 } |
102 | 102 |
103 void insertCache(const SkISize& size) | 103 void insertCache(const SkISize& size) |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 EXPECT_EQ(0, ImageDecodingStore::instance()->cacheEntries()); | 470 EXPECT_EQ(0, ImageDecodingStore::instance()->cacheEntries()); |
471 | 471 |
472 const ScaledImageFragment* cachedImage = ImageDecodingStore::instance()->ins
ertAndLockCache( | 472 const ScaledImageFragment* cachedImage = ImageDecodingStore::instance()->ins
ertAndLockCache( |
473 m_generator.get(), createCompleteImage(SkISize::Make(3, 3), true)); | 473 m_generator.get(), createCompleteImage(SkISize::Make(3, 3), true)); |
474 EXPECT_EQ(1, ImageDecodingStore::instance()->cacheEntries()); | 474 EXPECT_EQ(1, ImageDecodingStore::instance()->cacheEntries()); |
475 unlockCache(cachedImage); | 475 unlockCache(cachedImage); |
476 EXPECT_EQ(0, ImageDecodingStore::instance()->cacheEntries()); | 476 EXPECT_EQ(0, ImageDecodingStore::instance()->cacheEntries()); |
477 } | 477 } |
478 | 478 |
479 } // namespace | 479 } // namespace |
OLD | NEW |