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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/SegmentStream.h
diff --git a/third_party/WebKit/Source/platform/image-decoders/SegmentStream.h b/third_party/WebKit/Source/platform/image-decoders/SegmentStream.h
new file mode 100644
index 0000000000000000000000000000000000000000..a62fdb282316b490d5dc661334c0e51e5621e21e
--- /dev/null
+++ b/third_party/WebKit/Source/platform/image-decoders/SegmentStream.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SegmentStream_h
+#define SegmentStream_h
+
+#include <algorithm>
+#include "platform/image-decoders/SegmentReader.h"
+#include "platform/wtf/RefPtr.h"
+#include "third_party/skia/include/core/SkStream.h"
+
+namespace blink {
+
+class PLATFORM_EXPORT SegmentStream : public SkStream {
+ public:
+ SegmentStream();
+ SegmentStream(SegmentStream&& rhs);
+ 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
+
+ SegmentStream& operator=(SegmentStream&& rhs);
+
+ void SetReader(WTF::PassRefPtr<SegmentReader>);
+ // If a buffer has shrunk beyond the point we have read, it has been cleared.
+ // This allows clients to be aware of when data suddenly disappears.
+ bool IsCleared() const { return is_cleared_; }
+
+ // From SkStream:
+ size_t read(void* buffer, size_t) override;
+ size_t peek(void* buffer, size_t) const override;
+ bool isAtEnd() const override { return has_read_all_contents_; }
+ bool rewind() override;
+ bool hasPosition() const override { return true; }
+ size_t getPosition() const override { return position_; }
+ bool seek(size_t position) override;
+ bool move(long offset) override;
+ bool hasLength() const override { return true; }
+ size_t getLength() const override {
+ if (reader_)
+ return reader_->size();
+
+ return 0;
+ }
+
+ private:
+ void SetPositionState(size_t new_position);
+
+ WTF::RefPtr<SegmentReader> reader_;
+ size_t position_ = 0;
+ // |has_read_all_contents_| indicates if we have read all the contents of the
+ // buffer.
+ bool has_read_all_contents_ = true;
+ // |is_cleared_| tracks if we have shrunk the buffer beyond the point we have
+ // read. Clients of this class rely on data not disappearing, so we need to
+ // handle the case when it does.
+ bool is_cleared_ = true;
+};
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698