vector_wstream.h 875 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #ifndef UI_GFX_CODEC_VECTOR_WSTREAM_H_
  5. #define UI_GFX_CODEC_VECTOR_WSTREAM_H_
  6. #include <stddef.h>
  7. #include <vector>
  8. #include "base/check_op.h"
  9. #include "base/memory/raw_ptr.h"
  10. #include "third_party/skia/include/core/SkStream.h"
  11. namespace gfx {
  12. class VectorWStream : public SkWStream {
  13. public:
  14. // We do not take ownership of dst
  15. VectorWStream(std::vector<unsigned char>* dst) : dst_(dst) {
  16. DCHECK(dst_);
  17. DCHECK_EQ(0UL, dst_->size());
  18. }
  19. bool write(const void* buffer, size_t size) override;
  20. size_t bytesWritten() const override;
  21. private:
  22. // Does not have ownership.
  23. raw_ptr<std::vector<unsigned char>> dst_;
  24. };
  25. } // namespace gfx
  26. #endif // UI_GFX_CODEC_VECTOR_WSTREAM_H_