aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2018-01-26 15:48:26 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-26 22:13:34 +0000
commitda3e9ad894379713cbb66779136ca6877ccac7dd (patch)
tree6b2be2cf902fed8f4a311783e98c0d8e19fbea89 /include/codec
parent323df5720ce076f94709d20215e92e150ce60f6c (diff)
Make SkAndroidCodec (optionally) respect origin
Bug: b/63909536 ImageDecoder will respect the origin, but BitmapFactory will maintain its current behavior of not respecting it. Add an option to respect it. In addition, add support for reading the EXIF data from a WEBP. This seems to be an uncommon use case, but is occasionally used when converting from a JPEG. Add 8 WEBPs, all converted (with cwebp) from their analogous JPEG files already checked in. Change-Id: I38afca58c86fa99ee9ab7d1dc83aaa4f23132c11 Reviewed-on: https://skia-review.googlesource.com/95300 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/codec')
-rw-r--r--include/codec/SkAndroidCodec.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/include/codec/SkAndroidCodec.h b/include/codec/SkAndroidCodec.h
index 0746f066c8..750e2351f2 100644
--- a/include/codec/SkAndroidCodec.h
+++ b/include/codec/SkAndroidCodec.h
@@ -19,10 +19,31 @@
*/
class SK_API SkAndroidCodec : SkNoncopyable {
public:
+ enum class ExifOrientationBehavior {
+ /**
+ * Ignore any exif orientation markers in the data.
+ *
+ * getInfo's width and height will match the header of the image, and
+ * no processing will be done to match the marker.
+ */
+ kIgnore,
+
+ /**
+ * Respect the exif orientation marker.
+ *
+ * getInfo's width and height will represent what they should be after
+ * applying the orientation. For example, if the marker specifies a
+ * rotation by 90 degrees, they will be swapped relative to the header.
+ * getAndroidPixels will apply the orientation as well.
+ */
+ kRespect,
+ };
+
/**
* Pass ownership of an SkCodec to a newly-created SkAndroidCodec.
*/
- static std::unique_ptr<SkAndroidCodec> MakeFromCodec(std::unique_ptr<SkCodec>);
+ static std::unique_ptr<SkAndroidCodec> MakeFromCodec(std::unique_ptr<SkCodec>,
+ ExifOrientationBehavior = ExifOrientationBehavior::kIgnore);
/**
* If this stream represents an encoded image that we know how to decode,
@@ -33,6 +54,8 @@ public:
*
* If NULL is returned, the stream is deleted immediately. Otherwise, the
* SkCodec takes ownership of it, and will delete it when done with it.
+ *
+ * ExifOrientationBehavior is set to kIgnore.
*/
static std::unique_ptr<SkAndroidCodec> MakeFromStream(std::unique_ptr<SkStream>,
SkPngChunkReader* = nullptr);
@@ -43,6 +66,8 @@ public:
*
* The SkPngChunkReader handles unknown chunks in PNGs.
* See SkCodec.h for more details.
+ *
+ * ExifOrientationBehavior is set to kIgnore.
*/
static std::unique_ptr<SkAndroidCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
@@ -245,8 +270,7 @@ public:
SkCodec* codec() const { return fCodec.get(); }
protected:
-
- SkAndroidCodec(SkCodec*);
+ SkAndroidCodec(SkCodec*, ExifOrientationBehavior = ExifOrientationBehavior::kIgnore);
virtual SkISize onGetSampledDimensions(int sampleSize) const = 0;
@@ -256,11 +280,8 @@ protected:
size_t rowBytes, const AndroidOptions& options) = 0;
private:
-
- // This will always be a reference to the info that is contained by the
- // embedded SkCodec.
- const SkImageInfo& fInfo;
-
- std::unique_ptr<SkCodec> fCodec;
+ const SkImageInfo fInfo;
+ const ExifOrientationBehavior fOrientationBehavior;
+ std::unique_ptr<SkCodec> fCodec;
};
#endif // SkAndroidCodec_DEFINED