#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/image-decoders/segment_reader.h"
#include <utility>
#include "base/containers/span.h"
#include "base/memory/scoped_refptr.h"
#include "base/synchronization/lock.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "third_party/skia/include/core/SkData.h"
namespace blink {
namespace {
template <class Iter>
size_t BufferGetSomeData(Iter& iter,
size_t& position_of_block,
const char*& data,
size_t position) { … }
template <class Iter>
sk_sp<SkData> BufferCopyAsSkData(Iter iter, size_t available) { … }
}
class SharedBufferSegmentReader final : public SegmentReader { … };
SharedBufferSegmentReader::SharedBufferSegmentReader(
scoped_refptr<const SharedBuffer> buffer)
: … { … }
size_t SharedBufferSegmentReader::size() const { … }
size_t SharedBufferSegmentReader::GetSomeData(const char*& data,
size_t position) const { … }
sk_sp<SkData> SharedBufferSegmentReader::GetAsSkData() const { … }
class DataSegmentReader final : public SegmentReader { … };
DataSegmentReader::DataSegmentReader(sk_sp<SkData> data)
: … { … }
size_t DataSegmentReader::size() const { … }
size_t DataSegmentReader::GetSomeData(const char*& data,
size_t position) const { … }
sk_sp<SkData> DataSegmentReader::GetAsSkData() const { … }
class ROBufferSegmentReader final : public SegmentReader { … };
ROBufferSegmentReader::ROBufferSegmentReader(scoped_refptr<ROBuffer> buffer)
: … { … }
size_t ROBufferSegmentReader::size() const { … }
size_t ROBufferSegmentReader::GetSomeData(const char*& data,
size_t position) const { … }
static void UnrefROBuffer(const void* ptr, void* context) { … }
sk_sp<SkData> ROBufferSegmentReader::GetAsSkData() const { … }
scoped_refptr<SegmentReader> SegmentReader::CreateFromSharedBuffer(
scoped_refptr<const SharedBuffer> buffer) { … }
scoped_refptr<SegmentReader> SegmentReader::CreateFromSkData(
sk_sp<SkData> data) { … }
scoped_refptr<SegmentReader> SegmentReader::CreateFromROBuffer(
scoped_refptr<ROBuffer> buffer) { … }
sk_sp<SkData> SegmentReader::RWBufferCopyAsSkData(RWBuffer::ROIter iter,
size_t available) { … }
size_t SegmentReader::RWBufferGetSomeData(RWBuffer::ROIter& iter,
size_t& position_of_block,
const char*& data,
size_t position) { … }
}