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

Side by Side Diff: Source/platform/graphics/ImageFrameGenerator.cpp

Issue 485833005: Image decoding: Remove deprecated image caching code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 (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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 private: 66 private:
67 SkImageInfo m_info; 67 SkImageInfo m_info;
68 void* m_pixels; 68 void* m_pixels;
69 size_t m_rowBytes; 69 size_t m_rowBytes;
70 }; 70 };
71 71
72 ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<Sha redBuffer> data, bool allDataReceived, bool isMultiFrame) 72 ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<Sha redBuffer> data, bool allDataReceived, bool isMultiFrame)
73 : m_fullSize(fullSize) 73 : m_fullSize(fullSize)
74 , m_isMultiFrame(isMultiFrame) 74 , m_isMultiFrame(isMultiFrame)
75 , m_decodeFailedAndEmpty(false) 75 , m_decodeFailedAndEmpty(false)
76 , m_decodeCount(ScaledImageFragment::FirstPartialImage) 76 , m_decodeCount(0)
77 { 77 {
78 setData(data.get(), allDataReceived); 78 setData(data.get(), allDataReceived);
79 } 79 }
80 80
81 ImageFrameGenerator::~ImageFrameGenerator() 81 ImageFrameGenerator::~ImageFrameGenerator()
82 { 82 {
83 ImageDecodingStore::instance()->removeCacheIndexedByGenerator(this); 83 ImageDecodingStore::instance()->removeCacheIndexedByGenerator(this);
84 } 84 }
85 85
86 void ImageFrameGenerator::setData(PassRefPtr<SharedBuffer> data, bool allDataRec eived) 86 void ImageFrameGenerator::setData(PassRefPtr<SharedBuffer> data, bool allDataRec eived)
(...skipping 16 matching lines...) Expand all
103 // Prevents concurrent decode or scale operations on the same image data. 103 // Prevents concurrent decode or scale operations on the same image data.
104 MutexLocker lock(m_decodeMutex); 104 MutexLocker lock(m_decodeMutex);
105 105
106 // This implementation does not support scaling so check the requested size. 106 // This implementation does not support scaling so check the requested size.
107 SkISize scaledSize = SkISize::Make(info.fWidth, info.fHeight); 107 SkISize scaledSize = SkISize::Make(info.fWidth, info.fHeight);
108 ASSERT(m_fullSize == scaledSize); 108 ASSERT(m_fullSize == scaledSize);
109 109
110 if (m_decodeFailedAndEmpty) 110 if (m_decodeFailedAndEmpty)
111 return 0; 111 return 0;
112 112
113 TRACE_EVENT2("blink", "ImageFrameGenerator::decodeAndScale", "generator", th is, "decodeCount", static_cast<int>(m_decodeCount)); 113 TRACE_EVENT2("blink", "ImageFrameGenerator::decodeAndScale", "generator", th is, "decodeCount", m_decodeCount);
114 114
115 m_externalAllocator = adoptPtr(new ExternalMemoryAllocator(info, pixels, row Bytes)); 115 m_externalAllocator = adoptPtr(new ExternalMemoryAllocator(info, pixels, row Bytes));
116 116
117 SkBitmap bitmap = tryToResumeDecode(scaledSize, index); 117 SkBitmap bitmap = tryToResumeDecode(scaledSize, index);
118 if (bitmap.isNull()) 118 if (bitmap.isNull())
119 return false; 119 return false;
120 120
121 // Don't keep the allocator because it contains a pointer to memory 121 // Don't keep the allocator because it contains a pointer to memory
122 // that we do not own. 122 // that we do not own.
123 m_externalAllocator.clear(); 123 m_externalAllocator.clear();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // the decoder. The exception is multi-frame decoder which can generate 168 // the decoder. The exception is multi-frame decoder which can generate
169 // multiple complete frames. 169 // multiple complete frames.
170 const bool removeDecoder = complete && !m_isMultiFrame; 170 const bool removeDecoder = complete && !m_isMultiFrame;
171 171
172 if (resumeDecoding) { 172 if (resumeDecoding) {
173 if (removeDecoder) 173 if (removeDecoder)
174 ImageDecodingStore::instance()->removeDecoder(this, decoder); 174 ImageDecodingStore::instance()->removeDecoder(this, decoder);
175 else 175 else
176 ImageDecodingStore::instance()->unlockDecoder(this, decoder); 176 ImageDecodingStore::instance()->unlockDecoder(this, decoder);
177 } else if (!removeDecoder) { 177 } else if (!removeDecoder) {
178 ImageDecodingStore::instance()->insertDecoder(this, decoderContainer.rel ease(), false); 178 ImageDecodingStore::instance()->insertDecoder(this, decoderContainer.rel ease());
179 } 179 }
180 return fullSizeImage; 180 return fullSizeImage;
181 } 181 }
182 182
183 SkBitmap ImageFrameGenerator::decode(size_t index, ImageDecoder** decoder, bool* complete) 183 SkBitmap ImageFrameGenerator::decode(size_t index, ImageDecoder** decoder, bool* complete)
184 { 184 {
185 TRACE_EVENT2("blink", "ImageFrameGenerator::decode", "width", m_fullSize.wid th(), "height", m_fullSize.height()); 185 TRACE_EVENT2("blink", "ImageFrameGenerator::decode", "width", m_fullSize.wid th(), "height", m_fullSize.height());
186 186
187 ASSERT(decoder); 187 ASSERT(decoder);
188 SharedBuffer* data = 0; 188 SharedBuffer* data = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 242
243 bool ImageFrameGenerator::hasAlpha(size_t index) 243 bool ImageFrameGenerator::hasAlpha(size_t index)
244 { 244 {
245 MutexLocker lock(m_alphaMutex); 245 MutexLocker lock(m_alphaMutex);
246 if (index < m_hasAlpha.size()) 246 if (index < m_hasAlpha.size())
247 return m_hasAlpha[index]; 247 return m_hasAlpha[index];
248 return true; 248 return true;
249 } 249 }
250 250
251 } // namespace blink 251 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/ImageFrameGenerator.h ('k') | Source/platform/graphics/ImageFrameGeneratorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698