Skip to content
Snippets Groups Projects
Commit e2050d4c authored by Andrew Osmond's avatar Andrew Osmond
Browse files

Bug 1732115 - Part 2. Move OrientedPixel and related to image/Orientation.h. r=tnikkel

parent 1afab525
No related merge requests found
......@@ -7,8 +7,31 @@
#define mozilla_image_Orientation_h
#include <stdint.h>
#include "mozilla/gfx/Rect.h"
namespace mozilla {
// Pixel values in an image considering orientation metadata, such as the size
// of an image as seen by consumers of the image.
//
// Any public methods on RasterImage that use untyped units are interpreted as
// oriented pixels.
struct OrientedPixel {};
template <>
struct IsPixel<OrientedPixel> : std::true_type {};
typedef gfx::IntPointTyped<OrientedPixel> OrientedIntPoint;
typedef gfx::IntSizeTyped<OrientedPixel> OrientedIntSize;
typedef gfx::IntRectTyped<OrientedPixel> OrientedIntRect;
// Pixel values in an image ignoring orientation metadata, such as are stored
// in surfaces and the raw pixel data in the image.
struct UnorientedPixel {};
template <>
struct IsPixel<UnorientedPixel> : std::true_type {};
typedef gfx::IntPointTyped<UnorientedPixel> UnorientedIntPoint;
typedef gfx::IntSizeTyped<UnorientedPixel> UnorientedIntSize;
typedef gfx::IntRectTyped<UnorientedPixel> UnorientedIntRect;
namespace image {
enum class Angle : uint8_t { D0, D90, D180, D270 };
......@@ -50,6 +73,22 @@ struct Orientation {
return !(*this == aOther);
}
OrientedIntSize ToOriented(const UnorientedIntSize& aSize) const {
if (SwapsWidthAndHeight()) {
return OrientedIntSize(aSize.height, aSize.width);
} else {
return OrientedIntSize(aSize.width, aSize.height);
}
}
UnorientedIntSize ToUnoriented(const OrientedIntSize& aSize) const {
if (SwapsWidthAndHeight()) {
return UnorientedIntSize(aSize.height, aSize.width);
} else {
return UnorientedIntSize(aSize.width, aSize.height);
}
}
static Angle InvertAngle(Angle aAngle) {
switch (aAngle) {
case Angle::D90:
......
......@@ -125,26 +125,6 @@ class nsIRequest;
*/
namespace mozilla {
// Pixel values in an image considering orientation metadata, such as the size
// of an image as seen by consumers of the image.
//
// Any public methods on RasterImage that use untyped units are interpreted as
// oriented pixels.
struct OrientedPixel {};
template <>
struct IsPixel<OrientedPixel> : std::true_type {};
typedef gfx::IntSizeTyped<OrientedPixel> OrientedIntSize;
typedef gfx::IntRectTyped<OrientedPixel> OrientedIntRect;
// Pixel values in an image ignoring orientation metadata, such as are stored
// in surfaces and the raw pixel data in the image.
struct UnorientedPixel {};
template <>
struct IsPixel<UnorientedPixel> : std::true_type {};
typedef gfx::IntSizeTyped<UnorientedPixel> UnorientedIntSize;
typedef gfx::IntRectTyped<UnorientedPixel> UnorientedIntRect;
namespace layers {
class ImageContainer;
class Image;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment