2016-11-16 16:54:51 +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: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef WR_h
|
|
|
|
#define WR_h
|
2017-01-06 22:50:53 +03:00
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
#include "mozilla/gfx/Types.h"
|
2017-02-22 21:19:57 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "mozilla/gfx/Point.h"
|
2017-02-14 21:34:15 +03:00
|
|
|
// ---
|
|
|
|
#define WR_DECL_FFI_1(WrType, t1) \
|
|
|
|
struct WrType { \
|
|
|
|
t1 mHandle; \
|
|
|
|
bool operator==(const WrType& rhs) const { \
|
|
|
|
return mHandle == rhs.mHandle; \
|
|
|
|
} \
|
|
|
|
bool operator!=(const WrType& rhs) const { \
|
|
|
|
return mHandle != rhs.mHandle; \
|
|
|
|
} \
|
|
|
|
bool operator<(const WrType& rhs) const { \
|
|
|
|
return mHandle < rhs.mHandle; \
|
|
|
|
} \
|
2017-03-07 13:37:28 +03:00
|
|
|
bool operator<=(const WrType& rhs) const { \
|
|
|
|
return mHandle <= rhs.mHandle; \
|
|
|
|
} \
|
2017-02-14 21:34:15 +03:00
|
|
|
}; \
|
|
|
|
// ---
|
|
|
|
|
|
|
|
// ---
|
|
|
|
#define WR_DECL_FFI_2(WrType, t1, t2) \
|
|
|
|
struct WrType { \
|
|
|
|
t1 mNamespace; \
|
|
|
|
t2 mHandle; \
|
|
|
|
bool operator==(const WrType& rhs) const { \
|
|
|
|
return mNamespace == rhs.mNamespace \
|
|
|
|
&& mHandle == rhs.mHandle; \
|
|
|
|
} \
|
|
|
|
bool operator!=(const WrType& rhs) const { \
|
|
|
|
return mNamespace != rhs.mNamespace \
|
|
|
|
|| mHandle != rhs.mHandle; \
|
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
// ---
|
|
|
|
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
extern "C" {
|
2017-01-20 22:44:26 +03:00
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
// If you modify any of the declarations below, make sure to update the
|
|
|
|
// serialization code in WebRenderMessageUtils.h and the rust bindings.
|
|
|
|
|
|
|
|
WR_DECL_FFI_1(WrEpoch, uint32_t)
|
2017-02-22 21:19:57 +03:00
|
|
|
WR_DECL_FFI_1(WrIdNamespace, uint32_t)
|
2017-02-14 21:34:15 +03:00
|
|
|
WR_DECL_FFI_1(WrWindowId, uint64_t)
|
|
|
|
|
|
|
|
WR_DECL_FFI_2(WrPipelineId, uint32_t, uint32_t)
|
|
|
|
WR_DECL_FFI_2(WrImageKey, uint32_t, uint32_t)
|
|
|
|
WR_DECL_FFI_2(WrFontKey, uint32_t, uint32_t)
|
|
|
|
|
|
|
|
#undef WR_DECL_FFI_1
|
|
|
|
#undef WR_DECL_FFI_2
|
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
// ----
|
|
|
|
// Functions invoked from Rust code
|
|
|
|
// ----
|
|
|
|
|
2016-12-02 01:10:10 +03:00
|
|
|
bool is_in_compositor_thread();
|
2017-03-02 04:36:27 +03:00
|
|
|
bool is_in_main_thread();
|
2017-01-06 21:10:15 +03:00
|
|
|
bool is_in_render_thread();
|
2017-03-20 19:10:40 +03:00
|
|
|
bool is_glcontext_egl(void* glcontext_ptr);
|
2016-12-21 07:22:04 +03:00
|
|
|
void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname);
|
2016-12-02 01:10:10 +03:00
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
// -----
|
|
|
|
// Enums used in C++ code with corresponding enums in Rust code
|
|
|
|
// -----
|
2017-02-17 20:08:59 +03:00
|
|
|
enum class WrBoxShadowClipMode: uint32_t {
|
2017-02-16 21:23:22 +03:00
|
|
|
None,
|
|
|
|
Outset,
|
|
|
|
Inset,
|
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
2017-01-20 22:15:55 +03:00
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
enum class WrImageFormat: uint32_t
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
Invalid = 0,
|
|
|
|
A8 = 1,
|
|
|
|
RGB8 = 2,
|
|
|
|
RGBA8 = 3,
|
|
|
|
RGBAF32 = 4,
|
2017-01-20 22:44:26 +03:00
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
enum class WrBorderStyle: uint32_t
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
None = 0,
|
|
|
|
Solid = 1,
|
|
|
|
Double = 2,
|
|
|
|
Dotted = 3,
|
|
|
|
Dashed = 4,
|
|
|
|
Hidden = 5,
|
|
|
|
Groove = 6,
|
|
|
|
Ridge = 7,
|
|
|
|
Inset = 8,
|
|
|
|
Outset = 9,
|
2017-01-20 22:44:26 +03:00
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
enum class WrImageRendering: uint32_t
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
Auto = 0,
|
|
|
|
CrispEdges = 1,
|
|
|
|
Pixelated = 2,
|
2017-01-20 22:44:26 +03:00
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
|
|
|
|
2017-03-07 13:37:28 +03:00
|
|
|
enum class WrExternalImageIdType: uint32_t
|
|
|
|
{
|
|
|
|
NativeTexture, // Currently, we only support gl texture handle.
|
|
|
|
RawData,
|
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
2017-01-20 22:44:26 +03:00
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
enum class WrMixBlendMode: uint32_t
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-02-14 21:34:15 +03:00
|
|
|
Normal = 0,
|
|
|
|
Multiply = 1,
|
|
|
|
Screen = 2,
|
|
|
|
Overlay = 3,
|
|
|
|
Darken = 4,
|
|
|
|
Lighten = 5,
|
|
|
|
ColorDodge = 6,
|
|
|
|
ColorBurn = 7,
|
|
|
|
HardLight = 8,
|
|
|
|
SoftLight = 9,
|
|
|
|
Difference = 10,
|
|
|
|
Exclusion = 11,
|
|
|
|
Hue = 12,
|
|
|
|
Saturation = 13,
|
|
|
|
Color = 14,
|
|
|
|
Luminosity = 15,
|
2017-01-20 22:44:26 +03:00
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
2016-11-16 16:54:51 +03:00
|
|
|
};
|
|
|
|
|
2017-02-17 03:51:32 +03:00
|
|
|
enum class WrGradientExtendMode : uint32_t
|
|
|
|
{
|
|
|
|
Clamp = 0,
|
|
|
|
Repeat = 1,
|
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
|
|
|
|
2017-03-13 06:46:03 +03:00
|
|
|
enum class WrRepeatMode : uint32_t
|
|
|
|
{
|
|
|
|
Stretch = 0,
|
|
|
|
Repeat = 1,
|
|
|
|
Round = 2,
|
|
|
|
Space = 3,
|
|
|
|
|
|
|
|
Sentinel /* this must be last, for IPC serialization purposes */
|
|
|
|
};
|
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
// -----
|
|
|
|
// Typedefs for struct fields and function signatures below.
|
|
|
|
// -----
|
|
|
|
|
|
|
|
typedef uint64_t WrImageIdType;
|
2016-11-16 16:54:51 +03:00
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
// -----
|
|
|
|
// Structs used in C++ code with corresponding types in Rust code
|
|
|
|
// -----
|
|
|
|
|
2017-03-09 19:54:16 +03:00
|
|
|
struct WrItemRange
|
|
|
|
{
|
|
|
|
size_t start;
|
|
|
|
size_t length;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrBuiltDisplayListDescriptor {
|
2017-03-10 01:39:19 +03:00
|
|
|
size_t display_list_items_size;
|
2017-03-09 19:54:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WrAuxiliaryListsDescriptor {
|
2017-03-10 01:39:19 +03:00
|
|
|
size_t gradient_stops_size;
|
|
|
|
size_t complex_clip_regions_size;
|
|
|
|
size_t filters_size;
|
|
|
|
size_t glyph_instances_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrPoint
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
|
|
|
bool operator==(const WrPoint& aRhs) const {
|
|
|
|
return x == aRhs.x && y == aRhs.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator mozilla::gfx::Point() const { return mozilla::gfx::Point(x, y); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrSize
|
|
|
|
{
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
|
|
|
|
bool operator==(const WrSize& aRhs) const
|
|
|
|
{
|
|
|
|
return width == aRhs.width && height == aRhs.height;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrRect
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
|
|
|
|
bool operator==(const WrRect& aRhs) const
|
|
|
|
{
|
|
|
|
return x == aRhs.x && y == aRhs.y &&
|
|
|
|
width == aRhs.width && height == aRhs.height;
|
|
|
|
}
|
2017-03-09 19:54:16 +03:00
|
|
|
};
|
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
struct WrColor
|
|
|
|
{
|
2016-12-27 09:12:01 +03:00
|
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
|
|
|
float a;
|
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
bool operator==(const WrColor& aRhs) const
|
|
|
|
{
|
2016-12-27 09:12:01 +03:00
|
|
|
return r == aRhs.r && g == aRhs.g &&
|
|
|
|
b == aRhs.b && a == aRhs.a;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-24 16:44:23 +03:00
|
|
|
struct WrGlyphInstance
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-01-06 22:50:53 +03:00
|
|
|
uint32_t index;
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
2017-01-24 16:44:23 +03:00
|
|
|
bool operator==(const WrGlyphInstance& other) const
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-01-06 22:50:53 +03:00
|
|
|
return index == other.index &&
|
|
|
|
x == other.x &&
|
|
|
|
y == other.y;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Note that the type is slightly different than
|
2017-01-24 16:44:23 +03:00
|
|
|
// the definition in bindings.rs. WrGlyphInstance
|
2017-01-06 22:50:53 +03:00
|
|
|
// versus GlyphInstance, but their layout is the same.
|
|
|
|
// So we're really overlapping the types for the same memory.
|
2017-01-20 22:44:26 +03:00
|
|
|
struct WrGlyphArray
|
|
|
|
{
|
2017-01-13 13:25:07 +03:00
|
|
|
mozilla::gfx::Color color;
|
2017-01-24 16:44:23 +03:00
|
|
|
nsTArray<WrGlyphInstance> glyphs;
|
2017-01-06 22:50:53 +03:00
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
bool operator==(const WrGlyphArray& other) const
|
|
|
|
{
|
2017-01-06 22:50:53 +03:00
|
|
|
if (!(color == other.color) ||
|
|
|
|
(glyphs.Length() != other.glyphs.Length())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < glyphs.Length(); i++) {
|
|
|
|
if (!(glyphs[i] == other.glyphs[i])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-17 03:51:32 +03:00
|
|
|
struct WrGradientStop {
|
|
|
|
float offset;
|
|
|
|
WrColor color;
|
|
|
|
|
|
|
|
bool operator==(const WrGradientStop& aRhs) const
|
|
|
|
{
|
|
|
|
return offset == aRhs.offset && color == aRhs.color;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-17 17:53:57 +03:00
|
|
|
struct WrBorderSide {
|
2017-01-17 17:44:07 +03:00
|
|
|
WrColor color;
|
2017-01-17 17:53:57 +03:00
|
|
|
WrBorderStyle style;
|
2016-12-27 09:12:01 +03:00
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
bool operator==(const WrBorderSide& aRhs) const
|
|
|
|
{
|
2017-03-13 06:46:03 +03:00
|
|
|
return color == aRhs.color && style == aRhs.style;
|
2016-12-27 09:12:01 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-09 11:49:37 +03:00
|
|
|
struct WrBorderRadius {
|
2017-03-10 00:58:33 +03:00
|
|
|
WrSize top_left;
|
|
|
|
WrSize top_right;
|
|
|
|
WrSize bottom_left;
|
|
|
|
WrSize bottom_right;
|
2017-02-09 11:49:37 +03:00
|
|
|
|
|
|
|
bool operator==(const WrBorderRadius& aRhs) const
|
|
|
|
{
|
|
|
|
return top_left == aRhs.top_left && top_right == aRhs.top_right &&
|
|
|
|
bottom_left == aRhs.bottom_left && bottom_right == aRhs.bottom_right;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-13 06:46:03 +03:00
|
|
|
struct WrBorderWidths {
|
|
|
|
float left;
|
|
|
|
float top;
|
|
|
|
float right;
|
|
|
|
float bottom;
|
|
|
|
|
|
|
|
bool operator==(const WrBorderWidths& aRhs) const
|
|
|
|
{
|
|
|
|
return left == aRhs.left && top == aRhs.top &&
|
|
|
|
right == aRhs.right && bottom == aRhs.bottom;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrSideOffsets2Du32 {
|
|
|
|
uint32_t top;
|
|
|
|
uint32_t right;
|
|
|
|
uint32_t bottom;
|
|
|
|
uint32_t left;
|
|
|
|
|
|
|
|
bool operator==(const WrSideOffsets2Du32& aRhs) const
|
|
|
|
{
|
|
|
|
return top == aRhs.top && right == aRhs.right &&
|
|
|
|
bottom == aRhs.bottom && left == aRhs.left;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrSideOffsets2Df32 {
|
|
|
|
float top;
|
|
|
|
float right;
|
|
|
|
float bottom;
|
|
|
|
float left;
|
|
|
|
|
|
|
|
bool operator==(const WrSideOffsets2Df32& aRhs) const
|
|
|
|
{
|
|
|
|
return top == aRhs.top && right == aRhs.right &&
|
|
|
|
bottom == aRhs.bottom && left == aRhs.left;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrNinePatchDescriptor {
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
WrSideOffsets2Du32 slice;
|
|
|
|
|
|
|
|
bool operator==(const WrNinePatchDescriptor& aRhs) const
|
|
|
|
{
|
|
|
|
return width == aRhs.width && height == aRhs.height &&
|
|
|
|
slice == aRhs.slice;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-17 17:53:57 +03:00
|
|
|
struct WrImageMask
|
2016-11-16 16:54:51 +03:00
|
|
|
{
|
2017-01-20 22:44:26 +03:00
|
|
|
WrImageKey image;
|
|
|
|
WrRect rect;
|
|
|
|
bool repeat;
|
2016-11-18 11:07:02 +03:00
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
bool operator==(const WrImageMask& aRhs) const
|
|
|
|
{
|
|
|
|
return image == aRhs.image && rect == aRhs.rect && repeat == aRhs.repeat;
|
|
|
|
}
|
2016-11-16 16:54:51 +03:00
|
|
|
};
|
|
|
|
|
2017-03-09 19:54:16 +03:00
|
|
|
struct WrComplexClipRegion
|
|
|
|
{
|
|
|
|
WrRect rect;
|
|
|
|
WrBorderRadius radii;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WrClipRegion
|
|
|
|
{
|
|
|
|
WrRect main;
|
|
|
|
WrItemRange complex;
|
|
|
|
WrImageMask image_mask;
|
|
|
|
bool has_image_mask;
|
|
|
|
};
|
|
|
|
|
2017-03-01 12:08:56 +03:00
|
|
|
struct WrExternalImageId
|
2017-01-13 20:59:07 +03:00
|
|
|
{
|
2017-01-17 17:53:57 +03:00
|
|
|
WrImageIdType id;
|
2016-11-22 05:13:59 +03:00
|
|
|
};
|
|
|
|
|
2017-03-01 12:08:56 +03:00
|
|
|
struct WrExternalImage
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-03-07 13:37:28 +03:00
|
|
|
WrExternalImageIdType type;
|
2016-11-22 05:13:59 +03:00
|
|
|
|
|
|
|
// Texture coordinate
|
|
|
|
float u0, v0;
|
|
|
|
float u1, v1;
|
|
|
|
|
|
|
|
// external buffer handle
|
|
|
|
uint32_t handle;
|
|
|
|
|
2017-03-07 13:37:28 +03:00
|
|
|
// handle RawData.
|
|
|
|
uint8_t* buff;
|
|
|
|
size_t size;
|
2016-11-22 05:13:59 +03:00
|
|
|
};
|
|
|
|
|
2017-03-01 12:08:56 +03:00
|
|
|
typedef WrExternalImage (*LockExternalImageCallback)(void*, WrExternalImageId);
|
|
|
|
typedef void (*UnlockExternalImageCallback)(void*, WrExternalImageId);
|
|
|
|
typedef void (*ReleaseExternalImageCallback)(void*, WrExternalImageId);
|
2016-11-22 05:13:59 +03:00
|
|
|
|
2017-03-01 12:08:56 +03:00
|
|
|
struct WrExternalImageHandler
|
2017-01-20 22:44:26 +03:00
|
|
|
{
|
2017-03-01 12:08:56 +03:00
|
|
|
void* renderer_obj;
|
2017-01-13 15:02:19 +03:00
|
|
|
LockExternalImageCallback lock_func;
|
|
|
|
UnlockExternalImageCallback unlock_func;
|
2016-11-22 05:13:59 +03:00
|
|
|
ReleaseExternalImageCallback release_func;
|
|
|
|
};
|
2016-11-16 16:54:51 +03:00
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
struct WrImageDescriptor {
|
|
|
|
WrImageFormat format;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t stride;
|
|
|
|
bool is_opaque;
|
|
|
|
};
|
|
|
|
|
2017-03-01 17:10:53 +03:00
|
|
|
struct WrVecU8 {
|
|
|
|
uint8_t *data;
|
|
|
|
size_t length;
|
|
|
|
size_t capacity;
|
|
|
|
};
|
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
// -----
|
|
|
|
// Functions exposed by the webrender API
|
|
|
|
// -----
|
2016-11-16 16:54:51 +03:00
|
|
|
|
2017-01-20 22:46:58 +03:00
|
|
|
// Some useful defines to stub out webrender binding functions for when we
|
|
|
|
// build gecko without webrender. We try to tell the compiler these functions
|
|
|
|
// are unreachable in that case, but VC++ emits a warning if it finds any
|
|
|
|
// unreachable functions invoked from destructors. That warning gets turned into
|
|
|
|
// an error and causes the build to fail. So for wr_* functions called by
|
|
|
|
// destructors in C++ classes, use WR_DESTRUCTOR_SAFE_FUNC instead, which omits
|
|
|
|
// the unreachable annotation.
|
2017-03-23 00:36:25 +03:00
|
|
|
#ifdef MOZ_BUILD_WEBRENDER
|
2016-11-16 16:54:51 +03:00
|
|
|
# define WR_INLINE
|
|
|
|
# define WR_FUNC
|
2017-01-20 22:46:58 +03:00
|
|
|
# define WR_DESTRUCTOR_SAFE_FUNC
|
2016-11-16 16:54:51 +03:00
|
|
|
#else
|
|
|
|
# define WR_INLINE inline
|
|
|
|
# define WR_FUNC { MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("WebRender disabled"); }
|
2017-01-20 22:46:58 +03:00
|
|
|
# define WR_DESTRUCTOR_SAFE_FUNC {}
|
2016-11-16 16:54:51 +03:00
|
|
|
#endif
|
|
|
|
|
2017-01-20 22:44:26 +03:00
|
|
|
// Structs defined in Rust, but opaque to C++ code.
|
2017-01-27 23:30:18 +03:00
|
|
|
struct WrRenderedEpochs;
|
2017-01-06 21:10:03 +03:00
|
|
|
struct WrRenderer;
|
2017-01-17 17:32:25 +03:00
|
|
|
struct WrState;
|
2017-01-20 22:44:26 +03:00
|
|
|
struct WrAPI;
|
2017-01-06 21:10:03 +03:00
|
|
|
|
2017-03-01 12:08:56 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_renderer_set_external_image_handler(WrRenderer* renderer,
|
|
|
|
WrExternalImageHandler* handler)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-01-06 21:10:03 +03:00
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_renderer_update(WrRenderer* renderer)
|
|
|
|
WR_FUNC;
|
2017-01-06 21:10:03 +03:00
|
|
|
|
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_renderer_render(WrRenderer* renderer, uint32_t width, uint32_t height)
|
|
|
|
WR_FUNC;
|
2017-01-06 21:10:03 +03:00
|
|
|
|
2017-03-10 01:39:19 +03:00
|
|
|
// It is the responsibility of the caller to manage the dst_buffer memory
|
|
|
|
// and also free it at the proper time.
|
|
|
|
WR_INLINE const uint8_t*
|
2017-03-20 19:10:40 +03:00
|
|
|
wr_renderer_readback(WrRenderer* renderer,
|
|
|
|
uint32_t width, uint32_t height,
|
2017-03-10 01:39:19 +03:00
|
|
|
uint8_t* dst_buffer, size_t buffer_length)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-01-06 21:10:03 +03:00
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_renderer_set_profiler_enabled(WrRenderer* renderer, bool enabled)
|
|
|
|
WR_FUNC;
|
2017-01-06 21:10:03 +03:00
|
|
|
|
|
|
|
WR_INLINE bool
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_renderer_current_epoch(WrRenderer* renderer, WrPipelineId pipeline_id,
|
|
|
|
WrEpoch* out_epoch)
|
|
|
|
WR_FUNC;
|
2017-01-06 21:10:03 +03:00
|
|
|
|
2017-01-19 19:17:12 +03:00
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_renderer_delete(WrRenderer* renderer)
|
2017-01-20 22:46:58 +03:00
|
|
|
WR_DESTRUCTOR_SAFE_FUNC;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-27 23:30:18 +03:00
|
|
|
WR_INLINE WrRenderedEpochs*
|
|
|
|
wr_renderer_flush_rendered_epochs(WrRenderer* renderer) WR_FUNC;
|
|
|
|
|
|
|
|
WR_INLINE bool
|
|
|
|
wr_rendered_epochs_next(WrRenderedEpochs* pipeline_epochs,
|
|
|
|
WrPipelineId* out_pipeline,
|
|
|
|
WrEpoch* out_epoch) WR_FUNC;
|
|
|
|
|
|
|
|
WR_INLINE void
|
|
|
|
wr_rendered_epochs_delete(WrRenderedEpochs* pipeline_epochs) WR_DESTRUCTOR_SAFE_FUNC;
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
WR_INLINE bool
|
2017-02-16 09:01:04 +03:00
|
|
|
wr_window_new(WrWindowId window_id,
|
2017-03-07 02:46:30 +03:00
|
|
|
uint32_t window_width,
|
|
|
|
uint32_t window_height,
|
2017-02-16 09:01:04 +03:00
|
|
|
void* aGLContext,
|
|
|
|
bool enable_profiler,
|
|
|
|
WrAPI** out_api,
|
2017-01-20 22:44:26 +03:00
|
|
|
WrRenderer** out_renderer)
|
|
|
|
WR_FUNC;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_api_delete(WrAPI* api)
|
2017-01-20 22:46:58 +03:00
|
|
|
WR_DESTRUCTOR_SAFE_FUNC;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_add_image(WrAPI* api, WrImageKey key, const WrImageDescriptor* descriptor, uint8_t *buffer, size_t buffer_size)
|
2017-01-20 22:44:26 +03:00
|
|
|
WR_FUNC;
|
2017-01-12 17:31:31 +03:00
|
|
|
|
2017-03-02 04:22:40 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_add_external_image_handle(WrAPI* api, WrImageKey key, uint32_t width, uint32_t height,
|
|
|
|
WrImageFormat format, uint64_t external_image_id)
|
2017-01-20 22:44:26 +03:00
|
|
|
WR_FUNC;
|
2017-01-12 17:31:31 +03:00
|
|
|
|
2017-03-02 04:22:40 +03:00
|
|
|
WR_INLINE void
|
2017-03-09 05:10:09 +03:00
|
|
|
wr_api_add_external_image_buffer(WrAPI* api, WrImageKey key,
|
|
|
|
const WrImageDescriptor* descriptor,
|
|
|
|
uint64_t external_image_id)
|
2017-03-02 04:22:40 +03:00
|
|
|
WR_FUNC;
|
2017-02-10 18:16:47 +03:00
|
|
|
|
2017-01-12 17:31:31 +03:00
|
|
|
WR_INLINE void
|
2017-02-14 21:34:15 +03:00
|
|
|
wr_api_update_image(WrAPI* api, WrImageKey key,
|
|
|
|
const WrImageDescriptor* descriptor,
|
|
|
|
uint8_t *bytes, size_t size)
|
2017-01-20 22:44:26 +03:00
|
|
|
WR_FUNC;
|
2017-01-12 17:31:31 +03:00
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_api_delete_image(WrAPI* api, WrImageKey key)
|
|
|
|
WR_FUNC;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_api_set_root_pipeline(WrAPI* api, WrPipelineId pipeline_id)
|
|
|
|
WR_FUNC;
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-03-07 01:41:51 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_set_window_parameters(WrAPI* api, int width, int height)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
WR_INLINE void
|
2017-03-01 17:10:53 +03:00
|
|
|
wr_api_set_root_display_list(WrAPI* api, WrEpoch epoch, float w, float h,
|
|
|
|
WrPipelineId pipeline_id,
|
|
|
|
WrBuiltDisplayListDescriptor dl_descriptor,
|
|
|
|
uint8_t *dl_data,
|
|
|
|
size_t dl_size,
|
|
|
|
WrAuxiliaryListsDescriptor aux_descriptor,
|
|
|
|
uint8_t *aux_data,
|
|
|
|
size_t aux_size)
|
2017-01-20 22:44:26 +03:00
|
|
|
WR_FUNC;
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2017-03-06 04:42:17 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_clear_root_display_list(WrAPI* api, WrEpoch epoch, WrPipelineId pipeline_id)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-02-27 03:27:04 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_generate_frame(WrAPI* api)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-01-17 22:46:31 +03:00
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_api_send_external_event(WrAPI* api, uintptr_t evt)
|
2017-01-20 22:46:58 +03:00
|
|
|
WR_DESTRUCTOR_SAFE_FUNC;
|
2017-01-17 22:46:31 +03:00
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_add_raw_font(WrAPI* api, WrFontKey key, uint8_t* font_buffer, size_t buffer_size)
|
2017-01-20 22:44:26 +03:00
|
|
|
WR_FUNC;
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2017-03-10 01:39:19 +03:00
|
|
|
WR_INLINE WrIdNamespace
|
|
|
|
wr_api_get_namespace(WrAPI* api)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-01-17 17:32:25 +03:00
|
|
|
WR_INLINE WrState*
|
2017-02-24 00:12:40 +03:00
|
|
|
wr_state_new(WrPipelineId pipeline_id)
|
2017-01-20 22:44:26 +03:00
|
|
|
WR_FUNC;
|
2016-11-16 16:54:51 +03:00
|
|
|
|
|
|
|
WR_INLINE void
|
2017-01-20 22:44:26 +03:00
|
|
|
wr_state_delete(WrState* state)
|
2017-01-20 22:46:58 +03:00
|
|
|
WR_DESTRUCTOR_SAFE_FUNC;
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2017-03-10 01:39:19 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_dp_begin(WrState* wrState, uint32_t width, uint32_t height)
|
|
|
|
WR_FUNC;
|
|
|
|
|
|
|
|
WR_INLINE void
|
|
|
|
wr_dp_end(WrState* wrState)
|
|
|
|
WR_FUNC;
|
|
|
|
|
|
|
|
WR_INLINE WrClipRegion
|
|
|
|
wr_dp_new_clip_region(WrState* wrState,
|
|
|
|
WrRect main,
|
|
|
|
const WrComplexClipRegion* complex, size_t complexCount,
|
|
|
|
const WrImageMask* image_mask)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
WR_INLINE void
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_push_stacking_context(WrState *wrState, WrRect bounds,
|
2017-01-17 17:53:57 +03:00
|
|
|
WrRect overflow, const WrImageMask *mask,
|
2017-02-02 10:09:09 +03:00
|
|
|
float opacity, const float* matrix,
|
|
|
|
WrMixBlendMode mixBlendMode)
|
2016-11-16 16:54:51 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
|
|
|
//XXX: matrix should use a proper type
|
|
|
|
WR_INLINE void
|
2017-01-17 17:32:25 +03:00
|
|
|
wr_dp_pop_stacking_context(WrState *wrState)
|
2016-11-16 16:54:51 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
2017-02-14 21:34:15 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_dp_push_scroll_layer(WrState *wrState, WrRect bounds,
|
|
|
|
WrRect overflow, const WrImageMask *mask)
|
|
|
|
WR_FUNC;
|
|
|
|
|
|
|
|
WR_INLINE void
|
|
|
|
wr_dp_pop_scroll_layer(WrState *wrState)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
WR_INLINE void
|
2017-03-10 01:39:19 +03:00
|
|
|
wr_dp_push_iframe(WrState* wrState, WrRect bounds, WrClipRegion clip, WrPipelineId layers_id)
|
2017-01-12 17:31:31 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
WR_INLINE void
|
2017-03-10 01:39:19 +03:00
|
|
|
wr_dp_push_rect(WrState* wrState, WrRect bounds, WrClipRegion clip,
|
|
|
|
WrColor color)
|
2017-03-09 19:54:16 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
WR_INLINE void
|
2017-03-10 01:39:19 +03:00
|
|
|
wr_dp_push_image(WrState* wrState, WrRect bounds, WrClipRegion clip,
|
|
|
|
WrImageRendering filter, WrImageKey key)
|
2016-11-16 16:54:51 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
2016-12-27 09:12:01 +03:00
|
|
|
WR_INLINE void
|
2017-03-09 19:57:06 +03:00
|
|
|
wr_dp_push_text(WrState* wrState, WrRect bounds, WrClipRegion clip, WrColor color,
|
2017-01-24 16:44:23 +03:00
|
|
|
WrFontKey font_Key, const WrGlyphInstance* glyphs,
|
2017-01-20 22:44:26 +03:00
|
|
|
uint32_t glyph_count, float glyph_size)
|
|
|
|
WR_FUNC;
|
2017-01-13 13:25:07 +03:00
|
|
|
|
|
|
|
WR_INLINE void
|
2017-03-09 19:57:06 +03:00
|
|
|
wr_dp_push_border(WrState* wrState, WrRect bounds, WrClipRegion clip,
|
2017-03-13 06:46:03 +03:00
|
|
|
WrBorderWidths widths,
|
2017-01-17 17:53:57 +03:00
|
|
|
WrBorderSide top, WrBorderSide right, WrBorderSide bottom, WrBorderSide left,
|
2017-02-09 11:49:37 +03:00
|
|
|
WrBorderRadius radius)
|
2016-12-27 09:12:01 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
2017-03-13 06:46:03 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_dp_push_border_image(WrState* wrState, WrRect bounds, WrClipRegion clip,
|
|
|
|
WrBorderWidths widths,
|
|
|
|
WrImageKey image, WrNinePatchDescriptor patch, WrSideOffsets2Df32 outset,
|
|
|
|
WrRepeatMode repeat_horizontal,
|
|
|
|
WrRepeatMode repeat_vertical)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-02-17 03:51:32 +03:00
|
|
|
WR_INLINE void
|
2017-03-09 19:57:06 +03:00
|
|
|
wr_dp_push_linear_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
|
2017-02-17 03:51:32 +03:00
|
|
|
WrPoint startPoint, WrPoint endPoint,
|
|
|
|
const WrGradientStop* stops, size_t stopsCount,
|
2017-02-17 18:36:48 +03:00
|
|
|
WrGradientExtendMode extendMode)
|
2017-02-17 03:51:32 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
|
|
|
WR_INLINE void
|
2017-03-09 19:57:06 +03:00
|
|
|
wr_dp_push_radial_gradient(WrState* wrState, WrRect bounds, WrClipRegion clip,
|
2017-02-17 03:51:32 +03:00
|
|
|
WrPoint startCenter, WrPoint endCenter,
|
|
|
|
float startRadius, float endRadius,
|
|
|
|
const WrGradientStop* stops, size_t stopsCount,
|
2017-02-17 18:36:48 +03:00
|
|
|
WrGradientExtendMode extendMode)
|
2017-02-17 03:51:32 +03:00
|
|
|
WR_FUNC;
|
|
|
|
|
2017-02-16 21:23:22 +03:00
|
|
|
WR_INLINE void
|
2017-03-09 19:57:06 +03:00
|
|
|
wr_dp_push_box_shadow(WrState* wrState, WrRect rect, WrClipRegion clip,
|
2017-02-16 21:23:22 +03:00
|
|
|
WrRect box_bounds, WrPoint offset, WrColor color,
|
|
|
|
float blur_radius, float spread_radius, float border_radius,
|
|
|
|
WrBoxShadowClipMode clip_mode)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-03-01 17:10:53 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_api_finalize_builder(WrState* wrState,
|
|
|
|
WrBuiltDisplayListDescriptor& dl_descriptor,
|
|
|
|
WrVecU8& dl_data,
|
|
|
|
WrAuxiliaryListsDescriptor& aux_descriptor,
|
|
|
|
WrVecU8& aux_data)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-03-03 18:45:29 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_dp_push_built_display_list(WrState* wrState,
|
|
|
|
WrBuiltDisplayListDescriptor dl_descriptor,
|
|
|
|
WrVecU8 dl_data,
|
|
|
|
WrAuxiliaryListsDescriptor aux_descriptor,
|
|
|
|
WrVecU8 aux_data)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2017-03-01 17:10:53 +03:00
|
|
|
WR_INLINE void
|
|
|
|
wr_vec_u8_free(WrVecU8 dl_data)
|
|
|
|
WR_FUNC;
|
|
|
|
|
2016-11-16 16:54:51 +03:00
|
|
|
#undef WR_FUNC
|
2017-01-20 22:46:58 +03:00
|
|
|
#undef WR_DESTRUCTOR_SAFE_FUNC
|
2017-01-20 22:44:26 +03:00
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
#endif // WR_h
|