skia2/include/codec/SkEncodedOrigin.h
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

49 lines
2.1 KiB
C

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkEncodedOrigin_DEFINED
#define SkEncodedOrigin_DEFINED
#include "include/core/SkMatrix.h"
// These values match the orientation www.exif.org/Exif2-2.PDF.
enum SkEncodedOrigin {
kTopLeft_SkEncodedOrigin = 1, // Default
kTopRight_SkEncodedOrigin = 2, // Reflected across y-axis
kBottomRight_SkEncodedOrigin = 3, // Rotated 180
kBottomLeft_SkEncodedOrigin = 4, // Reflected across x-axis
kLeftTop_SkEncodedOrigin = 5, // Reflected across x-axis, Rotated 90 CCW
kRightTop_SkEncodedOrigin = 6, // Rotated 90 CW
kRightBottom_SkEncodedOrigin = 7, // Reflected across x-axis, Rotated 90 CW
kLeftBottom_SkEncodedOrigin = 8, // Rotated 90 CCW
kDefault_SkEncodedOrigin = kTopLeft_SkEncodedOrigin,
kLast_SkEncodedOrigin = kLeftBottom_SkEncodedOrigin,
};
/**
* Given an encoded origin and the width and height of the source data, returns a matrix
* that transforms the source rectangle [0, 0, w, h] to a correctly oriented destination
* rectangle, with the upper left corner still at [0, 0].
*/
static inline SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h) {
switch (origin) {
case kTopLeft_SkEncodedOrigin: return SkMatrix::I();
case kTopRight_SkEncodedOrigin: return SkMatrix::MakeAll(-1, 0, w, 0, 1, 0, 0, 0, 1);
case kBottomRight_SkEncodedOrigin: return SkMatrix::MakeAll(-1, 0, w, 0, -1, h, 0, 0, 1);
case kBottomLeft_SkEncodedOrigin: return SkMatrix::MakeAll( 1, 0, 0, 0, -1, h, 0, 0, 1);
case kLeftTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, 1, 0, 0, 0, 0, 1);
case kRightTop_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, h, 1, 0, 0, 0, 0, 1);
case kRightBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, -1, h, -1, 0, w, 0, 0, 1);
case kLeftBottom_SkEncodedOrigin: return SkMatrix::MakeAll( 0, 1, 0, -1, 0, w, 0, 0, 1);
}
SK_ABORT("Unexpected origin");
return SkMatrix::I();
}
#endif // SkEncodedOrigin_DEFINED