2015-10-06 03:12:46 +03: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 15:12:37 +04: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 02:00:44 +04:00
|
|
|
#ifndef GFX_2D_GLUE_H
|
|
|
|
#define GFX_2D_GLUE_H
|
|
|
|
|
2012-05-26 08:38:17 +04:00
|
|
|
#include "gfxPlatform.h"
|
2011-06-24 21:41:18 +04:00
|
|
|
#include "gfxRect.h"
|
2012-01-05 11:17:51 +04:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "gfxContext.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 13:20:52 +04:00
|
|
|
#include "mozilla/gfx/Matrix.h"
|
2011-06-24 21:41:18 +04:00
|
|
|
#include "mozilla/gfx/Rect.h"
|
2012-01-05 11:17:51 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2011-06-24 21:41:18 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
inline Rect ToRect(const gfxRect &aRect)
|
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
return Rect(Float(aRect.X()), Float(aRect.Y()),
|
2017-08-14 15:28:11 +03:00
|
|
|
Float(aRect.Width()), Float(aRect.Height()));
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2015-06-11 23:43:40 +03:00
|
|
|
inline RectDouble ToRectDouble(const gfxRect &aRect)
|
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
return RectDouble(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2015-06-11 23:43:40 +03:00
|
|
|
}
|
|
|
|
|
2012-01-05 11:17:51 +04:00
|
|
|
inline Matrix ToMatrix(const gfxMatrix &aMatrix)
|
|
|
|
{
|
2014-06-17 21:35:51 +04:00
|
|
|
return Matrix(Float(aMatrix._11), Float(aMatrix._12), Float(aMatrix._21),
|
|
|
|
Float(aMatrix._22), Float(aMatrix._31), Float(aMatrix._32));
|
2012-01-05 11:17:51 +04:00
|
|
|
}
|
|
|
|
|
2013-12-16 02:17:58 +04:00
|
|
|
inline gfxMatrix ThebesMatrix(const Matrix &aMatrix)
|
|
|
|
{
|
|
|
|
return gfxMatrix(aMatrix._11, aMatrix._12, aMatrix._21,
|
|
|
|
aMatrix._22, aMatrix._31, aMatrix._32);
|
|
|
|
}
|
|
|
|
|
2012-01-05 11:17:51 +04:00
|
|
|
inline Point ToPoint(const gfxPoint &aPoint)
|
|
|
|
{
|
|
|
|
return Point(Float(aPoint.x), Float(aPoint.y));
|
|
|
|
}
|
|
|
|
|
2015-11-11 07:36:29 +03:00
|
|
|
inline Size ToSize(const gfxSize &aSize)
|
|
|
|
{
|
|
|
|
return Size(Float(aSize.width), Float(aSize.height));
|
|
|
|
}
|
|
|
|
|
2012-01-05 11:17:51 +04:00
|
|
|
inline gfxPoint ThebesPoint(const Point &aPoint)
|
|
|
|
{
|
|
|
|
return gfxPoint(aPoint.x, aPoint.y);
|
|
|
|
}
|
|
|
|
|
2015-11-11 07:36:29 +03:00
|
|
|
inline gfxSize ThebesSize(const Size &aSize)
|
|
|
|
{
|
|
|
|
return gfxSize(aSize.width, aSize.height);
|
|
|
|
}
|
|
|
|
|
2012-01-05 11:17:51 +04:00
|
|
|
inline gfxRect ThebesRect(const Rect &aRect)
|
2011-06-24 21:41:18 +04:00
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2015-11-12 01:23:14 +03:00
|
|
|
inline gfxRect ThebesRect(const IntRect &aRect)
|
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2015-11-12 01:23:14 +03:00
|
|
|
}
|
|
|
|
|
2015-06-11 23:43:40 +03:00
|
|
|
inline gfxRect ThebesRect(const RectDouble &aRect)
|
|
|
|
{
|
2017-12-19 23:48:39 +03:00
|
|
|
return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
|
2015-06-11 23:43:40 +03:00
|
|
|
}
|
|
|
|
|
2013-09-25 00:45:13 +04:00
|
|
|
inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
|
2012-06-15 02:00:44 +04:00
|
|
|
{
|
|
|
|
switch (aFormat) {
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::A8R8G8B8_UINT32;
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::X8R8G8B8_UINT32;
|
2015-10-23 09:01:31 +03:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::R5G6B5_UINT16;
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::A8:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::A8;
|
2012-06-15 02:00:44 +04:00
|
|
|
default:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::UNKNOWN;
|
2012-06-15 02:00:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 00:45:13 +04:00
|
|
|
inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat)
|
2012-04-04 01:57:22 +04:00
|
|
|
{
|
|
|
|
switch (aFormat) {
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::A8R8G8B8_UINT32:
|
2014-01-10 23:06:16 +04:00
|
|
|
return SurfaceFormat::B8G8R8A8;
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::X8R8G8B8_UINT32:
|
2014-01-10 23:06:16 +04:00
|
|
|
return SurfaceFormat::B8G8R8X8;
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2015-10-23 09:01:31 +03:00
|
|
|
return SurfaceFormat::R5G6B5_UINT16;
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-10 23:06:16 +04:00
|
|
|
return SurfaceFormat::A8;
|
2012-04-04 01:57:22 +04:00
|
|
|
default:
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::UNKNOWN:
|
2014-01-10 23:06:16 +04:00
|
|
|
return SurfaceFormat::B8G8R8A8;
|
2012-04-04 01:57:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 00:45:13 +04:00
|
|
|
inline gfxContentType ContentForFormat(const SurfaceFormat &aFormat)
|
2011-06-24 21:41:18 +04:00
|
|
|
{
|
|
|
|
switch (aFormat) {
|
2015-10-23 09:01:31 +03:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::B8G8R8X8:
|
|
|
|
case SurfaceFormat::R8G8B8X8:
|
2014-01-23 22:26:40 +04:00
|
|
|
return gfxContentType::COLOR;
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::A8:
|
2014-01-23 22:26:40 +04:00
|
|
|
return gfxContentType::ALPHA;
|
2014-01-10 23:06:16 +04:00
|
|
|
case SurfaceFormat::B8G8R8A8:
|
|
|
|
case SurfaceFormat::R8G8B8A8:
|
2011-06-24 21:41:18 +04:00
|
|
|
default:
|
2014-01-23 22:26:40 +04:00
|
|
|
return gfxContentType::COLOR_ALPHA;
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2012-06-15 02:00:44 +04:00
|
|
|
|
|
|
|
#endif
|