Bug 1382128 part 3 - Rename WrByteSlice to ByteSlice. r?kats
MozReview-Commit-ID: 4jOsyvwxKrq
--- a/gfx/webrender_bindings/Moz2DImageRenderer.cpp
+++ b/gfx/webrender_bindings/Moz2DImageRenderer.cpp
@@ -85,17 +85,17 @@ static bool Moz2DRenderCallback(const Ra
return ret;
}
} // namespace
} // namespace
extern "C" {
-bool wr_moz2d_render_cb(const mozilla::wr::WrByteSlice blob,
+bool wr_moz2d_render_cb(const mozilla::wr::ByteSlice blob,
uint32_t width, uint32_t height,
mozilla::wr::ImageFormat aFormat,
mozilla::wr::MutByteSlice output)
{
return mozilla::wr::Moz2DRenderCallback(mozilla::wr::ByteSliceToRange(blob),
mozilla::gfx::IntSize(width, height),
mozilla::wr::WrImageFormatToSurfaceFormat(aFormat),
mozilla::wr::MutByteSliceToRange(output));
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -607,21 +607,21 @@ struct ByteBuffer
!(memcmp(mData, other.mData, mLength));
}
size_t mLength;
uint8_t* mData;
bool mOwned;
};
-inline wr::WrByteSlice RangeToByteSlice(mozilla::Range<uint8_t> aRange) {
- return wr::WrByteSlice { aRange.begin().get(), aRange.length() };
+inline wr::ByteSlice RangeToByteSlice(mozilla::Range<uint8_t> aRange) {
+ return wr::ByteSlice { aRange.begin().get(), aRange.length() };
}
-inline mozilla::Range<const uint8_t> ByteSliceToRange(wr::WrByteSlice aWrSlice) {
+inline mozilla::Range<const uint8_t> ByteSliceToRange(wr::ByteSlice aWrSlice) {
return mozilla::Range<const uint8_t>(aWrSlice.buffer, aWrSlice.len);
}
inline mozilla::Range<uint8_t> MutByteSliceToRange(wr::MutByteSlice aWrSlice) {
return mozilla::Range<uint8_t>(aWrSlice.buffer, aWrSlice.len);
}
struct BuiltDisplayList {
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -98,24 +98,24 @@ fn make_slice_mut<'a, T>(ptr: *mut T, le
if ptr.is_null() {
&mut []
} else {
unsafe { slice::from_raw_parts_mut(ptr, len) }
}
}
#[repr(C)]
-pub struct WrByteSlice {
+pub struct ByteSlice {
buffer: *const u8,
len: usize,
}
-impl WrByteSlice {
- pub fn new(slice: &[u8]) -> WrByteSlice {
- WrByteSlice {
+impl ByteSlice {
+ pub fn new(slice: &[u8]) -> ByteSlice {
+ ByteSlice {
buffer: &slice[0],
len: slice.len(),
}
}
pub fn as_slice(&self) -> &[u8] {
make_slice(self.buffer, self.len)
}
@@ -748,30 +748,30 @@ pub unsafe extern "C" fn wr_api_delete(a
let api = Box::from_raw(api);
api.shut_down();
}
#[no_mangle]
pub extern "C" fn wr_api_add_image(api: &mut WrAPI,
image_key: WrImageKey,
descriptor: &WrImageDescriptor,
- bytes: WrByteSlice) {
+ bytes: ByteSlice) {
assert!(unsafe { is_in_compositor_thread() });
let copied_bytes = bytes.as_slice().to_owned();
api.add_image(image_key,
descriptor.into(),
ImageData::new(copied_bytes),
None);
}
#[no_mangle]
pub extern "C" fn wr_api_add_blob_image(api: &mut WrAPI,
image_key: WrImageKey,
descriptor: &WrImageDescriptor,
- bytes: WrByteSlice) {
+ bytes: ByteSlice) {
assert!(unsafe { is_in_compositor_thread() });
let copied_bytes = bytes.as_slice().to_owned();
api.add_image(image_key,
descriptor.into(),
ImageData::new_blob_image(copied_bytes),
None);
}
@@ -808,17 +808,17 @@ pub extern "C" fn wr_api_add_external_im
}),
None);
}
#[no_mangle]
pub extern "C" fn wr_api_update_image(api: &mut WrAPI,
key: WrImageKey,
descriptor: &WrImageDescriptor,
- bytes: WrByteSlice) {
+ bytes: ByteSlice) {
assert!(unsafe { is_in_compositor_thread() });
let copied_bytes = bytes.as_slice().to_owned();
api.update_image(key, descriptor.into(), ImageData::new(copied_bytes), None);
}
#[no_mangle]
pub extern "C" fn wr_api_delete_image(api: &mut WrAPI,
@@ -1576,15 +1576,15 @@ pub extern "C" fn wr_dp_push_built_displ
mem::replace(dl_data, WrVecU8::from_vec(data));
}
// TODO: nical
// Update for the new blob image interface changes.
//
extern "C" {
// TODO: figure out the API for tiled blob images.
- pub fn wr_moz2d_render_cb(blob: WrByteSlice,
+ pub fn wr_moz2d_render_cb(blob: ByteSlice,
width: u32,
height: u32,
format: WrImageFormat,
output: MutByteSlice)
-> bool;
}
--- a/gfx/webrender_bindings/src/moz2d_renderer.rs
+++ b/gfx/webrender_bindings/src/moz2d_renderer.rs
@@ -1,10 +1,10 @@
use webrender_api::*;
-use bindings::{WrByteSlice, MutByteSlice, wr_moz2d_render_cb};
+use bindings::{ByteSlice, MutByteSlice, wr_moz2d_render_cb};
use rayon::ThreadPool;
use std::collections::hash_map::{HashMap, Entry};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::sync::Arc;
pub struct Moz2dImageRenderer {
blob_commands: HashMap<ImageKey, Arc<BlobImageData>>,
@@ -53,17 +53,17 @@ impl BlobImageRenderer for Moz2dImageRen
self.workers.spawn(move || {
let buf_size = (descriptor.width
* descriptor.height
* descriptor.format.bytes_per_pixel().unwrap()) as usize;
let mut output = vec![255u8; buf_size];
let result = unsafe {
if wr_moz2d_render_cb(
- WrByteSlice::new(&commands[..]),
+ ByteSlice::new(&commands[..]),
descriptor.width,
descriptor.height,
descriptor.format,
MutByteSlice::new(output.as_mut_slice())
) {
Ok(RasterizedBlobImage {
width: descriptor.width,
height: descriptor.height,
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -175,21 +175,21 @@ struct WrImageDescriptor {
return format == aOther.format &&
width == aOther.width &&
height == aOther.height &&
stride == aOther.stride &&
is_opaque == aOther.is_opaque;
}
};
-struct WrByteSlice {
+struct ByteSlice {
const uint8_t *buffer;
size_t len;
- bool operator==(const WrByteSlice& aOther) const {
+ bool operator==(const ByteSlice& aOther) const {
return buffer == aOther.buffer &&
len == aOther.len;
}
};
struct WrExternalImageId {
uint64_t mHandle;
@@ -428,44 +428,44 @@ struct WrGradientStop {
ColorF color;
bool operator==(const WrGradientStop& aOther) const {
return offset == aOther.offset &&
color == aOther.color;
}
};
+struct SideOffsets2D_f32 {
+ float top;
+ float right;
+ float bottom;
+ float left;
+
+ bool operator==(const SideOffsets2D_f32& aOther) const {
+ return top == aOther.top &&
+ right == aOther.right &&
+ bottom == aOther.bottom &&
+ left == aOther.left;
+ }
+};
+
struct SideOffsets2D_u32 {
uint32_t top;
uint32_t right;
uint32_t bottom;
uint32_t left;
bool operator==(const SideOffsets2D_u32& aOther) const {
return top == aOther.top &&
right == aOther.right &&
bottom == aOther.bottom &&
left == aOther.left;
}
};
-struct SideOffsets2D_f32 {
- float top;
- float right;
- float bottom;
- float left;
-
- bool operator==(const SideOffsets2D_f32& aOther) const {
- return top == aOther.top &&
- right == aOther.right &&
- bottom == aOther.bottom &&
- left == aOther.left;
- }
-};
-
struct WrNinePatchDescriptor {
uint32_t width;
uint32_t height;
SideOffsets2D_u32 slice;
bool operator==(const WrNinePatchDescriptor& aOther) const {
return width == aOther.width &&
height == aOther.height &&
@@ -593,17 +593,17 @@ struct WrExternalImageHandler {
* a. Alternatively, you can clone `https://github.com/rlhunt/cbindgen` and use a tagged release
* 2. Run `cbindgen toolkit/library/rust/ --crate webrender_bindings -o gfx/webrender_bindings/webrender_ffi_generated.h`
*/
WR_INLINE
void wr_api_add_blob_image(WrAPI *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
- WrByteSlice aBytes)
+ ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_add_external_image(WrAPI *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId,
WrExternalImageBufferType aBufferType,
@@ -616,17 +616,17 @@ void wr_api_add_external_image_buffer(Wr
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId)
WR_FUNC;
WR_INLINE
void wr_api_add_image(WrAPI *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
- WrByteSlice aBytes)
+ ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_add_raw_font(WrAPI *aApi,
WrFontKey aKey,
uint8_t *aFontBuffer,
size_t aBufferSize,
uint32_t aIndex)
@@ -703,17 +703,17 @@ void wr_api_set_window_parameters(WrAPI
int32_t aWidth,
int32_t aHeight)
WR_FUNC;
WR_INLINE
void wr_api_update_image(WrAPI *aApi,
WrImageKey aKey,
const WrImageDescriptor *aDescriptor,
- WrByteSlice aBytes)
+ ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_dp_begin(WrState *aState,
uint32_t aWidth,
uint32_t aHeight)
WR_FUNC;