OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 size_t peek(void* buf, size_t bytes) const override { | 872 size_t peek(void* buf, size_t bytes) const override { |
873 return fStream.peek(buf, SkTMin(bytes, fLimit)); | 873 return fStream.peek(buf, SkTMin(bytes, fLimit)); |
874 } | 874 } |
875 size_t read(void* buf, size_t bytes) override { | 875 size_t read(void* buf, size_t bytes) override { |
876 return fStream.read(buf, bytes); | 876 return fStream.read(buf, bytes); |
877 } | 877 } |
878 bool rewind() override { | 878 bool rewind() override { |
879 return fStream.rewind(); | 879 return fStream.rewind(); |
880 } | 880 } |
881 bool isAtEnd() const override { | 881 bool isAtEnd() const override { |
882 return false; | 882 return fStream.isAtEnd(); |
883 } | 883 } |
884 private: | 884 private: |
885 SkMemoryStream fStream; | 885 SkMemoryStream fStream; |
886 const size_t fLimit; | 886 const size_t fLimit; |
887 }; | 887 }; |
888 | 888 |
889 // Stream that is not an asset stream (!hasPosition() or !hasLength()) | 889 // Stream that is not an asset stream (!hasPosition() or !hasLength()) |
890 class NotAssetMemStream : public SkStream { | 890 class NotAssetMemStream : public SkStream { |
891 public: | 891 public: |
892 NotAssetMemStream(sk_sp<SkData> data) : fStream(std::move(data)) {} | 892 NotAssetMemStream(sk_sp<SkData> data) : fStream(std::move(data)) {} |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 // Create an arbitrary gray bitmap. | 1113 // Create an arbitrary gray bitmap. |
1114 path = "grayscale.jpg"; | 1114 path = "grayscale.jpg"; |
1115 stream.reset(resource(path)); | 1115 stream.reset(resource(path)); |
1116 codec.reset(SkCodec::NewFromStream(stream.release())); | 1116 codec.reset(SkCodec::NewFromStream(stream.release())); |
1117 SkBitmap bm2; | 1117 SkBitmap bm2; |
1118 bm2.allocPixels(codec->getInfo()); | 1118 bm2.allocPixels(codec->getInfo()); |
1119 result = codec->getPixels(codec->getInfo(), bm2.getPixels(), bm2.rowBytes())
; | 1119 result = codec->getPixels(codec->getInfo(), bm2.getPixels(), bm2.rowBytes())
; |
1120 REPORTER_ASSERT(r, SkCodec::kSuccess == result); | 1120 REPORTER_ASSERT(r, SkCodec::kSuccess == result); |
1121 check_round_trip(r, bm2); | 1121 check_round_trip(r, bm2); |
1122 } | 1122 } |
OLD | NEW |