2015-10-05 17:12:46 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 12:12:37 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2012-06-15 10:00:44 +12:00
|
|
|
#ifndef GFX_2D_GLUE_H
|
|
|
|
#define GFX_2D_GLUE_H
|
|
|
|
|
2012-01-05 08:17:51 +01:00
|
|
|
#include "gfxMatrix.h"
|
2019-04-22 19:58:52 +00:00
|
|
|
#include "gfxPoint.h"
|
|
|
|
#include "gfxRect.h"
|
|
|
|
#include "gfxTypes.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
#include "mozilla/gfx/Matrix.h"
|
2020-11-23 16:12:02 +00:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2011-06-24 19:41:18 +02:00
|
|
|
#include "mozilla/gfx/Rect.h"
|
2020-11-23 16:12:02 +00:00
|
|
|
#include "mozilla/gfx/Types.h"
|
2011-06-24 19:41:18 +02:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
inline Rect ToRect(const gfxRect& aRect) {
|
2017-12-19 15:48:39 -05:00
|
|
|
return Rect(Float(aRect.X()), Float(aRect.Y()), Float(aRect.Width()),
|
2017-08-14 08:28:11 -04:00
|
|
|
Float(aRect.Height()));
|
2011-06-24 19:41:18 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 13:43:40 -07:00
|
|
|
inline RectDouble ToRectDouble(const gfxRect& aRect) {
|
2017-12-19 15:48:39 -05:00
|
|
|
return RectDouble(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2015-06-11 13:43:40 -07:00
|
|
|
}
|
|
|
|
|
2012-01-05 08:17:51 +01:00
|
|
|
inline Matrix ToMatrix(const gfxMatrix& aMatrix) {
|
2014-06-17 18:35:51 +01:00
|
|
|
return Matrix(Float(aMatrix._11), Float(aMatrix._12), Float(aMatrix._21),
|
|
|
|
Float(aMatrix._22), Float(aMatrix._31), Float(aMatrix._32));
|
2012-01-05 08:17:51 +01:00
|
|
|
}
|
|
|
|
|
2013-12-16 11:17:58 +13:00
|
|
|
inline gfxMatrix ThebesMatrix(const Matrix& aMatrix) {
|
|
|
|
return gfxMatrix(aMatrix._11, aMatrix._12, aMatrix._21, aMatrix._22,
|
|
|
|
aMatrix._31, aMatrix._32);
|
|
|
|
}
|
|
|
|
|
2012-01-05 08:17:51 +01:00
|
|
|
inline Point ToPoint(const gfxPoint& aPoint) {
|
|
|
|
return Point(Float(aPoint.x), Float(aPoint.y));
|
|
|
|
}
|
|
|
|
|
2015-11-10 20:36:29 -08:00
|
|
|
inline Size ToSize(const gfxSize& aSize) {
|
|
|
|
return Size(Float(aSize.width), Float(aSize.height));
|
|
|
|
}
|
|
|
|
|
2012-01-05 08:17:51 +01:00
|
|
|
inline gfxPoint ThebesPoint(const Point& aPoint) {
|
|
|
|
return gfxPoint(aPoint.x, aPoint.y);
|
|
|
|
}
|
|
|
|
|
2015-11-10 20:36:29 -08:00
|
|
|
inline gfxSize ThebesSize(const Size& aSize) {
|
|
|
|
return gfxSize(aSize.width, aSize.height);
|
|
|
|
}
|
|
|
|
|
2012-01-05 08:17:51 +01:00
|
|
|
inline gfxRect ThebesRect(const Rect& aRect) {
|
2017-12-19 15:48:39 -05:00
|
|
|
return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2011-06-24 19:41:18 +02:00
|
|
|
}
|
|
|
|
|
2015-11-11 14:23:14 -08:00
|
|
|
inline gfxRect ThebesRect(const IntRect& aRect) {
|
2017-12-19 15:48:39 -05:00
|
|
|
return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2015-11-11 14:23:14 -08:00
|
|
|
}
|
|
|
|
|
2015-06-11 13:43:40 -07:00
|
|
|
inline gfxRect ThebesRect(const RectDouble& aRect) {
|
2017-12-19 15:48:39 -05:00
|
|
|
return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2015-06-11 13:43:40 -07:00
|
|
|
}
|
|
|
|
|
2013-09-24 16:45:13 -04:00
|
|
|
inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat) {
|
2012-06-15 10:00:44 +12:00
|
|
|
switch (aFormat) {
|
2014-01-10 14:06:16 -05:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
2016-01-07 20:57:38 -08:00
|
|
|
return SurfaceFormat::A8R8G8B8_UINT32;
|
2014-01-10 14:06:16 -05:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
2016-01-07 20:57:38 -08:00
|
|
|
return SurfaceFormat::X8R8G8B8_UINT32;
|
2015-10-22 23:01:31 -07:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2016-01-07 20:57:38 -08:00
|
|
|
return SurfaceFormat::R5G6B5_UINT16;
|
2014-01-10 14:06:16 -05:00
|
|
|
case SurfaceFormat::A8:
|
2016-01-07 20:57:38 -08:00
|
|
|
return SurfaceFormat::A8;
|
2012-06-15 10:00:44 +12:00
|
|
|
default:
|
2016-01-07 20:57:38 -08:00
|
|
|
return SurfaceFormat::UNKNOWN;
|
2012-06-15 10:00:44 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 16:45:13 -04:00
|
|
|
inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat) {
|
2012-04-03 14:57:22 -07:00
|
|
|
switch (aFormat) {
|
2016-01-07 20:57:38 -08:00
|
|
|
case SurfaceFormat::A8R8G8B8_UINT32:
|
2014-01-10 14:06:16 -05:00
|
|
|
return SurfaceFormat::B8G8R8A8;
|
2016-01-07 20:57:38 -08:00
|
|
|
case SurfaceFormat::X8R8G8B8_UINT32:
|
2014-01-10 14:06:16 -05:00
|
|
|
return SurfaceFormat::B8G8R8X8;
|
2016-01-07 20:57:38 -08:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2015-10-22 23:01:31 -07:00
|
|
|
return SurfaceFormat::R5G6B5_UINT16;
|
2016-01-07 20:57:38 -08:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-10 14:06:16 -05:00
|
|
|
return SurfaceFormat::A8;
|
2012-04-03 14:57:22 -07:00
|
|
|
default:
|
2016-01-07 20:57:38 -08:00
|
|
|
case SurfaceFormat::UNKNOWN:
|
2014-01-10 14:06:16 -05:00
|
|
|
return SurfaceFormat::B8G8R8A8;
|
2012-04-03 14:57:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 16:45:13 -04:00
|
|
|
inline gfxContentType ContentForFormat(const SurfaceFormat& aFormat) {
|
2011-06-24 19:41:18 +02:00
|
|
|
switch (aFormat) {
|
2015-10-22 23:01:31 -07:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2014-01-10 14:06:16 -05:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
|
|
|
case SurfaceFormat::R8G8B8X8:
|
2014-01-23 13:26:40 -05:00
|
|
|
return gfxContentType::COLOR;
|
2014-01-10 14:06:16 -05:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-23 13:26:40 -05:00
|
|
|
return gfxContentType::ALPHA;
|
2014-01-10 14:06:16 -05:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
|
|
|
case SurfaceFormat::R8G8B8A8:
|
2011-06-24 19:41:18 +02:00
|
|
|
default:
|
2014-01-23 13:26:40 -05:00
|
|
|
return gfxContentType::COLOR_ALPHA;
|
2011-06-24 19:41:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2012-06-15 10:00:44 +12:00
|
|
|
|
|
|
|
#endif
|