Bug 1355187 - Update some of the ExternalImage data types to be more similar in Rust and C++. r=rhunt

The WrExternalImageId is currently a struct wrapping a uint64_t on the C++ side,
which is unnecessary as we can just typedef it directly to a uint64_t. On the
Rust side it's a tuple of (u64).

Also the WrExternalImageIdType enum should be WrExternalImageType for consistency.

MozReview-Commit-ID: DgOf4xfY9h3
This commit is contained in:
Kartikaya Gupta 2017-04-10 17:38:02 -04:00
Родитель 1358415529
Коммит 6f05b1f766
3 изменённых файлов: 8 добавлений и 15 удалений

Просмотреть файл

@ -19,7 +19,7 @@ namespace wr {
WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId) WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId)
{ {
RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj); RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
RenderTextureHost* texture = renderer->GetRenderTexture(aId.id); RenderTextureHost* texture = renderer->GetRenderTexture(aId);
if (texture->AsBufferTextureHost()) { if (texture->AsBufferTextureHost()) {
RenderBufferTextureHost* bufferTexture = texture->AsBufferTextureHost(); RenderBufferTextureHost* bufferTexture = texture->AsBufferTextureHost();
@ -45,7 +45,7 @@ WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId)
void UnlockExternalImage(void* aObj, WrExternalImageId aId) void UnlockExternalImage(void* aObj, WrExternalImageId aId)
{ {
RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj); RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
RenderTextureHost* texture = renderer->GetRenderTexture(aId.id); RenderTextureHost* texture = renderer->GetRenderTexture(aId);
MOZ_ASSERT(texture); MOZ_ASSERT(texture);
texture->Unlock(); texture->Unlock();
} }

Просмотреть файл

@ -348,16 +348,14 @@ static inline WrComplexClipRegion ToWrComplexClipRegion(const gfx::RectTyped<T>&
static inline WrExternalImageId ToWrExternalImageId(uint64_t aID) static inline WrExternalImageId ToWrExternalImageId(uint64_t aID)
{ {
WrExternalImageId id; return aID;
id.id = aID;
return id;
} }
static inline WrExternalImage RawDataToWrExternalImage(const uint8_t* aBuff, static inline WrExternalImage RawDataToWrExternalImage(const uint8_t* aBuff,
size_t size) size_t size)
{ {
return WrExternalImage { return WrExternalImage {
WrExternalImageIdType::RawData, WrExternalImageType::RawData,
0, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0.0f, 0.0f, 0.0f, 0.0f,
aBuff, size aBuff, size
}; };
@ -368,7 +366,7 @@ static inline WrExternalImage NativeTextureToWrExternalImage(uint8_t aHandle,
float u1, float v1) float u1, float v1)
{ {
return WrExternalImage { return WrExternalImage {
WrExternalImageIdType::NativeTexture, WrExternalImageType::NativeTexture,
aHandle, u0, v0, u1, v1, aHandle, u0, v0, u1, v1,
nullptr, 0 nullptr, 0
}; };

Просмотреть файл

@ -128,7 +128,7 @@ enum class WrImageRendering: uint32_t
Sentinel /* this must be last, for IPC serialization purposes */ Sentinel /* this must be last, for IPC serialization purposes */
}; };
enum class WrExternalImageIdType: uint32_t enum class WrExternalImageType: uint32_t
{ {
NativeTexture, // Currently, we only support gl texture handle. NativeTexture, // Currently, we only support gl texture handle.
RawData, RawData,
@ -180,7 +180,7 @@ enum class WrRepeatMode : uint32_t
// Typedefs for struct fields and function signatures below. // Typedefs for struct fields and function signatures below.
// ----- // -----
typedef uint64_t WrImageIdType; typedef uint64_t WrExternalImageId;
// ----- // -----
// Structs used in C++ code with corresponding types in Rust code // Structs used in C++ code with corresponding types in Rust code
@ -404,14 +404,9 @@ struct WrClipRegion
bool has_image_mask; bool has_image_mask;
}; };
struct WrExternalImageId
{
WrImageIdType id;
};
struct WrExternalImage struct WrExternalImage
{ {
WrExternalImageIdType type; WrExternalImageType type;
// external texture handle // external texture handle
uint32_t handle; uint32_t handle;