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 * 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 ImageFrameGenerator::~ImageFrameGenerator() | 110 ImageFrameGenerator::~ImageFrameGenerator() |
111 { | 111 { |
112 ImageDecodingStore::instance().removeCacheIndexedByGenerator(this); | 112 ImageDecodingStore::instance().removeCacheIndexedByGenerator(this); |
113 } | 113 } |
114 | 114 |
115 void ImageFrameGenerator::setData(PassRefPtr<SharedBuffer> data, bool allDataRec eived) | 115 void ImageFrameGenerator::setData(PassRefPtr<SharedBuffer> data, bool allDataRec eived) |
116 { | 116 { |
117 m_data.setData(data.get(), allDataReceived); | 117 m_data.setData(data.get(), allDataReceived); |
118 } | 118 } |
119 | 119 |
120 void ImageFrameGenerator::copyData(RefPtr<SharedBuffer>* data, bool* allDataRece ived) | 120 static void sharedBufSkDataReleaseProc(const void* addr, void* ctx) |
121 { | |
122 RefPtr<SharedBuffer>* pbuffer = static_cast<RefPtr<SharedBuffer>*>(ctx); | |
123 ASSERT(pbuffer && (*pbuffer)->data() == addr); | |
124 delete pbuffer; | |
Stephen White
2015/12/02 02:44:54
It might be clearer to pass a bare pointer though
| |
125 } | |
126 | |
127 SkData* ImageFrameGenerator::refSkData() | |
121 { | 128 { |
122 SharedBuffer* buffer = 0; | 129 SharedBuffer* buffer = 0; |
123 m_data.data(&buffer, allDataReceived); | 130 bool allDataReceived = false; |
124 if (buffer) | 131 m_data.data(&buffer, &allDataReceived); |
chrishtr
2015/12/01 21:56:45
Please change ThreadSafeDataTransport::data to ret
Stephen White
2015/12/02 02:50:39
Even if we fix that, we still need something to pa
aleksandar.stojiljkovic
2015/12/02 11:04:16
Thanks, both chrishtr and you have a point here ab
| |
125 *data = buffer->copy(); | 132 if (!allDataReceived) |
133 return nullptr; | |
134 | |
135 RefPtr<SharedBuffer>* pbuffer = new RefPtr<SharedBuffer>(buffer); | |
136 return SkData::NewWithProc(buffer->data(), buffer->size(), sharedBufSkDataRe leaseProc, pbuffer); | |
126 } | 137 } |
127 | 138 |
128 bool ImageFrameGenerator::decodeAndScale(const SkImageInfo& info, size_t index, void* pixels, size_t rowBytes) | 139 bool ImageFrameGenerator::decodeAndScale(const SkImageInfo& info, size_t index, void* pixels, size_t rowBytes) |
129 { | 140 { |
130 // This method is called to populate a discardable memory owned by Skia. | 141 // This method is called to populate a discardable memory owned by Skia. |
131 | 142 |
132 // Prevents concurrent decode or scale operations on the same image data. | 143 // Prevents concurrent decode or scale operations on the same image data. |
133 MutexLocker lock(m_decodeMutex); | 144 MutexLocker lock(m_decodeMutex); |
134 | 145 |
135 // This implementation does not support scaling so check the requested size. | 146 // This implementation does not support scaling so check the requested size. |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 | 384 |
374 // Setting a dummy ImagePlanes object signals to the decoder that we want to do YUV decoding. | 385 // Setting a dummy ImagePlanes object signals to the decoder that we want to do YUV decoding. |
375 decoder->setData(data, allDataReceived); | 386 decoder->setData(data, allDataReceived); |
376 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); | 387 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); |
377 decoder->setImagePlanes(dummyImagePlanes.release()); | 388 decoder->setImagePlanes(dummyImagePlanes.release()); |
378 | 389 |
379 return updateYUVComponentSizes(decoder.get(), componentSizes, ImageDecoder:: SizeForMemoryAllocation); | 390 return updateYUVComponentSizes(decoder.get(), componentSizes, ImageDecoder:: SizeForMemoryAllocation); |
380 } | 391 } |
381 | 392 |
382 } // namespace blink | 393 } // namespace blink |
OLD | NEW |