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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/SegmentStream.h

Issue 2565323003: Move gif image decoder to SkCodec (Closed)
Patch Set: Correct comments. Better variable names. Better DCHECK. Created 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SegmentStream_h
6 #define SegmentStream_h
7
8 #include <algorithm>
9 #include "platform/image-decoders/SegmentReader.h"
10 #include "platform/wtf/RefPtr.h"
11 #include "third_party/skia/include/core/SkStream.h"
12
13 namespace blink {
14
15 class PLATFORM_EXPORT SegmentStream : public SkStream {
16 public:
17 SegmentStream();
18 SegmentStream(SegmentStream&& rhs);
19 virtual ~SegmentStream() {}
scroggo_chromium 2017/08/08 19:39:25 Should this instead be: ~SegmentStream() overrid
cblume 2017/08/09 17:29:29 Yes. On 2017/08/08 19:39:25, scroggo_chromium wr
scroggo_chromium 2017/08/09 17:50:48 Yeah, that code is pretty old. Skia's official sty
20
21 SegmentStream& operator=(SegmentStream&& rhs);
22
23 void SetReader(WTF::PassRefPtr<SegmentReader>);
24 // If a buffer has shrunk beyond the point we have read, it has been cleared.
25 // This allows clients to be aware of when data suddenly disappears.
26 bool IsCleared() const { return is_cleared_; }
27
28 // From SkStream:
29 size_t read(void* buffer, size_t) override;
30 size_t peek(void* buffer, size_t) const override;
31 bool isAtEnd() const override { return has_read_all_contents_; }
32 bool rewind() override;
33 bool hasPosition() const override { return true; }
34 size_t getPosition() const override { return position_; }
35 bool seek(size_t position) override;
36 bool move(long offset) override;
37 bool hasLength() const override { return true; }
38 size_t getLength() const override {
39 if (reader_)
40 return reader_->size();
41
42 return 0;
43 }
44
45 private:
46 void SetPositionState(size_t new_position);
47
48 WTF::RefPtr<SegmentReader> reader_;
49 size_t position_ = 0;
50 // |has_read_all_contents_| indicates if we have read all the contents of the
51 // buffer.
52 bool has_read_all_contents_ = true;
53 // |is_cleared_| tracks if we have shrunk the buffer beyond the point we have
54 // read. Clients of this class rely on data not disappearing, so we need to
55 // handle the case when it does.
56 bool is_cleared_ = true;
57 };
58
59 } // namespace blink
60
61 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698