зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1711648 - Move all device rects to the Box2D representations. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D116401 Depends on D116266
This commit is contained in:
Родитель
259f360733
Коммит
2c30dfddef
|
@ -312,8 +312,8 @@ void DCLayerTree::Bind(wr::NativeTileId aId, wr::DeviceIntPoint* aOffset,
|
|||
auto tile = surface->GetTile(aId.x, aId.y);
|
||||
wr::DeviceIntPoint targetOffset{0, 0};
|
||||
|
||||
gfx::IntRect validRect(aValidRect.origin.x, aValidRect.origin.y,
|
||||
aValidRect.size.width, aValidRect.size.height);
|
||||
gfx::IntRect validRect(aValidRect.min.x, aValidRect.min.y, aValidRect.width(),
|
||||
aValidRect.height());
|
||||
if (!tile->mValidRect.IsEqualEdges(validRect)) {
|
||||
tile->mValidRect = validRect;
|
||||
surface->DirtyAllocatedRect();
|
||||
|
@ -447,9 +447,8 @@ void DCLayerTree::AddSurface(wr::NativeSurfaceId aId,
|
|||
// on that. I suspect that will perform worse though, so we should only do
|
||||
// that for complex transforms (which are never provided right now).
|
||||
MOZ_ASSERT(transform.IsRectilinear());
|
||||
gfx::Rect clip = transform.Inverse().TransformBounds(
|
||||
gfx::Rect(aClipRect.origin.x, aClipRect.origin.y, aClipRect.size.width,
|
||||
aClipRect.size.height));
|
||||
gfx::Rect clip = transform.Inverse().TransformBounds(gfx::Rect(
|
||||
aClipRect.min.x, aClipRect.min.y, aClipRect.width(), aClipRect.height()));
|
||||
// Set the clip rect - converting from world space to the pre-offset space
|
||||
// that DC requires for rectangle clips.
|
||||
visual->SetClip(D2DRect(clip));
|
||||
|
@ -961,10 +960,10 @@ GLuint DCLayerTree::CreateEGLSurfaceForCompositionSurface(
|
|||
POINT offset;
|
||||
|
||||
RECT update_rect;
|
||||
update_rect.left = aSurfaceOffset.x + aDirtyRect.origin.x;
|
||||
update_rect.top = aSurfaceOffset.y + aDirtyRect.origin.y;
|
||||
update_rect.right = update_rect.left + aDirtyRect.size.width;
|
||||
update_rect.bottom = update_rect.top + aDirtyRect.size.height;
|
||||
update_rect.left = aSurfaceOffset.x + aDirtyRect.min.x;
|
||||
update_rect.top = aSurfaceOffset.y + aDirtyRect.min.y;
|
||||
update_rect.right = aSurfaceOffset.x + aDirtyRect.max.x;
|
||||
update_rect.bottom = aSurfaceOffset.y + aDirtyRect.max.y;
|
||||
|
||||
hr = aCompositionSurface->BeginDraw(&update_rect, __uuidof(ID3D11Texture2D),
|
||||
(void**)getter_AddRefs(backBuf), &offset);
|
||||
|
@ -977,8 +976,8 @@ GLuint DCLayerTree::CreateEGLSurfaceForCompositionSurface(
|
|||
|
||||
// DC includes the origin of the dirty / update rect in the draw offset,
|
||||
// undo that here since WR expects it to be an absolute offset.
|
||||
offset.x -= aDirtyRect.origin.x;
|
||||
offset.y -= aDirtyRect.origin.y;
|
||||
offset.x -= aDirtyRect.min.x;
|
||||
offset.y -= aDirtyRect.min.y;
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
backBuf->GetDesc(&desc);
|
||||
|
|
|
@ -543,12 +543,10 @@ RenderedFrameId RenderCompositorANGLE::EndFrame(
|
|||
for (size_t i = 0; i < aDirtyRects.Length(); ++i) {
|
||||
const DeviceIntRect& rect = aDirtyRects[i];
|
||||
// Clip rect to bufferSize
|
||||
int left = std::max(0, std::min(rect.origin.x, bufferSize.width));
|
||||
int top = std::max(0, std::min(rect.origin.y, bufferSize.height));
|
||||
int right = std::max(
|
||||
0, std::min(rect.origin.x + rect.size.width, bufferSize.width));
|
||||
int bottom = std::max(
|
||||
0, std::min(rect.origin.y + rect.size.height, bufferSize.height));
|
||||
int left = std::max(0, std::min(rect.min.x, bufferSize.width));
|
||||
int top = std::max(0, std::min(rect.min.y, bufferSize.height));
|
||||
int right = std::max(0, std::min(rect.max.x, bufferSize.width));
|
||||
int bottom = std::max(0, std::min(rect.max.y, bufferSize.height));
|
||||
|
||||
// When rect is not empty, the rect could be passed to Present1().
|
||||
if (left < right && top < bottom) {
|
||||
|
|
|
@ -227,11 +227,10 @@ bool RenderCompositorD3D11SWGL::TileD3D11::Map(wr::DeviceIntRect aDirtyRect,
|
|||
return false;
|
||||
}
|
||||
|
||||
*aData =
|
||||
map.mData + aValidRect.origin.y * map.mStride + aValidRect.origin.x * 4;
|
||||
*aData = map.mData + aValidRect.min.y * map.mStride + aValidRect.min.x * 4;
|
||||
*aStride = map.mStride;
|
||||
mValidRect = gfx::Rect(aValidRect.origin.x, aValidRect.origin.y,
|
||||
aValidRect.size.width, aValidRect.size.height);
|
||||
mValidRect = gfx::Rect(aValidRect.min.x, aValidRect.min.y,
|
||||
aValidRect.width(), aValidRect.height());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -293,13 +292,12 @@ bool RenderCompositorD3D11SWGL::TileD3D11::Map(wr::DeviceIntRect aDirtyRect,
|
|||
// rect, so take the mapped resource's data (which covers the full tile size)
|
||||
// and offset it by the top/left of the valid rect.
|
||||
*aData = (uint8_t*)mappedSubresource.pData +
|
||||
aValidRect.origin.y * mappedSubresource.RowPitch +
|
||||
aValidRect.origin.x * 4;
|
||||
aValidRect.min.y * mappedSubresource.RowPitch + aValidRect.min.x * 4;
|
||||
*aStride = mappedSubresource.RowPitch;
|
||||
|
||||
// Store the new valid rect, so that we can composite only those pixels
|
||||
mValidRect = gfx::Rect(aValidRect.origin.x, aValidRect.origin.y,
|
||||
aValidRect.size.width, aValidRect.size.height);
|
||||
mValidRect = gfx::Rect(aValidRect.min.x, aValidRect.min.y, aValidRect.width(),
|
||||
aValidRect.height());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -117,13 +117,11 @@ RenderedFrameId RenderCompositorEGL::EndFrame(
|
|||
gfx::IntRegion bufferInvalid;
|
||||
const auto bufferSize = GetBufferSize();
|
||||
for (const DeviceIntRect& rect : aDirtyRects) {
|
||||
const auto left = std::max(0, std::min(bufferSize.width, rect.origin.x));
|
||||
const auto top = std::max(0, std::min(bufferSize.height, rect.origin.y));
|
||||
const auto left = std::max(0, std::min(bufferSize.width, rect.min.x));
|
||||
const auto top = std::max(0, std::min(bufferSize.height, rect.min.y));
|
||||
|
||||
const auto right = std::min(bufferSize.width,
|
||||
std::max(0, rect.origin.x + rect.size.width));
|
||||
const auto bottom = std::min(
|
||||
bufferSize.height, std::max(0, rect.origin.y + rect.size.height));
|
||||
const auto right = std::min(bufferSize.width, std::max(0, rect.max.x));
|
||||
const auto bottom = std::min(bufferSize.height, std::max(0, rect.max.y));
|
||||
|
||||
const auto width = right - left;
|
||||
const auto height = bottom - top;
|
||||
|
@ -273,16 +271,14 @@ void RenderCompositorEGL::SetBufferDamageRegion(const wr::DeviceIntRect* aRects,
|
|||
const auto bufferSize = GetBufferSize();
|
||||
for (size_t i = 0; i < aNumRects; i++) {
|
||||
const auto left =
|
||||
std::max(0, std::min(bufferSize.width, aRects[i].origin.x));
|
||||
std::max(0, std::min(bufferSize.width, aRects[i].min.x));
|
||||
const auto top =
|
||||
std::max(0, std::min(bufferSize.height, aRects[i].origin.y));
|
||||
std::max(0, std::min(bufferSize.height, aRects[i].min.y));
|
||||
|
||||
const auto right =
|
||||
std::min(bufferSize.width,
|
||||
std::max(0, aRects[i].origin.x + aRects[i].size.width));
|
||||
std::min(bufferSize.width, std::max(0, aRects[i].max.x));
|
||||
const auto bottom =
|
||||
std::min(bufferSize.height,
|
||||
std::max(0, aRects[i].origin.y + aRects[i].size.height));
|
||||
std::min(bufferSize.height, std::max(0, aRects[i].max.y));
|
||||
|
||||
const auto width = right - left;
|
||||
const auto height = bottom - top;
|
||||
|
|
|
@ -88,8 +88,8 @@ void RenderCompositorLayersSWGL::StartCompositing(
|
|||
MOZ_RELEASE_ASSERT(aNumDirtyRects > 0);
|
||||
for (size_t i = 0; i < aNumDirtyRects; i++) {
|
||||
const auto& rect = aDirtyRects[i];
|
||||
dirty.OrWith(gfx::IntRect(rect.origin.x, rect.origin.y, rect.size.width,
|
||||
rect.size.height));
|
||||
dirty.OrWith(
|
||||
gfx::IntRect(rect.min.x, rect.min.y, rect.width(), rect.height()));
|
||||
}
|
||||
dirty.AndWith(bounds);
|
||||
|
||||
|
@ -97,8 +97,8 @@ void RenderCompositorLayersSWGL::StartCompositing(
|
|||
opaque.SubOut(mWidget->GetTransparentRegion().ToUnknownRegion());
|
||||
for (size_t i = 0; i < aNumOpaqueRects; i++) {
|
||||
const auto& rect = aOpaqueRects[i];
|
||||
opaque.OrWith(gfx::IntRect(rect.origin.x, rect.origin.y, rect.size.width,
|
||||
rect.size.height));
|
||||
opaque.OrWith(
|
||||
gfx::IntRect(rect.min.x, rect.min.y, rect.width(), rect.height()));
|
||||
}
|
||||
if (!mCompositor->BeginFrameForWindow(dirty, Nothing(), bounds, opaque)) {
|
||||
return;
|
||||
|
@ -188,21 +188,19 @@ bool RenderCompositorLayersSWGL::MapTile(wr::NativeTileId aId,
|
|||
|
||||
mCurrentTile = layerCursor->second.get();
|
||||
mCurrentTileId = aId;
|
||||
mCurrentTileDirty =
|
||||
gfx::IntRect(aDirtyRect.origin.x, aDirtyRect.origin.y,
|
||||
aDirtyRect.size.width, aDirtyRect.size.height);
|
||||
mCurrentTileDirty = gfx::IntRect(aDirtyRect.min.x, aDirtyRect.min.y,
|
||||
aDirtyRect.width(), aDirtyRect.height());
|
||||
|
||||
if (!mCurrentTile->Map(aDirtyRect, aValidRect, aData, aStride)) {
|
||||
gfxCriticalNote << "MapTile failed aValidRect: "
|
||||
<< gfx::Rect(aValidRect.origin.x, aValidRect.origin.y,
|
||||
aValidRect.size.width, aValidRect.size.height);
|
||||
<< gfx::Rect(aValidRect.min.x, aValidRect.min.y,
|
||||
aValidRect.width(), aValidRect.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the new valid rect, so that we can composite only those pixels
|
||||
mCurrentTile->mValidRect =
|
||||
gfx::Rect(aValidRect.origin.x, aValidRect.origin.y, aValidRect.size.width,
|
||||
aValidRect.size.height);
|
||||
mCurrentTile->mValidRect = gfx::Rect(aValidRect.min.x, aValidRect.min.y,
|
||||
aValidRect.width(), aValidRect.height());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -307,8 +305,8 @@ void RenderCompositorLayersSWGL::AddSurface(
|
|||
aTransform.m31, aTransform.m32, aTransform.m33, aTransform.m34,
|
||||
aTransform.m41, aTransform.m42, aTransform.m43, aTransform.m44);
|
||||
|
||||
gfx::IntRect clipRect(aClipRect.origin.x, aClipRect.origin.y,
|
||||
aClipRect.size.width, aClipRect.size.height);
|
||||
gfx::IntRect clipRect(aClipRect.min.x, aClipRect.min.y, aClipRect.width(),
|
||||
aClipRect.height());
|
||||
|
||||
mFrameSurfaces.AppendElement(FrameSurface{aId, transform, clipRect,
|
||||
ToSamplingFilter(aImageRendering)});
|
||||
|
|
|
@ -391,8 +391,8 @@ void RenderCompositorNative::AddSurface(
|
|||
gfx::IntPoint layerPosition(surface.mTileSize.width * it->first.mX,
|
||||
surface.mTileSize.height * it->first.mY);
|
||||
layer->SetPosition(layerPosition);
|
||||
gfx::IntRect clipRect(aClipRect.origin.x, aClipRect.origin.y,
|
||||
aClipRect.size.width, aClipRect.size.height);
|
||||
gfx::IntRect clipRect(aClipRect.min.x, aClipRect.min.y, aClipRect.width(),
|
||||
aClipRect.height());
|
||||
layer->SetClipRect(Some(clipRect));
|
||||
layer->SetTransform(transform);
|
||||
layer->SetSamplingFilter(ToSamplingFilter(aImageRendering));
|
||||
|
@ -505,10 +505,10 @@ void RenderCompositorNativeOGL::Bind(wr::NativeTileId aId,
|
|||
uint32_t* aFboId,
|
||||
wr::DeviceIntRect aDirtyRect,
|
||||
wr::DeviceIntRect aValidRect) {
|
||||
gfx::IntRect validRect(aValidRect.origin.x, aValidRect.origin.y,
|
||||
aValidRect.size.width, aValidRect.size.height);
|
||||
gfx::IntRect dirtyRect(aDirtyRect.origin.x, aDirtyRect.origin.y,
|
||||
aDirtyRect.size.width, aDirtyRect.size.height);
|
||||
gfx::IntRect validRect(aValidRect.min.x, aValidRect.min.y, aValidRect.width(),
|
||||
aValidRect.height());
|
||||
gfx::IntRect dirtyRect(aDirtyRect.min.x, aDirtyRect.min.y, aDirtyRect.width(),
|
||||
aDirtyRect.height());
|
||||
|
||||
BindNativeLayer(aId, dirtyRect);
|
||||
|
||||
|
@ -615,10 +615,10 @@ bool RenderCompositorNativeSWGL::MapTile(wr::NativeTileId aId,
|
|||
if (mNativeLayerForEntireWindow) {
|
||||
return false;
|
||||
}
|
||||
gfx::IntRect dirtyRect(aDirtyRect.origin.x, aDirtyRect.origin.y,
|
||||
aDirtyRect.size.width, aDirtyRect.size.height);
|
||||
gfx::IntRect validRect(aValidRect.origin.x, aValidRect.origin.y,
|
||||
aValidRect.size.width, aValidRect.size.height);
|
||||
gfx::IntRect dirtyRect(aDirtyRect.min.x, aDirtyRect.min.y, aDirtyRect.width(),
|
||||
aDirtyRect.height());
|
||||
gfx::IntRect validRect(aValidRect.min.x, aValidRect.min.y, aValidRect.width(),
|
||||
aValidRect.height());
|
||||
BindNativeLayer(aId, dirtyRect);
|
||||
if (!MapNativeLayer(mCurrentlyBoundNativeLayer, dirtyRect, validRect)) {
|
||||
UnbindNativeLayer();
|
||||
|
|
|
@ -69,13 +69,11 @@ RenderedFrameId RenderCompositorOGL::EndFrame(
|
|||
gfx::IntRegion bufferInvalid;
|
||||
const auto bufferSize = GetBufferSize();
|
||||
for (const DeviceIntRect& rect : aDirtyRects) {
|
||||
const auto left = std::max(0, std::min(bufferSize.width, rect.origin.x));
|
||||
const auto top = std::max(0, std::min(bufferSize.height, rect.origin.y));
|
||||
const auto left = std::max(0, std::min(bufferSize.width, rect.min.x));
|
||||
const auto top = std::max(0, std::min(bufferSize.height, rect.min.y));
|
||||
|
||||
const auto right = std::min(bufferSize.width,
|
||||
std::max(0, rect.origin.x + rect.size.width));
|
||||
const auto bottom = std::min(
|
||||
bufferSize.height, std::max(0, rect.origin.y + rect.size.height));
|
||||
const auto right = std::min(bufferSize.width, std::max(0, rect.max.x));
|
||||
const auto bottom = std::min(bufferSize.height, std::max(0, rect.max.y));
|
||||
|
||||
const auto width = right - left;
|
||||
const auto height = bottom - top;
|
||||
|
|
|
@ -380,9 +380,9 @@ bool RenderCompositorOGLSWGL::TileOGL::Map(wr::DeviceIntRect aDirtyRect,
|
|||
gl->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, mPBO);
|
||||
size_t stride = mSurface->Stride();
|
||||
size_t offset =
|
||||
stride * aValidRect.origin.y + aValidRect.origin.x * sizeof(uint32_t);
|
||||
size_t length = stride * (aValidRect.size.height - 1) +
|
||||
aValidRect.size.width * sizeof(uint32_t);
|
||||
stride * aValidRect.min.y + aValidRect.min.x * sizeof(uint32_t);
|
||||
size_t length = stride * (aValidRect.height() - 1) +
|
||||
(aValidRect.width()) * sizeof(uint32_t);
|
||||
void* data = gl->fMapBufferRange(
|
||||
LOCAL_GL_PIXEL_UNPACK_BUFFER, offset, length,
|
||||
LOCAL_GL_MAP_WRITE_BIT | LOCAL_GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
|
@ -400,8 +400,8 @@ bool RenderCompositorOGLSWGL::TileOGL::Map(wr::DeviceIntRect aDirtyRect,
|
|||
}
|
||||
// Verify that we're not somehow using a PBOUnpackSurface.
|
||||
MOZ_ASSERT(map.mData != nullptr);
|
||||
*aData = map.mData + aValidRect.origin.y * map.mStride +
|
||||
aValidRect.origin.x * sizeof(uint32_t);
|
||||
*aData = map.mData + aValidRect.min.y * map.mStride +
|
||||
aValidRect.min.x * sizeof(uint32_t);
|
||||
*aStride = map.mStride;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -131,8 +131,8 @@ bool RenderCompositorSWGL::AllocateMappedBuffer(
|
|||
LayoutDeviceIntRegion opaque;
|
||||
for (size_t i = 0; i < aNumOpaqueRects; i++) {
|
||||
const auto& rect = aOpaqueRects[i];
|
||||
opaque.OrWith(LayoutDeviceIntRect(rect.origin.x, rect.origin.y,
|
||||
rect.size.width, rect.size.height));
|
||||
opaque.OrWith(LayoutDeviceIntRect(rect.min.x, rect.min.y, rect.width(),
|
||||
rect.height()));
|
||||
}
|
||||
|
||||
LayoutDeviceIntRegion clear = mWidget->GetTransparentRegion();
|
||||
|
@ -162,8 +162,8 @@ void RenderCompositorSWGL::StartCompositing(
|
|||
mDirtyRegion.SetEmpty();
|
||||
for (size_t i = 0; i < aNumDirtyRects; i++) {
|
||||
const auto& rect = aDirtyRects[i];
|
||||
mDirtyRegion.OrWith(LayoutDeviceIntRect(
|
||||
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
|
||||
mDirtyRegion.OrWith(LayoutDeviceIntRect(rect.min.x, rect.min.y,
|
||||
rect.width(), rect.height()));
|
||||
}
|
||||
// Ensure the region lies within the widget bounds
|
||||
mDirtyRegion.AndWith(bounds);
|
||||
|
|
|
@ -305,10 +305,10 @@ bool TransactionBuilder::IsRenderedFrameInvalidated() const {
|
|||
void TransactionBuilder::SetDocumentView(
|
||||
const LayoutDeviceIntRect& aDocumentRect) {
|
||||
wr::DeviceIntRect wrDocRect;
|
||||
wrDocRect.origin.x = aDocumentRect.x;
|
||||
wrDocRect.origin.y = aDocumentRect.y;
|
||||
wrDocRect.size.width = aDocumentRect.width;
|
||||
wrDocRect.size.height = aDocumentRect.height;
|
||||
wrDocRect.min.x = aDocumentRect.x;
|
||||
wrDocRect.min.y = aDocumentRect.y;
|
||||
wrDocRect.max.x = aDocumentRect.x + aDocumentRect.width;
|
||||
wrDocRect.max.y = aDocumentRect.y + aDocumentRect.height;
|
||||
wr_transaction_set_document_view(mTxn, &wrDocRect);
|
||||
}
|
||||
|
||||
|
|
|
@ -345,10 +345,10 @@ static inline wr::LayoutRect ToLayoutRect(const gfx::Rect& rect) {
|
|||
static inline wr::DeviceIntRect ToDeviceIntRect(
|
||||
const mozilla::ImageIntRect& rect) {
|
||||
wr::DeviceIntRect r;
|
||||
r.origin.x = rect.X();
|
||||
r.origin.y = rect.Y();
|
||||
r.size.width = rect.Width();
|
||||
r.size.height = rect.Height();
|
||||
r.min.x = rect.X();
|
||||
r.min.y = rect.Y();
|
||||
r.max.x = rect.X() + rect.Width();
|
||||
r.max.y = rect.Y() + rect.Height();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,3 +47,9 @@ bitflags = true
|
|||
|
||||
[export.rename]
|
||||
"ThinVec" = "nsTArray"
|
||||
|
||||
[export.body]
|
||||
"Box2D" = """
|
||||
inline T width() const { return max.x - min.x; }
|
||||
inline T height() const { return max.y - min.y; }
|
||||
"""
|
|
@ -716,7 +716,7 @@ pub extern "C" fn wr_renderer_get_screenshot_async(
|
|||
assert!(!screenshot_height.is_null());
|
||||
|
||||
let (handle, size) = renderer.get_screenshot_async(
|
||||
DeviceIntRect::new(
|
||||
DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(window_x, window_y),
|
||||
DeviceIntSize::new(window_width, window_height),
|
||||
),
|
||||
|
@ -2103,7 +2103,7 @@ pub extern "C" fn wr_resource_updates_update_blob_image(
|
|||
descriptor.into(),
|
||||
Arc::new(bytes.flush_into_vec()),
|
||||
visible_rect,
|
||||
&DirtyRect::Partial(dirty_rect),
|
||||
&DirtyRect::Partial(dirty_rect.to_box2d()),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use rayon::ThreadPool;
|
|||
use webrender::api::units::{BlobDirtyRect, BlobToDeviceTranslation, DeviceIntRect};
|
||||
use webrender::api::*;
|
||||
|
||||
use euclid::Rect;
|
||||
use euclid::{Rect, Box2D};
|
||||
use std;
|
||||
use std::collections::btree_map::BTreeMap;
|
||||
use std::collections::hash_map;
|
||||
|
@ -273,6 +273,7 @@ impl BlobWriter {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: replace with euclid::Box2D
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Ord, PartialOrd)]
|
||||
#[repr(C)]
|
||||
/// A two-points representation of a rectangle.
|
||||
|
@ -329,6 +330,23 @@ impl<T> From<&Rect<i32, T>> for Box2d {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> From<Box2D<i32, T>> for Box2d {
|
||||
fn from(rect: Box2D<i32, T>) -> Box2d {
|
||||
(&rect).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<&Box2D<i32, T>> for Box2d {
|
||||
fn from(rect: &Box2D<i32, T>) -> Box2d {
|
||||
Box2d {
|
||||
x1: rect.min.x,
|
||||
y1: rect.min.y,
|
||||
x2: rect.max.x,
|
||||
y2: rect.max.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides an API for looking up the display items in a blob image by bounds, yielding items
|
||||
/// with equal bounds in their original relative ordering.
|
||||
///
|
||||
|
@ -634,7 +652,7 @@ fn rasterize_blob(job: Job) -> (BlobImageRequest, BlobImageResult) {
|
|||
let mut output = vec![0u8; buf_size];
|
||||
|
||||
let dirty_rect = match job.dirty_rect {
|
||||
DirtyRect::Partial(rect) => Some(rect),
|
||||
DirtyRect::Partial(rect) => Some(rect.to_rect()),
|
||||
DirtyRect::All => None,
|
||||
};
|
||||
assert!(descriptor.rect.size.width > 0 && descriptor.rect.size.height > 0);
|
||||
|
@ -653,9 +671,9 @@ fn rasterize_blob(job: Job) -> (BlobImageRequest, BlobImageResult) {
|
|||
) {
|
||||
// We want the dirty rect local to the tile rather than the whole image.
|
||||
// TODO(nical): move that up and avoid recomupting the tile bounds in the callback
|
||||
let dirty_rect = job.dirty_rect.to_subrect_of(&descriptor.rect);
|
||||
let dirty_rect = job.dirty_rect.to_subrect_of(&descriptor.rect.to_box2d());
|
||||
let tx: BlobToDeviceTranslation = (-descriptor.rect.origin.to_vector()).into();
|
||||
let rasterized_rect = tx.transform_rect(&dirty_rect);
|
||||
let rasterized_rect = tx.transform_box(&dirty_rect);
|
||||
|
||||
Ok(RasterizedBlobImage {
|
||||
rasterized_rect,
|
||||
|
@ -705,10 +723,10 @@ impl BlobImageHandler for Moz2dBlobImageHandler {
|
|||
let command = e.get_mut();
|
||||
let dirty_rect = if let DirtyRect::Partial(rect) = *dirty_rect {
|
||||
Box2d {
|
||||
x1: rect.min_x(),
|
||||
y1: rect.min_y(),
|
||||
x2: rect.max_x(),
|
||||
y2: rect.max_y(),
|
||||
x1: rect.min.x,
|
||||
y1: rect.min.y,
|
||||
x2: rect.max.x,
|
||||
y2: rect.max.y,
|
||||
}
|
||||
} else {
|
||||
Box2d {
|
||||
|
|
|
@ -62,7 +62,7 @@ impl App {
|
|||
|
||||
for (pipeline_id, color, offset) in init_data {
|
||||
let size = DeviceIntSize::new(250, 250);
|
||||
let bounds = DeviceIntRect::new(offset, size);
|
||||
let bounds = DeviceIntRect::from_origin_and_size(offset, size);
|
||||
|
||||
let document_id = api.add_document(size);
|
||||
let mut txn = Transaction::new();
|
||||
|
@ -74,7 +74,7 @@ impl App {
|
|||
pipeline_id,
|
||||
content_rect: LayoutRect::new(
|
||||
LayoutPoint::origin(),
|
||||
bounds.size.to_f32() / Scale::new(device_pixel_ratio),
|
||||
bounds.size().to_f32() / Scale::new(device_pixel_ratio),
|
||||
),
|
||||
color,
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ PER_INSTANCE in float aDevicePixelScale;
|
|||
PER_INSTANCE in ivec2 aTransformIds;
|
||||
|
||||
struct ClipMaskInstanceCommon {
|
||||
RectWithSize sub_rect;
|
||||
RectWithEndpoint sub_rect;
|
||||
vec2 task_origin;
|
||||
vec2 screen_origin;
|
||||
float device_pixel_scale;
|
||||
|
@ -23,7 +23,7 @@ struct ClipMaskInstanceCommon {
|
|||
ClipMaskInstanceCommon fetch_clip_item_common() {
|
||||
ClipMaskInstanceCommon cmi;
|
||||
|
||||
cmi.sub_rect = RectWithSize(aClipDeviceArea.xy, aClipDeviceArea.zw);
|
||||
cmi.sub_rect = RectWithEndpoint(aClipDeviceArea.xy, aClipDeviceArea.zw);
|
||||
cmi.task_origin = aClipOrigins.xy;
|
||||
cmi.screen_origin = aClipOrigins.zw;
|
||||
cmi.device_pixel_scale = aDevicePixelScale;
|
||||
|
@ -49,11 +49,11 @@ RectWithSize intersect_rect(RectWithSize a, RectWithSize b) {
|
|||
ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
|
||||
Transform prim_transform,
|
||||
Transform clip_transform,
|
||||
RectWithSize sub_rect,
|
||||
RectWithEndpoint sub_rect,
|
||||
vec2 task_origin,
|
||||
vec2 screen_origin,
|
||||
float device_pixel_scale) {
|
||||
vec2 device_pos = screen_origin + sub_rect.p0 + aPosition.xy * sub_rect.size;
|
||||
vec2 device_pos = screen_origin + mix(sub_rect.p0, sub_rect.p1, aPosition.xy);
|
||||
vec2 world_pos = device_pos / device_pixel_scale;
|
||||
|
||||
vec4 pos = prim_transform.m * vec4(world_pos, 0.0, 1.0);
|
||||
|
@ -70,7 +70,7 @@ ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
|
|||
// We can therefore simplify this when the clip construction is rewritten
|
||||
// to only affect the areas touched by a clip.
|
||||
vec4 vertex_pos = vec4(
|
||||
task_origin + sub_rect.p0 + aPosition.xy * sub_rect.size,
|
||||
task_origin + mix(sub_rect.p0, sub_rect.p1, aPosition.xy),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
|
|
|
@ -61,13 +61,13 @@ PER_INSTANCE attribute vec4 aUvRect0;
|
|||
|
||||
void main(void) {
|
||||
// Get world position
|
||||
vec2 world_pos = aDeviceRect.xy + aPosition.xy * aDeviceRect.zw;
|
||||
vec2 world_pos = mix(aDeviceRect.xy, aDeviceRect.zw, aPosition.xy);
|
||||
|
||||
// Clip the position to the world space clip rect
|
||||
vec2 clipped_world_pos = clamp(world_pos, aDeviceClipRect.xy, aDeviceClipRect.xy + aDeviceClipRect.zw);
|
||||
vec2 clipped_world_pos = clamp(world_pos, aDeviceClipRect.xy, aDeviceClipRect.zw);
|
||||
|
||||
// Derive the normalized UV from the clipped vertex position
|
||||
vec2 uv = (clipped_world_pos - aDeviceRect.xy) / aDeviceRect.zw;
|
||||
vec2 uv = (clipped_world_pos - aDeviceRect.xy) / (aDeviceRect.zw - aDeviceRect.xy);
|
||||
|
||||
#ifdef WR_FEATURE_YUV
|
||||
int yuv_color_space = int(aParams.y);
|
||||
|
|
|
@ -158,8 +158,9 @@ void main(void) {
|
|||
int style1 = (aFlags >> 16) & 0xff;
|
||||
int clip_mode = (aFlags >> 24) & 0x0f;
|
||||
|
||||
vec2 size = aRect.zw - aRect.xy;
|
||||
vec2 outer_scale = get_outer_corner_scale(segment);
|
||||
vec2 outer = outer_scale * aRect.zw;
|
||||
vec2 outer = outer_scale * size;
|
||||
vec2 clip_sign = 1.0 - 2.0 * outer_scale;
|
||||
|
||||
// Set some flags used by the FS to determine the
|
||||
|
@ -202,7 +203,7 @@ void main(void) {
|
|||
clip_mode
|
||||
);
|
||||
vPartialWidths = vec4(aWidths / 3.0, aWidths / 2.0);
|
||||
vPos = aRect.zw * aPosition.xy;
|
||||
vPos = size * aPosition.xy;
|
||||
|
||||
vec4[2] color0 = get_colors_for_side(aColor0, style0);
|
||||
vColor00 = color0[0];
|
||||
|
@ -228,7 +229,7 @@ void main(void) {
|
|||
radius += 2.0;
|
||||
|
||||
vPos = vClipParams1.xy + radius * (2.0 * aPosition.xy - 1.0);
|
||||
vPos = clamp(vPos, vec2(0.0), aRect.zw);
|
||||
vPos = clamp(vPos, vec2(0.0), size);
|
||||
} else if (clip_mode == CLIP_DASH_CORNER) {
|
||||
vec2 center = (aClipParams1.xy + aClipParams2.xy) * 0.5;
|
||||
// This is a gross approximation which works out because dashes don't have
|
||||
|
|
|
@ -85,7 +85,8 @@ void main(void) {
|
|||
bool do_aa = ((aFlags >> 24) & 0xf0) != 0;
|
||||
|
||||
vec2 outer_scale = get_outer_corner_scale(segment);
|
||||
vec2 outer = outer_scale * aRect.zw;
|
||||
vec2 size = aRect.zw - aRect.xy;
|
||||
vec2 outer = outer_scale * size;
|
||||
vec2 clip_sign = 1.0 - 2.0 * outer_scale;
|
||||
|
||||
int mix_colors;
|
||||
|
@ -103,7 +104,7 @@ void main(void) {
|
|||
}
|
||||
|
||||
vMixColors = mix_colors;
|
||||
vPos = aRect.zw * aPosition.xy;
|
||||
vPos = size * aPosition.xy;
|
||||
|
||||
vColor0 = aColor0;
|
||||
vColor1 = aColor1;
|
||||
|
|
|
@ -46,7 +46,7 @@ ClipImageVertexInfo write_clip_image_vertex(RectWithSize tile_rect,
|
|||
RectWithSize local_clip_rect,
|
||||
Transform prim_transform,
|
||||
Transform clip_transform,
|
||||
RectWithSize sub_rect,
|
||||
RectWithEndpoint sub_rect,
|
||||
vec2 task_origin,
|
||||
vec2 screen_origin,
|
||||
float device_pixel_scale) {
|
||||
|
|
|
@ -33,7 +33,7 @@ void main(void) {
|
|||
float d = aEndOffset - aStartOffset;
|
||||
v_offset_scale = d != 0.0 ? 1.0 / d : 0.0;
|
||||
|
||||
vec2 pos = aTaskRect.xy + aTaskRect.zw * aPosition.xy;
|
||||
vec2 pos = mix(aTaskRect.xy, aTaskRect.zw, aPosition.xy);
|
||||
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
|
||||
|
||||
v_angle = PI / 2.0 - aAngle;
|
||||
|
@ -42,7 +42,7 @@ void main(void) {
|
|||
// v_pos and v_center are in a coordinate space relative to the task rect
|
||||
// (so they are independent of the task origin).
|
||||
v_center = aCenter * v_offset_scale;
|
||||
v_pos = aTaskRect.zw * aPosition.xy * v_offset_scale * aScale;
|
||||
v_pos = (aTaskRect.zw - aTaskRect.xy) * aPosition.xy * v_offset_scale * aScale;
|
||||
|
||||
v_gradient_repeat = float(aExtendMode == EXTEND_MODE_REPEAT);
|
||||
v_gradient_address = aGradientStopsAddress;
|
||||
|
|
|
@ -21,7 +21,7 @@ void main(void) {
|
|||
vColor0 = aColor0;
|
||||
vColor1 = aColor1;
|
||||
|
||||
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * aPosition.xy, 0.0, 1.0);
|
||||
gl_Position = uTransform * vec4(mix(aTaskRect.xy, aTaskRect.zw, aPosition.xy), 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void main(void) {
|
|||
|
||||
vLocalPos = mix(aPosition.xy, aPosition.yx, aAxisSelect) * size;
|
||||
|
||||
gl_Position = uTransform * vec4(aTaskRect.xy + aTaskRect.zw * aPosition.xy, 0.0, 1.0);
|
||||
gl_Position = uTransform * vec4(mix(aTaskRect.xy, aTaskRect.zw, aPosition.xy), 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ PER_INSTANCE in int aExtendMode;
|
|||
PER_INSTANCE in int aGradientStopsAddress;
|
||||
|
||||
void main(void) {
|
||||
vec2 pos = aTaskRect.xy + aTaskRect.zw * aPosition.xy;
|
||||
vec2 pos = mix(aTaskRect.xy, aTaskRect.zw, aPosition.xy);
|
||||
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
|
||||
|
||||
v_pos = aPosition.xy * aScale;
|
||||
|
@ -33,7 +33,7 @@ void main(void) {
|
|||
v_scale_dir = dir / dot(dir, dir);
|
||||
v_start_offset = dot(aStartPoint, v_scale_dir);
|
||||
|
||||
v_scale_dir *= aTaskRect.zw;
|
||||
v_scale_dir *= (aTaskRect.zw - aTaskRect.xy);
|
||||
|
||||
v_gradient_repeat = float(aExtendMode == EXTEND_MODE_REPEAT);
|
||||
v_gradient_address = aGradientStopsAddress;
|
||||
|
|
|
@ -28,7 +28,7 @@ void main(void) {
|
|||
float rd = aEndRadius - aStartRadius;
|
||||
float radius_scale = rd != 0.0 ? 1.0 / rd : 0.0;
|
||||
|
||||
vec2 pos = aTaskRect.xy + aTaskRect.zw * aPosition.xy;
|
||||
vec2 pos = mix(aTaskRect.xy, aTaskRect.zw, aPosition.xy);
|
||||
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
|
||||
|
||||
v_start_radius = aStartRadius * radius_scale;
|
||||
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
|
||||
// v_pos is in a coordinate space relative to the task rect
|
||||
// (so it is independent of the task origin).
|
||||
v_pos = (aTaskRect.zw * aPosition.xy * aScale - aCenter) * radius_scale;
|
||||
v_pos = ((aTaskRect.zw - aTaskRect.xy) * aPosition.xy * aScale - aCenter) * radius_scale;
|
||||
v_pos.y *= aXYRatio;
|
||||
|
||||
v_gradient_repeat = float(aExtendMode == EXTEND_MODE_REPEAT);
|
||||
|
|
|
@ -22,7 +22,7 @@ PER_INSTANCE attribute vec4 aScaleSourceRect;
|
|||
|
||||
void main(void) {
|
||||
vec2 src_offset = aScaleSourceRect.xy;
|
||||
vec2 src_size = aScaleSourceRect.zw;
|
||||
vec2 src_size = aScaleSourceRect.zw - aScaleSourceRect.xy;
|
||||
|
||||
// If this is in WR_FEATURE_TEXTURE_RECT mode, the rect and size use
|
||||
// non-normalized texture coordinates.
|
||||
|
@ -37,7 +37,7 @@ void main(void) {
|
|||
vUvRect = vec4(src_offset + vec2(0.5),
|
||||
src_offset + src_size - vec2(0.5)) / texture_size.xyxy;
|
||||
|
||||
vec2 pos = aScaleTargetRect.xy + aScaleTargetRect.zw * aPosition.xy;
|
||||
vec2 pos = mix(aScaleTargetRect.xy, aScaleTargetRect.zw, aPosition.xy);
|
||||
vUv = (src_offset + src_size * aPosition.xy) / texture_size;
|
||||
|
||||
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
|
||||
|
|
|
@ -53,4 +53,3 @@ float signed_distance_rect(vec2 pos, vec2 p0, vec2 p1) {
|
|||
vec2 clamp_rect(vec2 pt, RectWithSize rect) {
|
||||
return clamp(pt, rect.p0, rect.p0 + rect.size);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ impl ApiResources {
|
|||
blobs_to_rasterize.push(img.key);
|
||||
}
|
||||
ResourceUpdate::UpdateBlobImage(ref img) => {
|
||||
debug_assert_eq!(img.visible_rect.size, img.descriptor.size);
|
||||
debug_assert_eq!(img.visible_rect.size(), img.descriptor.size);
|
||||
self.update_blob_image(
|
||||
img.key,
|
||||
Some(&img.descriptor),
|
||||
|
@ -212,7 +212,7 @@ impl ApiResources {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
let blob_size = visible_rect.size;
|
||||
let blob_size = visible_rect.size();
|
||||
|
||||
if let Some(descriptor) = descriptor {
|
||||
image.descriptor = *descriptor;
|
||||
|
@ -274,7 +274,7 @@ impl ApiResources {
|
|||
&template.visible_rect,
|
||||
template.tile_size,
|
||||
tile,
|
||||
).cast_unit(),
|
||||
).to_rect().cast_unit(),
|
||||
format: template.descriptor.format,
|
||||
};
|
||||
|
||||
|
|
|
@ -1360,7 +1360,7 @@ impl BatchBuilder {
|
|||
DeviceVector2D::new(0.5, 0.5)
|
||||
).floor() - glyph_translation;
|
||||
|
||||
let device_glyph_rect = DeviceRect::new(
|
||||
let device_glyph_rect = DeviceRect::from_origin_and_size(
|
||||
glyph.offset + raster_glyph_offset.to_vector() + raster_text_offset,
|
||||
glyph.size.to_f32(),
|
||||
);
|
||||
|
@ -1371,11 +1371,11 @@ impl BatchBuilder {
|
|||
let map_device_to_surface: SpaceMapper<PicturePixel, DevicePixel> = SpaceMapper::new_with_target(
|
||||
root_spatial_node_index,
|
||||
surface_spatial_node_index,
|
||||
device_bounding_rect,
|
||||
device_bounding_rect.to_rect(),
|
||||
ctx.spatial_tree,
|
||||
);
|
||||
|
||||
match map_device_to_surface.unmap(&device_bounding_rect) {
|
||||
match map_device_to_surface.unmap(&device_bounding_rect.to_rect()) {
|
||||
Some(r) => r.intersection(&bounding_rect),
|
||||
None => Some(*bounding_rect),
|
||||
}
|
||||
|
@ -3414,7 +3414,7 @@ impl ClipBatcher {
|
|||
return false;
|
||||
}
|
||||
|
||||
let mask_screen_rect_size = mask_screen_rect.size.to_i32();
|
||||
let mask_screen_rect_size = mask_screen_rect.size().to_i32();
|
||||
let clip_spatial_node = &spatial_tree
|
||||
.spatial_nodes[clip_spatial_node_index.0 as usize];
|
||||
|
||||
|
@ -3448,7 +3448,7 @@ impl ClipBatcher {
|
|||
// Because we only run this code path for axis-aligned rects (the root coord system check above),
|
||||
// and only for rectangles (not rounded etc), the world_device_rect is not conservative - we know
|
||||
// that there is no inner_rect, and the world_device_rect should be the real, axis-aligned clip rect.
|
||||
let mask_origin = mask_screen_rect.origin.to_vector();
|
||||
let mask_origin = mask_screen_rect.min.to_vector();
|
||||
let clip_list = self.get_batch_list(is_first_clip);
|
||||
|
||||
for y in 0 .. y_tiles {
|
||||
|
@ -3461,19 +3461,16 @@ impl ClipBatcher {
|
|||
(p0.x + CLIP_RECTANGLE_TILE_SIZE).min(mask_screen_rect_size.width),
|
||||
(p0.y + CLIP_RECTANGLE_TILE_SIZE).min(mask_screen_rect_size.height),
|
||||
);
|
||||
let normalized_sub_rect = DeviceIntRect::new(
|
||||
p0,
|
||||
DeviceIntSize::new(
|
||||
p1.x - p0.x,
|
||||
p1.y - p0.y,
|
||||
),
|
||||
).to_f32();
|
||||
let normalized_sub_rect = DeviceIntRect {
|
||||
min: p0,
|
||||
max: p1,
|
||||
}.to_f32();
|
||||
let world_sub_rect = normalized_sub_rect.translate(mask_origin);
|
||||
|
||||
// If the clip rect completely contains this tile rect, then drawing
|
||||
// these pixels would be redundant - since this clip can't possibly
|
||||
// affect the pixels in this tile, skip them!
|
||||
if !world_device_rect.contains_rect(&world_sub_rect) {
|
||||
if !world_device_rect.to_box2d().contains_box(&world_sub_rect) {
|
||||
clip_list.slow_rectangles.push(ClipMaskInstanceRect {
|
||||
common: ClipMaskInstanceCommon {
|
||||
sub_rect: normalized_sub_rect,
|
||||
|
@ -3555,10 +3552,7 @@ impl ClipBatcher {
|
|||
};
|
||||
|
||||
let common = ClipMaskInstanceCommon {
|
||||
sub_rect: DeviceRect::new(
|
||||
DevicePoint::zero(),
|
||||
actual_rect.size,
|
||||
),
|
||||
sub_rect: DeviceRect::from_size(actual_rect.size()),
|
||||
task_origin,
|
||||
screen_origin,
|
||||
device_pixel_scale: surface_device_pixel_scale.0,
|
||||
|
@ -3598,8 +3592,8 @@ impl ClipBatcher {
|
|||
// ensure nothing is drawn outside the target. If for some reason we can't map the
|
||||
// rect back to local space, we also fall back to just using a scissor rectangle.
|
||||
let world_rect =
|
||||
sub_rect.translate(actual_rect.origin.to_vector()) / surface_device_pixel_scale;
|
||||
let (clip_transform_id, local_rect, scissor) = match map_local_to_world.unmap(&world_rect) {
|
||||
sub_rect.translate(actual_rect.min.to_vector()) / surface_device_pixel_scale;
|
||||
let (clip_transform_id, local_rect, scissor) = match map_local_to_world.unmap(&world_rect.to_rect()) {
|
||||
Some(local_rect)
|
||||
if clip_transform_id.transform_kind() == TransformedRectKind::AxisAligned &&
|
||||
!map_local_to_world.get_transform().has_perspective_component() => {
|
||||
|
@ -3640,16 +3634,17 @@ impl ClipBatcher {
|
|||
let clip_is_axis_aligned = clip_spatial_node.coordinate_system_id == CoordinateSystemId::root();
|
||||
|
||||
if clip_instance.has_visible_tiles() {
|
||||
let sub_rect_bounds = actual_rect.size.into();
|
||||
let sub_rect_bounds = actual_rect.size().into();
|
||||
|
||||
for tile in clip_store.visible_mask_tiles(&clip_instance) {
|
||||
let tile_sub_rect = if clip_is_axis_aligned {
|
||||
let tile_world_rect = map_local_to_world
|
||||
.map(&tile.tile_rect)
|
||||
.expect("bug: should always map as axis-aligned");
|
||||
.expect("bug: should always map as axis-aligned")
|
||||
.to_box2d();
|
||||
let tile_device_rect = tile_world_rect * surface_device_pixel_scale;
|
||||
tile_device_rect
|
||||
.translate(-actual_rect.origin.to_vector())
|
||||
.translate(-actual_rect.min.to_vector())
|
||||
.round_out()
|
||||
.intersection(&sub_rect_bounds)
|
||||
} else {
|
||||
|
@ -3657,7 +3652,7 @@ impl ClipBatcher {
|
|||
};
|
||||
|
||||
if let Some(tile_sub_rect) = tile_sub_rect {
|
||||
assert!(sub_rect_bounds.contains_rect(&tile_sub_rect));
|
||||
assert!(sub_rect_bounds.contains_box(&tile_sub_rect));
|
||||
add_image(
|
||||
request.with_tile(tile.tile_offset),
|
||||
tile.tile_rect,
|
||||
|
@ -3675,7 +3670,7 @@ impl ClipBatcher {
|
|||
if is_first_clip &&
|
||||
(!clip_is_axis_aligned ||
|
||||
!(map_local_to_world.map(&rect).expect("bug: should always map as axis-aligned")
|
||||
* surface_device_pixel_scale).contains_rect(&actual_rect)) {
|
||||
* surface_device_pixel_scale).contains_rect(&actual_rect.to_rect())) {
|
||||
clear_to_one = true;
|
||||
}
|
||||
true
|
||||
|
|
|
@ -995,10 +995,10 @@ fn add_segment(
|
|||
match style0 {
|
||||
BorderStyle::Dashed => {
|
||||
let (x, y) = if is_vertical {
|
||||
let half_dash_size = task_rect.size.height * 0.25;
|
||||
let half_dash_size = task_rect.height() * 0.25;
|
||||
(0., half_dash_size)
|
||||
} else {
|
||||
let half_dash_size = task_rect.size.width * 0.25;
|
||||
let half_dash_size = task_rect.width() * 0.25;
|
||||
(half_dash_size, 0.)
|
||||
};
|
||||
|
||||
|
@ -1282,7 +1282,7 @@ pub fn build_border_instances(
|
|||
let v_corner_radius = (LayoutSize::from_au(cache_key.v_adjacent_corner_radius) * scale).ceil();
|
||||
|
||||
add_segment(
|
||||
DeviceRect::new(DevicePoint::zero(), cache_size.to_f32()),
|
||||
DeviceRect::from_size(cache_size.to_f32()),
|
||||
style0,
|
||||
style1,
|
||||
color0,
|
||||
|
|
|
@ -675,8 +675,8 @@ impl CompositeState {
|
|||
kind: tile_kind(&surface, compositor_surface.is_opaque),
|
||||
surface,
|
||||
rect: external_surface.surface_rect,
|
||||
valid_rect: external_surface.surface_rect.translate(-external_surface.surface_rect.origin.to_vector()),
|
||||
dirty_rect: external_surface.surface_rect.translate(-external_surface.surface_rect.origin.to_vector()),
|
||||
valid_rect: external_surface.surface_rect.translate(-external_surface.surface_rect.min.to_vector()),
|
||||
dirty_rect: external_surface.surface_rect.translate(-external_surface.surface_rect.min.to_vector()),
|
||||
clip_rect,
|
||||
transform: Some(external_surface.transform),
|
||||
z_id: external_surface.z_id,
|
||||
|
|
|
@ -72,7 +72,7 @@ impl SwTile {
|
|||
clip_rect: &DeviceIntRect,
|
||||
) -> Option<DeviceIntRect> {
|
||||
let bounds = self.local_bounds(surface);
|
||||
let device_rect = transform.outer_transformed_rect(&bounds.to_f32())?.round_out().to_i32();
|
||||
let device_rect = transform.outer_transformed_box2d(&bounds.to_f32())?.round_out().to_i32();
|
||||
device_rect.intersection(clip_rect)
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ impl SwTile {
|
|||
// Offset the valid rect to the appropriate surface origin.
|
||||
let valid = self.local_bounds(surface);
|
||||
// The destination rect is the valid rect transformed and then clipped.
|
||||
let dest_rect = transform.outer_transformed_rect(&valid.to_f32())?.round_out().to_i32();
|
||||
let dest_rect = transform.outer_transformed_box2d(&valid.to_f32())?.round_out().to_i32();
|
||||
if !dest_rect.intersects(clip_rect) {
|
||||
return None;
|
||||
}
|
||||
|
@ -110,10 +110,10 @@ impl SwTile {
|
|||
// a source rect that is now relative to the surface origin rather than absolute.
|
||||
let inv_transform = transform.inverse()?;
|
||||
let src_rect = inv_transform
|
||||
.outer_transformed_rect(&dest_rect.to_f32())?
|
||||
.outer_transformed_box2d(&dest_rect.to_f32())?
|
||||
.round()
|
||||
.to_i32()
|
||||
.translate(-valid.origin.to_vector());
|
||||
.translate(-valid.min.to_vector());
|
||||
Some((src_rect, dest_rect, transform.m22 < 0.0))
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ impl SwSurface {
|
|||
clip_rect: &DeviceIntRect,
|
||||
) -> Option<DeviceIntRect> {
|
||||
let bounds = self.local_bounds();
|
||||
let device_rect = transform.outer_transformed_rect(&bounds.to_f32())?.round_out().to_i32();
|
||||
let device_rect = transform.outer_transformed_box2d(&bounds.to_f32())?.round_out().to_i32();
|
||||
device_rect.intersection(clip_rect)
|
||||
}
|
||||
}
|
||||
|
@ -212,32 +212,32 @@ impl SwCompositeJob {
|
|||
let band_index = num_bands - 1 - band_index;
|
||||
// Calculate the Y extents for the job's band, starting at the current index and spanning to
|
||||
// the following index.
|
||||
let band_offset = (self.clipped_dst.size.height * band_index) / num_bands;
|
||||
let band_height = (self.clipped_dst.size.height * (band_index + 1)) / num_bands - band_offset;
|
||||
let band_offset = (self.clipped_dst.height() * band_index) / num_bands;
|
||||
let band_height = (self.clipped_dst.height() * (band_index + 1)) / num_bands - band_offset;
|
||||
// Create a rect that is the intersection of the band with the clipped dest
|
||||
let band_clip = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(self.clipped_dst.origin.x, self.clipped_dst.origin.y + band_offset),
|
||||
DeviceIntSize::new(self.clipped_dst.size.width, band_height),
|
||||
let band_clip = DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(self.clipped_dst.min.x, self.clipped_dst.min.y + band_offset),
|
||||
DeviceIntSize::new(self.clipped_dst.width(), band_height),
|
||||
);
|
||||
match self.locked_src {
|
||||
SwCompositeSource::BGRA(ref resource) => {
|
||||
self.locked_dst.composite(
|
||||
resource,
|
||||
self.src_rect.origin.x,
|
||||
self.src_rect.origin.y,
|
||||
self.src_rect.size.width,
|
||||
self.src_rect.size.height,
|
||||
self.dst_rect.origin.x,
|
||||
self.dst_rect.origin.y,
|
||||
self.dst_rect.size.width,
|
||||
self.dst_rect.size.height,
|
||||
self.src_rect.min.x,
|
||||
self.src_rect.min.y,
|
||||
self.src_rect.width(),
|
||||
self.src_rect.height(),
|
||||
self.dst_rect.min.x,
|
||||
self.dst_rect.min.y,
|
||||
self.dst_rect.width(),
|
||||
self.dst_rect.height(),
|
||||
self.opaque,
|
||||
self.flip_y,
|
||||
image_rendering_to_gl_filter(self.filter),
|
||||
band_clip.origin.x,
|
||||
band_clip.origin.y,
|
||||
band_clip.size.width,
|
||||
band_clip.size.height,
|
||||
band_clip.min.x,
|
||||
band_clip.min.y,
|
||||
band_clip.width(),
|
||||
band_clip.height(),
|
||||
);
|
||||
}
|
||||
SwCompositeSource::YUV(ref y, ref u, ref v, color_space, color_depth) => {
|
||||
|
@ -253,19 +253,19 @@ impl SwCompositeJob {
|
|||
v,
|
||||
swgl_color_space,
|
||||
color_depth.bit_depth(),
|
||||
self.src_rect.origin.x,
|
||||
self.src_rect.origin.y,
|
||||
self.src_rect.size.width,
|
||||
self.src_rect.size.height,
|
||||
self.dst_rect.origin.x,
|
||||
self.dst_rect.origin.y,
|
||||
self.dst_rect.size.width,
|
||||
self.dst_rect.size.height,
|
||||
self.src_rect.min.x,
|
||||
self.src_rect.min.y,
|
||||
self.src_rect.width(),
|
||||
self.src_rect.height(),
|
||||
self.dst_rect.min.x,
|
||||
self.dst_rect.min.y,
|
||||
self.dst_rect.width(),
|
||||
self.dst_rect.height(),
|
||||
self.flip_y,
|
||||
band_clip.origin.x,
|
||||
band_clip.origin.y,
|
||||
band_clip.size.width,
|
||||
band_clip.size.height,
|
||||
band_clip.min.x,
|
||||
band_clip.min.y,
|
||||
band_clip.width(),
|
||||
band_clip.height(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -526,8 +526,8 @@ impl SwCompositeThread {
|
|||
None => return,
|
||||
};
|
||||
|
||||
let num_bands = if clipped_dst.size.width >= 64 && clipped_dst.size.height >= 64 {
|
||||
(clipped_dst.size.height / 64).min(4) as u8
|
||||
let num_bands = if clipped_dst.width() >= 64 && clipped_dst.height() >= 64 {
|
||||
(clipped_dst.height() / 64).min(4) as u8
|
||||
} else {
|
||||
1
|
||||
};
|
||||
|
@ -791,13 +791,13 @@ impl SwCompositor {
|
|||
}
|
||||
|
||||
fn set_x_range(rect: &mut DeviceIntRect, range: &Range<i32>) {
|
||||
rect.origin.x = range.start;
|
||||
rect.size.width = range.end - range.start;
|
||||
rect.min.x = range.start;
|
||||
rect.max.x = range.end;
|
||||
}
|
||||
|
||||
fn set_y_range(rect: &mut DeviceIntRect, range: &Range<i32>) {
|
||||
rect.origin.y = range.start;
|
||||
rect.size.height = range.end - range.start;
|
||||
rect.min.y = range.start;
|
||||
rect.max.y = range.end;
|
||||
}
|
||||
|
||||
fn union(base: Range<i32>, extra: Range<i32>) -> Range<i32> {
|
||||
|
@ -1266,8 +1266,8 @@ impl Compositor for SwCompositor {
|
|||
self.gl.set_texture_buffer(
|
||||
tile.color_id,
|
||||
gl::RGBA8,
|
||||
valid_rect.size.width,
|
||||
valid_rect.size.height,
|
||||
valid_rect.width(),
|
||||
valid_rect.height(),
|
||||
stride,
|
||||
buf,
|
||||
surface.tile_size.width,
|
||||
|
@ -1285,15 +1285,15 @@ impl Compositor for SwCompositor {
|
|||
self.gl.set_texture_buffer(
|
||||
self.depth_id,
|
||||
gl::DEPTH_COMPONENT,
|
||||
valid_rect.size.width,
|
||||
valid_rect.size.height,
|
||||
valid_rect.width(),
|
||||
valid_rect.height(),
|
||||
0,
|
||||
ptr::null_mut(),
|
||||
self.max_tile_size.width,
|
||||
self.max_tile_size.height,
|
||||
);
|
||||
surface_info.fbo_id = tile.fbo_id;
|
||||
surface_info.origin -= valid_rect.origin.to_vector();
|
||||
surface_info.origin -= valid_rect.min.to_vector();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1244,8 +1244,12 @@ impl DrawTarget {
|
|||
DrawTarget::Default { ref rect, surface_origin_is_top_left, .. } => {
|
||||
// perform a Y-flip here
|
||||
if !surface_origin_is_top_left {
|
||||
fb_rect.origin.y = rect.origin.y + rect.size.height - fb_rect.origin.y - fb_rect.size.height;
|
||||
fb_rect.origin.x += rect.origin.x;
|
||||
let w = fb_rect.width();
|
||||
let h = fb_rect.height();
|
||||
fb_rect.min.x = fb_rect.min.x + rect.min.x;
|
||||
fb_rect.min.y = rect.max.y - fb_rect.max.y;
|
||||
fb_rect.max.x = fb_rect.min.x + w;
|
||||
fb_rect.max.y = fb_rect.min.y + h;
|
||||
}
|
||||
}
|
||||
DrawTarget::Texture { .. } | DrawTarget::External { .. } | DrawTarget::NativeSurface { .. } => (),
|
||||
|
@ -1284,8 +1288,7 @@ impl DrawTarget {
|
|||
}
|
||||
}
|
||||
None => {
|
||||
FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
FramebufferIntRect::from_size(
|
||||
device_size_as_framebuffer_size(dimensions),
|
||||
)
|
||||
}
|
||||
|
@ -2122,8 +2125,7 @@ impl Device {
|
|||
(self.default_draw_fbo, rect, false)
|
||||
}
|
||||
DrawTarget::Texture { dimensions, fbo_id, with_depth, .. } => {
|
||||
let rect = FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
let rect = FramebufferIntRect::from_size(
|
||||
device_size_as_framebuffer_size(dimensions),
|
||||
);
|
||||
(fbo_id, rect, with_depth)
|
||||
|
@ -2134,7 +2136,7 @@ impl Device {
|
|||
DrawTarget::NativeSurface { external_fbo_id, offset, dimensions, .. } => {
|
||||
(
|
||||
FBOId(external_fbo_id),
|
||||
device_rect_as_framebuffer_rect(&DeviceIntRect::new(offset, dimensions)),
|
||||
device_rect_as_framebuffer_rect(&DeviceIntRect::from_origin_and_size(offset, dimensions)),
|
||||
true
|
||||
)
|
||||
}
|
||||
|
@ -2143,10 +2145,10 @@ impl Device {
|
|||
self.depth_available = depth_available;
|
||||
self.bind_draw_target_impl(fbo_id);
|
||||
self.gl.viewport(
|
||||
rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.size.width,
|
||||
rect.size.height,
|
||||
rect.min.x,
|
||||
rect.min.y,
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2564,9 +2566,9 @@ impl Device {
|
|||
|
||||
self.blit_render_target(
|
||||
ReadTarget::from_texture(src_texture),
|
||||
FramebufferIntRect::new(src_offset, size),
|
||||
FramebufferIntRect::from_origin_and_size(src_offset, size),
|
||||
DrawTarget::from_texture(dest_texture, false),
|
||||
FramebufferIntRect::new(dest_offset, size),
|
||||
FramebufferIntRect::from_origin_and_size(dest_offset, size),
|
||||
// In most cases the filter shouldn't matter, as there is no scaling involved
|
||||
// in the blit. We were previously using Linear, but this caused issues when
|
||||
// blitting RGBAF32 textures on Mali, so use Nearest to be safe.
|
||||
|
@ -2720,18 +2722,18 @@ impl Device {
|
|||
TextureFilter::Linear | TextureFilter::Trilinear => gl::LINEAR,
|
||||
};
|
||||
|
||||
let src_x0 = src_rect.origin.x + self.bound_read_fbo.1.x;
|
||||
let src_y0 = src_rect.origin.y + self.bound_read_fbo.1.y;
|
||||
let src_x0 = src_rect.min.x + self.bound_read_fbo.1.x;
|
||||
let src_y0 = src_rect.min.y + self.bound_read_fbo.1.y;
|
||||
|
||||
self.gl.blit_framebuffer(
|
||||
src_x0,
|
||||
src_y0,
|
||||
src_x0 + src_rect.size.width,
|
||||
src_y0 + src_rect.size.height,
|
||||
dest_rect.origin.x,
|
||||
dest_rect.origin.y,
|
||||
dest_rect.origin.x + dest_rect.size.width,
|
||||
dest_rect.origin.y + dest_rect.size.height,
|
||||
src_x0 + src_rect.width(),
|
||||
src_y0 + src_rect.height(),
|
||||
dest_rect.min.x,
|
||||
dest_rect.min.y,
|
||||
dest_rect.max.x,
|
||||
dest_rect.max.y,
|
||||
gl::COLOR_BUFFER_BIT,
|
||||
filter,
|
||||
);
|
||||
|
@ -2769,8 +2771,8 @@ impl Device {
|
|||
debug_assert!(self.inside_frame);
|
||||
|
||||
let mut inverted_dest_rect = dest_rect;
|
||||
inverted_dest_rect.origin.y = dest_rect.max_y();
|
||||
inverted_dest_rect.size.height *= -1;
|
||||
inverted_dest_rect.min.y = dest_rect.max.y;
|
||||
inverted_dest_rect.max.y = dest_rect.min.y;
|
||||
|
||||
self.blit_render_target(
|
||||
src_target,
|
||||
|
@ -2976,7 +2978,7 @@ impl Device {
|
|||
format: ImageFormat,
|
||||
pbo: &PBO,
|
||||
) {
|
||||
let byte_size = rect.size.area() as usize * format.bytes_per_pixel() as usize;
|
||||
let byte_size = rect.area() as usize * format.bytes_per_pixel() as usize;
|
||||
|
||||
assert!(byte_size <= pbo.reserved_size);
|
||||
|
||||
|
@ -2989,10 +2991,10 @@ impl Device {
|
|||
|
||||
unsafe {
|
||||
self.gl.read_pixels_into_pbo(
|
||||
rect.origin.x as _,
|
||||
rect.origin.y as _,
|
||||
rect.size.width as _,
|
||||
rect.size.height as _,
|
||||
rect.min.x as _,
|
||||
rect.min.y as _,
|
||||
rect.width() as _,
|
||||
rect.height() as _,
|
||||
gl_format.read,
|
||||
gl_format.pixel_type,
|
||||
);
|
||||
|
@ -3114,15 +3116,15 @@ impl Device {
|
|||
) {
|
||||
let bytes_per_pixel = format.bytes_per_pixel();
|
||||
let desc = self.gl_describe_format(format);
|
||||
let size_in_bytes = (bytes_per_pixel * rect.size.width * rect.size.height) as usize;
|
||||
let size_in_bytes = (bytes_per_pixel * rect.area()) as usize;
|
||||
assert_eq!(output.len(), size_in_bytes);
|
||||
|
||||
self.gl.flush();
|
||||
self.gl.read_pixels_into_buffer(
|
||||
rect.origin.x as _,
|
||||
rect.origin.y as _,
|
||||
rect.size.width as _,
|
||||
rect.size.height as _,
|
||||
rect.min.x as _,
|
||||
rect.min.y as _,
|
||||
rect.width() as _,
|
||||
rect.height() as _,
|
||||
desc.read,
|
||||
desc.pixel_type,
|
||||
output,
|
||||
|
@ -3586,10 +3588,10 @@ impl Device {
|
|||
Some(rect) => {
|
||||
self.gl.enable(gl::SCISSOR_TEST);
|
||||
self.gl.scissor(
|
||||
rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.size.width,
|
||||
rect.size.height,
|
||||
rect.min.x,
|
||||
rect.min.y,
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
);
|
||||
self.gl.clear(clear_bits);
|
||||
self.gl.disable(gl::SCISSOR_TEST);
|
||||
|
@ -3626,10 +3628,10 @@ impl Device {
|
|||
|
||||
pub fn set_scissor_rect(&self, rect: FramebufferIntRect) {
|
||||
self.gl.scissor(
|
||||
rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.size.width,
|
||||
rect.size.height,
|
||||
rect.min.x,
|
||||
rect.min.y,
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4429,7 +4431,7 @@ impl<'a> TextureUploader<'a> {
|
|||
// Textures dimensions may have been clamped by the hardware. Crop the
|
||||
// upload region to match.
|
||||
let cropped = rect.intersection(
|
||||
&DeviceIntRect::new(DeviceIntPoint::zero(), texture.get_dimensions())
|
||||
&DeviceIntRect::from_size(texture.get_dimensions())
|
||||
);
|
||||
if cfg!(debug_assertions) && cropped.map_or(true, |r| r != rect) {
|
||||
warn!("Cropping texture upload {:?} to {:?}", rect, cropped);
|
||||
|
@ -4440,13 +4442,13 @@ impl<'a> TextureUploader<'a> {
|
|||
};
|
||||
|
||||
let bytes_pp = texture.format.bytes_per_pixel() as usize;
|
||||
let width_bytes = rect.size.width as usize * bytes_pp;
|
||||
let width_bytes = rect.width() as usize * bytes_pp;
|
||||
|
||||
let src_stride = stride.map_or(width_bytes, |stride| {
|
||||
assert!(stride >= 0);
|
||||
stride as usize
|
||||
});
|
||||
let src_size = (rect.size.height as usize - 1) * src_stride + width_bytes;
|
||||
let src_size = (rect.height() as usize - 1) * src_stride + width_bytes;
|
||||
assert!(src_size <= len * mem::size_of::<T>());
|
||||
|
||||
match device.upload_method {
|
||||
|
@ -4467,10 +4469,10 @@ impl<'a> TextureUploader<'a> {
|
|||
texture,
|
||||
});
|
||||
|
||||
width_bytes * rect.size.height as usize
|
||||
width_bytes * rect.height() as usize
|
||||
}
|
||||
UploadMethod::PixelBuffer(_) => {
|
||||
let mut staging_buffer = match self.stage(device, texture.format, rect.size) {
|
||||
let mut staging_buffer = match self.stage(device, texture.format, rect.size()) {
|
||||
Ok(staging_buffer) => staging_buffer,
|
||||
Err(_) => return 0,
|
||||
};
|
||||
|
@ -4486,7 +4488,7 @@ impl<'a> TextureUploader<'a> {
|
|||
} else {
|
||||
// copy the data line-by-line in to the buffer so
|
||||
// that it has an optimal stride
|
||||
for y in 0..rect.size.height as usize {
|
||||
for y in 0..rect.height() as usize {
|
||||
let src_start = y * src_stride;
|
||||
let src_end = src_start + width_bytes;
|
||||
let dst_start = y * staging_buffer.get_stride();
|
||||
|
@ -4556,8 +4558,8 @@ impl<'a> TextureUploader<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
let pos = chunk.rect.origin;
|
||||
let size = chunk.rect.size;
|
||||
let pos = chunk.rect.min;
|
||||
let size = chunk.rect.size();
|
||||
|
||||
match chunk.texture.target {
|
||||
gl::TEXTURE_2D | gl::TEXTURE_RECTANGLE | gl::TEXTURE_EXTERNAL_OES => {
|
||||
|
|
|
@ -557,8 +557,8 @@ impl FrameBuilder {
|
|||
// TODO(dp): Remove me completely!!
|
||||
let global_device_pixel_scale = DevicePixelScale::new(1.0);
|
||||
|
||||
let output_size = scene.output_rect.size;
|
||||
let screen_world_rect = (scene.output_rect.to_f32() / global_device_pixel_scale).round_out();
|
||||
let output_size = scene.output_rect.size();
|
||||
let screen_world_rect = (scene.output_rect.to_f32() / global_device_pixel_scale).round_out().to_rect();
|
||||
|
||||
let mut composite_state = CompositeState::new(
|
||||
scene.config.compositor_kind,
|
||||
|
@ -689,9 +689,9 @@ impl FrameBuilder {
|
|||
scene.clip_store.end_frame(&mut scratch.clip_store);
|
||||
|
||||
Frame {
|
||||
device_rect: DeviceIntRect::new(
|
||||
device_rect: DeviceIntRect::from_origin_and_size(
|
||||
device_origin,
|
||||
scene.output_rect.size,
|
||||
scene.output_rect.size(),
|
||||
),
|
||||
passes,
|
||||
transform_palette: transform_palette.finish(),
|
||||
|
@ -732,7 +732,7 @@ impl FrameBuilder {
|
|||
let world_clip_rect = map_local_to_world
|
||||
.map(&tile_cache.local_clip_rect)
|
||||
.expect("bug: unable to map clip rect");
|
||||
let device_clip_rect = (world_clip_rect * ctx.global_device_pixel_scale).round();
|
||||
let device_clip_rect = (world_clip_rect * ctx.global_device_pixel_scale).round().to_box2d();
|
||||
|
||||
composite_state.push_surface(
|
||||
tile_cache,
|
||||
|
|
|
@ -52,8 +52,7 @@ pub fn resolve_image(
|
|||
let cache_item = CacheItem {
|
||||
texture_id: TextureSource::External(deferred_resolve_index, image_buffer_kind),
|
||||
uv_rect_handle: cache_handle,
|
||||
uv_rect: DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
uv_rect: DeviceIntRect::from_size(
|
||||
image_properties.descriptor.size,
|
||||
),
|
||||
user_data: [0.0; 4],
|
||||
|
|
|
@ -305,8 +305,8 @@ pub fn tiles(
|
|||
|
||||
// Size of regular tiles in layout space.
|
||||
let layout_tile_size = LayoutSize::new(
|
||||
device_tile_size as f32 / image_rect.size.width as f32 * prim_rect.size.width,
|
||||
device_tile_size as f32 / image_rect.size.height as f32 * prim_rect.size.height,
|
||||
device_tile_size as f32 / image_rect.width() as f32 * prim_rect.width(),
|
||||
device_tile_size as f32 / image_rect.height() as f32 * prim_rect.height(),
|
||||
);
|
||||
|
||||
// The decomposition logic is exactly the same on each axis so we reduce
|
||||
|
@ -503,16 +503,16 @@ pub fn compute_tile_rect(
|
|||
tile: TileOffset,
|
||||
) -> DeviceIntRect {
|
||||
let regular_tile_size = regular_tile_size as i32;
|
||||
DeviceIntRect {
|
||||
origin: point2(
|
||||
DeviceIntRect::from_origin_and_size(
|
||||
point2(
|
||||
compute_tile_origin_1d(image_rect.x_range(), regular_tile_size, tile.x as i32),
|
||||
compute_tile_origin_1d(image_rect.y_range(), regular_tile_size, tile.y as i32),
|
||||
),
|
||||
size: size2(
|
||||
size2(
|
||||
compute_tile_size_1d(image_rect.x_range(), regular_tile_size, tile.x as i32),
|
||||
compute_tile_size_1d(image_rect.y_range(), regular_tile_size, tile.y as i32),
|
||||
),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn compute_tile_origin_1d(
|
||||
|
@ -600,10 +600,10 @@ pub fn compute_valid_tiles_if_bounds_change(
|
|||
}
|
||||
};
|
||||
|
||||
let left = prev_rect.min_x() != new_rect.min_x();
|
||||
let right = prev_rect.max_x() != new_rect.max_x();
|
||||
let top = prev_rect.min_y() != new_rect.min_y();
|
||||
let bottom = prev_rect.max_y() != new_rect.max_y();
|
||||
let left = prev_rect.min.x != new_rect.min.x;
|
||||
let right = prev_rect.max.x != new_rect.max.x;
|
||||
let top = prev_rect.min.y != new_rect.min.y;
|
||||
let bottom = prev_rect.max.y != new_rect.max.y;
|
||||
|
||||
if !left && !right && !top && !bottom {
|
||||
// Bounds have not changed.
|
||||
|
@ -617,10 +617,10 @@ pub fn compute_valid_tiles_if_bounds_change(
|
|||
.cast::<f32>()
|
||||
.scale(tw, th);
|
||||
|
||||
let min_x = if left { f32::ceil(tiles.min_x()) } else { f32::floor(tiles.min_x()) };
|
||||
let min_y = if top { f32::ceil(tiles.min_y()) } else { f32::floor(tiles.min_y()) };
|
||||
let max_x = if right { f32::floor(tiles.max_x()) } else { f32::ceil(tiles.max_x()) };
|
||||
let max_y = if bottom { f32::floor(tiles.max_y()) } else { f32::ceil(tiles.max_y()) };
|
||||
let min_x = if left { f32::ceil(tiles.min.x) } else { f32::floor(tiles.min.x) };
|
||||
let min_y = if top { f32::ceil(tiles.min.y) } else { f32::floor(tiles.min.y) };
|
||||
let max_x = if right { f32::floor(tiles.max.x) } else { f32::ceil(tiles.max.x) };
|
||||
let max_y = if bottom { f32::floor(tiles.max.y) } else { f32::ceil(tiles.max.y) };
|
||||
|
||||
Some(TileRange {
|
||||
origin: point2(min_x as i32, min_y as i32),
|
||||
|
@ -666,7 +666,7 @@ mod tests {
|
|||
let mut count = 0;
|
||||
checked_for_each_tile(&rect(0., 0., 1000., 1000.),
|
||||
&rect(75., 75., 400., 400.),
|
||||
&rect(0, 0, 400, 400),
|
||||
&rect(0, 0, 400, 400).to_box2d(),
|
||||
36,
|
||||
&mut |_tile_rect, _tile_offset, _tile_flags| {
|
||||
count += 1;
|
||||
|
@ -680,7 +680,7 @@ mod tests {
|
|||
let mut count = 0;
|
||||
checked_for_each_tile(&rect(0., 0., 74., 74.),
|
||||
&rect(75., 75., 400., 400.),
|
||||
&rect(0, 0, 400, 400),
|
||||
&rect(0, 0, 400, 400).to_box2d(),
|
||||
36,
|
||||
&mut |_tile_rect, _tile_offset, _tile_flags| {
|
||||
count += 1;
|
||||
|
@ -795,22 +795,22 @@ mod tests {
|
|||
#[test]
|
||||
fn smaller_than_tile_size_at_origin() {
|
||||
let r = compute_tile_rect(
|
||||
&rect(0, 0, 80, 80),
|
||||
&rect(0, 0, 80, 80).to_box2d(),
|
||||
256,
|
||||
point2(0, 0),
|
||||
);
|
||||
|
||||
assert_eq!(r, rect(0, 0, 80, 80));
|
||||
assert_eq!(r, rect(0, 0, 80, 80).to_box2d());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smaller_than_tile_size_with_offset() {
|
||||
let r = compute_tile_rect(
|
||||
&rect(20, 20, 80, 80),
|
||||
&rect(20, 20, 80, 80).to_box2d(),
|
||||
256,
|
||||
point2(0, 0),
|
||||
);
|
||||
|
||||
assert_eq!(r, rect(20, 20, 80, 80));
|
||||
assert_eq!(r, rect(20, 20, 80, 80).to_box2d());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,7 +405,7 @@ impl TextureUpdateList {
|
|||
height: i32,
|
||||
) {
|
||||
let size = DeviceIntSize::new(width, height);
|
||||
let rect = DeviceIntRect::new(origin, size);
|
||||
let rect = DeviceIntRect::from_origin_and_size(origin, size);
|
||||
self.push_update(id, TextureCacheUpdate {
|
||||
rect,
|
||||
stride: None,
|
||||
|
|
|
@ -1237,8 +1237,9 @@ impl Tile {
|
|||
// is just to deal with float accuracy. However, the valid rect is not
|
||||
// always aligned to a device pixel. To handle this, round out to get all
|
||||
// required pixels, and intersect with the tile device rect.
|
||||
let device_rect = (self.world_tile_rect * ctx.global_device_pixel_scale).round();
|
||||
let device_rect = (self.world_tile_rect * ctx.global_device_pixel_scale).round().to_box2d();
|
||||
self.device_valid_rect = (self.world_valid_rect * ctx.global_device_pixel_scale)
|
||||
.to_box2d()
|
||||
.round_out()
|
||||
.intersection(&device_rect)
|
||||
.unwrap_or_else(DeviceRect::zero);
|
||||
|
@ -3132,7 +3133,7 @@ impl TileCacheInstance {
|
|||
let world_rect = pic_to_world_mapper
|
||||
.map(&prim_rect)
|
||||
.expect("bug: unable to map the primitive to world space");
|
||||
let device_rect = (world_rect * frame_context.global_device_pixel_scale).round();
|
||||
let device_rect = (world_rect * frame_context.global_device_pixel_scale).round().to_box2d();
|
||||
|
||||
// TODO(gw): Is there any case where if the primitive ends up on a fractional
|
||||
// boundary we want to _skip_ promoting to a compositor surface and
|
||||
|
@ -3155,14 +3156,14 @@ impl TileCacheInstance {
|
|||
let world_to_device_scale = Transform3D::from_scale(frame_context.global_device_pixel_scale);
|
||||
let transform = surface_to_world_mapper.get_transform().pre_translate(prim_origin).then(&world_to_device_scale);
|
||||
|
||||
(local_prim_rect.cast_unit(), transform)
|
||||
(local_prim_rect.to_box2d().cast_unit(), transform)
|
||||
}
|
||||
};
|
||||
|
||||
let clip_rect = (world_clip_rect * frame_context.global_device_pixel_scale).round();
|
||||
let clip_rect = (world_clip_rect * frame_context.global_device_pixel_scale).round().to_box2d();
|
||||
|
||||
if surface_rect.size.width >= MAX_COMPOSITOR_SURFACES_SIZE ||
|
||||
surface_rect.size.height >= MAX_COMPOSITOR_SURFACES_SIZE {
|
||||
if surface_rect.width() >= MAX_COMPOSITOR_SURFACES_SIZE ||
|
||||
surface_rect.height() >= MAX_COMPOSITOR_SURFACES_SIZE {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3186,7 +3187,7 @@ impl TileCacheInstance {
|
|||
(None, None)
|
||||
}
|
||||
CompositorKind::Native { .. } => {
|
||||
let native_surface_size = surface_rect.size.round().to_i32();
|
||||
let native_surface_size = surface_rect.size().round().to_i32();
|
||||
|
||||
let key = ExternalNativeSurfaceKey {
|
||||
image_keys: *api_keys,
|
||||
|
@ -4869,7 +4870,7 @@ impl PicturePrimitive {
|
|||
.map(&tile_cache.local_clip_rect)
|
||||
.expect("bug: unable to map clip rect")
|
||||
.round();
|
||||
let device_clip_rect = (world_clip_rect * frame_context.global_device_pixel_scale).round();
|
||||
let device_clip_rect = (world_clip_rect * frame_context.global_device_pixel_scale).round().to_box2d();
|
||||
|
||||
for (sub_slice_index, sub_slice) in tile_cache.sub_slices.iter_mut().enumerate() {
|
||||
for tile in sub_slice.tiles.values_mut() {
|
||||
|
@ -4957,7 +4958,7 @@ impl PicturePrimitive {
|
|||
30.0 + sub_slice_index as f32 * 20.0,
|
||||
);
|
||||
let tile_device_rect = tile.world_tile_rect * frame_context.global_device_pixel_scale;
|
||||
if tile_device_rect.size.height >= label_offset.y {
|
||||
if tile_device_rect.height() >= label_offset.y {
|
||||
let surface = tile.surface.as_ref().expect("no tile surface set!");
|
||||
|
||||
scratch.push_debug_string(
|
||||
|
@ -5011,8 +5012,9 @@ impl PicturePrimitive {
|
|||
// Update the world/device dirty rect
|
||||
let world_dirty_rect = map_pic_to_world.map(&tile.local_dirty_rect).expect("bug");
|
||||
|
||||
let device_rect = (tile.world_tile_rect * frame_context.global_device_pixel_scale).round();
|
||||
let device_rect = (tile.world_tile_rect * frame_context.global_device_pixel_scale).round().to_box2d();
|
||||
tile.device_dirty_rect = (world_dirty_rect * frame_context.global_device_pixel_scale)
|
||||
.to_box2d()
|
||||
.round_out()
|
||||
.intersection(&device_rect)
|
||||
.unwrap_or_else(DeviceRect::zero);
|
||||
|
@ -5105,12 +5107,12 @@ impl PicturePrimitive {
|
|||
);
|
||||
|
||||
let scissor_rect = tile.device_dirty_rect
|
||||
.translate(-device_rect.origin.to_vector())
|
||||
.translate(-device_rect.min.to_vector())
|
||||
.round()
|
||||
.to_i32();
|
||||
|
||||
let valid_rect = tile.device_valid_rect
|
||||
.translate(-device_rect.origin.to_vector())
|
||||
.translate(-device_rect.min.to_vector())
|
||||
.round()
|
||||
.to_i32();
|
||||
|
||||
|
@ -5158,7 +5160,7 @@ impl PicturePrimitive {
|
|||
|
||||
// If the entire tile valid region is dirty, we can update the fract offset
|
||||
// at which the tile was rendered.
|
||||
if tile.device_dirty_rect.contains_rect(&tile.device_valid_rect) {
|
||||
if tile.device_dirty_rect.contains_box(&tile.device_valid_rect) {
|
||||
tile.device_fract_offset = tile_cache.device_fract_offset;
|
||||
}
|
||||
}
|
||||
|
@ -5197,8 +5199,8 @@ impl PicturePrimitive {
|
|||
kind: tile_kind(&surface, is_opaque),
|
||||
surface,
|
||||
rect: device_rect,
|
||||
valid_rect: tile.device_valid_rect.translate(-device_rect.origin.to_vector()),
|
||||
dirty_rect: tile.device_dirty_rect.translate(-device_rect.origin.to_vector()),
|
||||
valid_rect: tile.device_valid_rect.translate(-device_rect.min.to_vector()),
|
||||
dirty_rect: tile.device_dirty_rect.translate(-device_rect.min.to_vector()),
|
||||
clip_rect: device_clip_rect,
|
||||
transform: None,
|
||||
z_id: tile.z_id,
|
||||
|
@ -5325,11 +5327,11 @@ impl PicturePrimitive {
|
|||
} else {
|
||||
max_target_size as f32
|
||||
};
|
||||
if device_rect.size.width > limit || device_rect.size.height > limit {
|
||||
if device_rect.width() > limit || device_rect.height() > limit {
|
||||
// round_out will grow by 1 integer pixel if origin is on a
|
||||
// fractional position, so keep that margin for error with -1:
|
||||
let scale = (limit as f32 - 1.0) /
|
||||
(f32::max(device_rect.size.width, device_rect.size.height));
|
||||
(f32::max(device_rect.width(), device_rect.height()));
|
||||
*device_pixel_scale = *device_pixel_scale * Scale::new(scale);
|
||||
let new_device_rect = device_rect.to_f32() * Scale::new(scale);
|
||||
*device_rect = new_device_rect.round_out();
|
||||
|
@ -5386,15 +5388,16 @@ impl PicturePrimitive {
|
|||
clipped
|
||||
};
|
||||
|
||||
let mut original_size = device_rect.size;
|
||||
let mut original_size = device_rect.size();
|
||||
|
||||
// Adjust the size to avoid introducing sampling errors during the down-scaling passes.
|
||||
// what would be even better is to rasterize the picture at the down-scaled size
|
||||
// directly.
|
||||
device_rect.size = BlurTask::adjusted_blur_source_size(
|
||||
device_rect.size,
|
||||
let adjusted_size = BlurTask::adjusted_blur_source_size(
|
||||
device_rect.size(),
|
||||
blur_std_deviation,
|
||||
);
|
||||
device_rect.set_size(adjusted_size);
|
||||
|
||||
if let Some(scale) = adjust_scale_for_max_surface_size(
|
||||
raster_config, frame_context.fb_config.max_target_size,
|
||||
|
@ -5414,16 +5417,16 @@ impl PicturePrimitive {
|
|||
device_pixel_scale,
|
||||
);
|
||||
|
||||
let task_size = device_rect.size.to_i32();
|
||||
let task_size = device_rect.size().to_i32();
|
||||
|
||||
let picture_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
device_rect.origin,
|
||||
device_rect.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5467,13 +5470,14 @@ impl PicturePrimitive {
|
|||
.intersection(&unclipped)
|
||||
.unwrap();
|
||||
|
||||
device_rect.size = BlurTask::adjusted_blur_source_size(
|
||||
device_rect.size,
|
||||
let adjusted_size = BlurTask::adjusted_blur_source_size(
|
||||
device_rect.size(),
|
||||
DeviceSize::new(
|
||||
max_std_deviation * scale_factors.0,
|
||||
max_std_deviation * scale_factors.1
|
||||
),
|
||||
);
|
||||
device_rect.set_size(adjusted_size);
|
||||
|
||||
if let Some(scale) = adjust_scale_for_max_surface_size(
|
||||
raster_config, frame_context.fb_config.max_target_size,
|
||||
|
@ -5492,16 +5496,16 @@ impl PicturePrimitive {
|
|||
device_pixel_scale,
|
||||
);
|
||||
|
||||
let task_size = device_rect.size.to_i32();
|
||||
let task_size = device_rect.size().to_i32();
|
||||
|
||||
let picture_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
device_rect.origin,
|
||||
device_rect.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5534,7 +5538,7 @@ impl PicturePrimitive {
|
|||
frame_state.rg_builder,
|
||||
RenderTargetKind::Color,
|
||||
Some(&mut blur_tasks),
|
||||
device_rect.size.to_i32(),
|
||||
device_rect.size().to_i32(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -5621,8 +5625,8 @@ impl PicturePrimitive {
|
|||
|
||||
frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
available_rect.size.to_i32(),
|
||||
RenderTaskKind::new_readback(Some(available_rect.origin)),
|
||||
available_rect.size().to_i32(),
|
||||
RenderTaskKind::new_readback(Some(available_rect.min)),
|
||||
).with_uv_rect_kind(backdrop_uv)
|
||||
)
|
||||
}
|
||||
|
@ -5643,16 +5647,16 @@ impl PicturePrimitive {
|
|||
|
||||
self.secondary_render_task_id = Some(readback_task_id);
|
||||
|
||||
let task_size = clipped.size.to_i32();
|
||||
let task_size = clipped.size().to_i32();
|
||||
|
||||
let render_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
clipped.origin,
|
||||
clipped.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5689,16 +5693,16 @@ impl PicturePrimitive {
|
|||
device_pixel_scale,
|
||||
);
|
||||
|
||||
let task_size = clipped.size.to_i32();
|
||||
let task_size = clipped.size().to_i32();
|
||||
|
||||
let render_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
clipped.origin,
|
||||
clipped.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5734,16 +5738,16 @@ impl PicturePrimitive {
|
|||
device_pixel_scale,
|
||||
);
|
||||
|
||||
let task_size = clipped.size.to_i32();
|
||||
let task_size = clipped.size().to_i32();
|
||||
|
||||
let render_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
clipped.origin,
|
||||
clipped.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5780,16 +5784,16 @@ impl PicturePrimitive {
|
|||
device_pixel_scale,
|
||||
);
|
||||
|
||||
let task_size = clipped.size.to_i32();
|
||||
let task_size = clipped.size().to_i32();
|
||||
|
||||
let render_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
clipped.origin,
|
||||
clipped.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5826,16 +5830,16 @@ impl PicturePrimitive {
|
|||
device_pixel_scale,
|
||||
);
|
||||
|
||||
let task_size = clipped.size.to_i32();
|
||||
let task_size = clipped.size().to_i32();
|
||||
|
||||
let picture_task_id = frame_state.rg_builder.add().init(
|
||||
RenderTask::new_dynamic(
|
||||
task_size,
|
||||
RenderTaskKind::new_picture(
|
||||
task_size,
|
||||
unclipped.size,
|
||||
unclipped.size(),
|
||||
pic_index,
|
||||
clipped.origin,
|
||||
clipped.min,
|
||||
surface_spatial_node_index,
|
||||
device_pixel_scale,
|
||||
None,
|
||||
|
@ -5849,7 +5853,7 @@ impl PicturePrimitive {
|
|||
primitives,
|
||||
filter_datas,
|
||||
frame_state.rg_builder,
|
||||
clipped.size.to_i32(),
|
||||
clipped.size().to_i32(),
|
||||
uv_rect_kind,
|
||||
picture_task_id,
|
||||
device_pixel_scale,
|
||||
|
@ -6569,8 +6573,8 @@ fn calculate_screen_uv(
|
|||
let raster_pos = transform.transform_point2d_homogeneous(*local_pos);
|
||||
|
||||
DeviceHomogeneousVector::new(
|
||||
(raster_pos.x * device_pixel_scale.0 - rendered_rect.origin.x * raster_pos.w) / rendered_rect.size.width,
|
||||
(raster_pos.y * device_pixel_scale.0 - rendered_rect.origin.y * raster_pos.w) / rendered_rect.size.height,
|
||||
(raster_pos.x * device_pixel_scale.0 - rendered_rect.min.x * raster_pos.w) / rendered_rect.width(),
|
||||
(raster_pos.y * device_pixel_scale.0 - rendered_rect.min.y * raster_pos.w) / rendered_rect.height(),
|
||||
0.0,
|
||||
raster_pos.w,
|
||||
)
|
||||
|
@ -6585,7 +6589,7 @@ fn calculate_uv_rect_kind(
|
|||
device_pixel_scale: DevicePixelScale,
|
||||
) -> UvRectKind {
|
||||
let top_left = calculate_screen_uv(
|
||||
&pic_rect.origin,
|
||||
&pic_rect.top_left(),
|
||||
transform,
|
||||
&rendered_rect,
|
||||
device_pixel_scale,
|
||||
|
@ -6983,7 +6987,7 @@ impl TileNode {
|
|||
let world_rect = pic_to_world_mapper
|
||||
.map(&local_rect)
|
||||
.unwrap();
|
||||
let device_rect = world_rect * global_device_pixel_scale;
|
||||
let device_rect = (world_rect * global_device_pixel_scale).to_box2d();
|
||||
|
||||
let outer_color = color.scale_alpha(0.3);
|
||||
let inner_color = outer_color.scale_alpha(0.5);
|
||||
|
|
|
@ -1546,7 +1546,7 @@ fn get_unclipped_device_rect(
|
|||
) -> Option<DeviceRect> {
|
||||
let raster_rect = map_to_raster.map(&prim_rect)?;
|
||||
let world_rect = raster_rect * Scale::new(1.0);
|
||||
Some(world_rect * device_pixel_scale)
|
||||
Some((world_rect * device_pixel_scale).to_box2d())
|
||||
}
|
||||
|
||||
/// Given an unclipped device rect, try to find a minimal device space
|
||||
|
@ -1561,7 +1561,7 @@ fn get_clipped_device_rect(
|
|||
device_pixel_scale: DevicePixelScale,
|
||||
) -> Option<DeviceRect> {
|
||||
let unclipped_raster_rect = {
|
||||
let world_rect = *unclipped * Scale::new(1.0);
|
||||
let world_rect = unclipped.to_rect() * Scale::new(1.0);
|
||||
let raster_rect = world_rect * device_pixel_scale.inverse();
|
||||
|
||||
raster_rect.cast_unit()
|
||||
|
|
|
@ -318,7 +318,7 @@ impl Transaction {
|
|||
&mut self,
|
||||
device_rect: DeviceIntRect,
|
||||
) {
|
||||
window_size_sanity_check(device_rect.size);
|
||||
window_size_sanity_check(device_rect.size());
|
||||
self.scene_ops.push(
|
||||
SceneMsg::SetDocumentView {
|
||||
device_rect,
|
||||
|
|
|
@ -486,7 +486,7 @@ impl Document {
|
|||
}
|
||||
|
||||
fn has_pixels(&self) -> bool {
|
||||
!self.view.scene.device_rect.size.is_empty()
|
||||
!self.view.scene.device_rect.is_empty()
|
||||
}
|
||||
|
||||
fn process_frame_msg(
|
||||
|
@ -576,7 +576,7 @@ impl Document {
|
|||
gpu_cache,
|
||||
&mut self.rg_builder,
|
||||
self.stamp,
|
||||
self.view.scene.device_rect.origin,
|
||||
self.view.scene.device_rect.min,
|
||||
&self.dynamic_properties,
|
||||
&mut self.data_stores,
|
||||
&mut self.scratch,
|
||||
|
|
|
@ -543,8 +543,8 @@ impl RenderTarget for AlphaRenderTarget {
|
|||
&ctx.screen_world_rect,
|
||||
task_info.device_pixel_scale,
|
||||
ctx.global_device_pixel_scale,
|
||||
target_rect.origin.to_f32(),
|
||||
task_info.actual_rect.origin,
|
||||
target_rect.min.to_f32(),
|
||||
task_info.actual_rect.min,
|
||||
);
|
||||
if task_info.clear_to_one || clear_to_one {
|
||||
self.one_clears.push(task_id);
|
||||
|
@ -554,15 +554,14 @@ impl RenderTarget for AlphaRenderTarget {
|
|||
if region_task.clear_to_one {
|
||||
self.one_clears.push(task_id);
|
||||
}
|
||||
let device_rect = DeviceRect::new(
|
||||
DevicePoint::zero(),
|
||||
target_rect.size.to_f32(),
|
||||
let device_rect = DeviceRect::from_size(
|
||||
target_rect.size().to_f32(),
|
||||
);
|
||||
self.clip_batcher.add_clip_region(
|
||||
region_task.local_pos,
|
||||
device_rect,
|
||||
region_task.clip_data.clone(),
|
||||
target_rect.origin.to_f32(),
|
||||
target_rect.min.to_f32(),
|
||||
DevicePoint::zero(),
|
||||
region_task.device_pixel_scale.0,
|
||||
);
|
||||
|
@ -675,7 +674,7 @@ impl TextureCacheRenderTarget {
|
|||
RenderTaskKind::Border(ref task_info) => {
|
||||
self.clears.push(target_rect);
|
||||
|
||||
let task_origin = target_rect.origin.to_f32();
|
||||
let task_origin = target_rect.min.to_f32();
|
||||
// TODO(gw): Clone here instead of a move of this vec, since the frame
|
||||
// graph is immutable by this point. It's rare that borders
|
||||
// are drawn since they are persisted in the texture cache,
|
||||
|
@ -750,7 +749,7 @@ fn add_scaling_instances(
|
|||
) {
|
||||
let target_rect = target_task
|
||||
.get_target_rect()
|
||||
.inner_rect(task.padding)
|
||||
.inner_box(task.padding)
|
||||
.to_f32();
|
||||
|
||||
let source = source_task.unwrap().get_texture_source();
|
||||
|
|
|
@ -128,8 +128,8 @@ impl RenderTaskLocation {
|
|||
pub fn size(&self) -> DeviceIntSize {
|
||||
match self {
|
||||
RenderTaskLocation::Unallocated { size } => *size,
|
||||
RenderTaskLocation::Dynamic { rect, .. } => rect.size,
|
||||
RenderTaskLocation::Static { rect, .. } => rect.size,
|
||||
RenderTaskLocation::Dynamic { rect, .. } => rect.size(),
|
||||
RenderTaskLocation::Static { rect, .. } => rect.size(),
|
||||
RenderTaskLocation::CacheRequest { size } => *size,
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ impl RenderTaskKind {
|
|||
// TODO(gw): If this ever shows up in a profile, we could pre-calculate
|
||||
// whether a ClipSources contains any box-shadows and skip
|
||||
// this iteration for the majority of cases.
|
||||
let task_size = outer_rect.size.to_i32();
|
||||
let task_size = outer_rect.size().to_i32();
|
||||
|
||||
// If we have a potentially tiled clip mask, clear the mask area first. Otherwise,
|
||||
// the first (primary) clip mask will overwrite all the clip mask pixels with
|
||||
|
@ -584,8 +584,8 @@ impl RenderTaskKind {
|
|||
RenderTaskKind::CacheMask(ref task) => {
|
||||
[
|
||||
task.device_pixel_scale.0,
|
||||
task.actual_rect.origin.x,
|
||||
task.actual_rect.origin.y,
|
||||
task.actual_rect.min.x,
|
||||
task.actual_rect.min.y,
|
||||
0.0,
|
||||
]
|
||||
}
|
||||
|
@ -637,10 +637,10 @@ impl RenderTaskKind {
|
|||
|
||||
RenderTaskData {
|
||||
data: [
|
||||
target_rect.origin.x as f32,
|
||||
target_rect.origin.y as f32,
|
||||
target_rect.size.width as f32,
|
||||
target_rect.size.height as f32,
|
||||
target_rect.min.x as f32,
|
||||
target_rect.min.y as f32,
|
||||
target_rect.width() as f32,
|
||||
target_rect.height() as f32,
|
||||
data[0],
|
||||
data[1],
|
||||
data[2],
|
||||
|
@ -1409,8 +1409,8 @@ impl RenderTask {
|
|||
}
|
||||
|
||||
if let Some(mut request) = gpu_cache.request(&mut self.uv_rect_handle) {
|
||||
let p0 = target_rect.min().to_f32();
|
||||
let p1 = target_rect.max().to_f32();
|
||||
let p0 = target_rect.min.to_f32();
|
||||
let p1 = target_rect.max.to_f32();
|
||||
let image_source = ImageSource {
|
||||
p0,
|
||||
p1,
|
||||
|
|
|
@ -444,7 +444,7 @@ impl RenderTaskGraphBuilder {
|
|||
let surface = self.active_surfaces.get_mut(&texture_id).unwrap();
|
||||
if let Some(p) = surface.alloc_rect(size, kind, true) {
|
||||
location = Some((texture_id, p));
|
||||
*used_rect = used_rect.union(&DeviceIntRect::new(p, size));
|
||||
*used_rect = used_rect.union(&DeviceIntRect::from_origin_and_size(p, size));
|
||||
sub_pass.task_ids.push(*task_id);
|
||||
break;
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ impl RenderTaskGraphBuilder {
|
|||
surface: SubPassSurface::Dynamic {
|
||||
texture_id,
|
||||
target_kind: kind,
|
||||
used_rect: DeviceIntRect::new(p, size),
|
||||
used_rect: DeviceIntRect::from_origin_and_size(p, size),
|
||||
},
|
||||
task_ids: vec![*task_id],
|
||||
});
|
||||
|
@ -530,7 +530,7 @@ impl RenderTaskGraphBuilder {
|
|||
assert!(location.is_some());
|
||||
task.location = RenderTaskLocation::Dynamic {
|
||||
texture_id: location.unwrap().0,
|
||||
rect: DeviceIntRect::new(location.unwrap().1, size),
|
||||
rect: DeviceIntRect::from_origin_and_size(location.unwrap().1, size),
|
||||
};
|
||||
}
|
||||
RenderTaskLocation::Static { ref surface, .. } => {
|
||||
|
|
|
@ -201,11 +201,11 @@ impl DebugRenderer {
|
|||
|
||||
// If either corner of the glyph will end up out of bounds, drop it.
|
||||
if let Some(b) = bounds {
|
||||
let rect = DeviceRect::new(
|
||||
DevicePoint::new(x0, y0),
|
||||
DeviceSize::new(x1 - x0, y1 - y0),
|
||||
);
|
||||
if !b.contains_rect(&rect) {
|
||||
let rect = DeviceRect {
|
||||
min: DevicePoint::new(x0, y0),
|
||||
max: DevicePoint::new(x1, y1),
|
||||
};
|
||||
if !b.contains_box(&rect) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -286,8 +286,8 @@ impl DebugRenderer {
|
|||
|
||||
|
||||
pub fn add_rect(&mut self, rect: &DeviceIntRect, color: ColorU) {
|
||||
let p0 = rect.origin;
|
||||
let p1 = p0 + rect.size;
|
||||
let p0 = rect.min;
|
||||
let p1 = rect.max;
|
||||
self.add_line(p0.x, p0.y, color, p1.x, p0.y, color);
|
||||
self.add_line(p1.x, p0.y, color, p1.x, p1.y, color);
|
||||
self.add_line(p1.x, p1.y, color, p0.x, p1.y, color);
|
||||
|
|
|
@ -342,7 +342,7 @@ impl GpuCacheTexture {
|
|||
}
|
||||
|
||||
let blocks = row.dirty_blocks();
|
||||
let rect = DeviceIntRect::new(
|
||||
let rect = DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(row.min_dirty as i32, row_index as i32),
|
||||
DeviceIntSize::new(blocks.len() as i32, 1),
|
||||
);
|
||||
|
|
|
@ -1744,22 +1744,13 @@ impl Renderer {
|
|||
// Ensure old surface is invalidated before binding
|
||||
compositor.invalidate_tile(
|
||||
NativeTileId::DEBUG_OVERLAY,
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
surface_size,
|
||||
),
|
||||
DeviceIntRect::from_size(surface_size),
|
||||
);
|
||||
// Bind the native surface
|
||||
let surface_info = compositor.bind(
|
||||
NativeTileId::DEBUG_OVERLAY,
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
surface_size,
|
||||
),
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
surface_size,
|
||||
),
|
||||
DeviceIntRect::from_size(surface_size),
|
||||
DeviceIntRect::from_size(surface_size),
|
||||
);
|
||||
|
||||
// Bind the native surface to current FBO target
|
||||
|
@ -1801,8 +1792,7 @@ impl Renderer {
|
|||
compositor.add_surface(
|
||||
NativeSurfaceId::DEBUG_OVERLAY,
|
||||
CompositorSurfaceTransform::identity(),
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
DeviceIntRect::from_size(
|
||||
self.debug_overlay_state.current_size.unwrap(),
|
||||
),
|
||||
ImageRendering::Auto,
|
||||
|
@ -2389,38 +2379,38 @@ impl Renderer {
|
|||
);
|
||||
|
||||
// Get the rect that we ideally want, in space of the parent surface
|
||||
let wanted_rect = DeviceRect::new(
|
||||
let wanted_rect = DeviceRect::from_origin_and_size(
|
||||
readback_origin,
|
||||
readback_rect.size.to_f32(),
|
||||
readback_rect.size().to_f32(),
|
||||
);
|
||||
|
||||
// Get the rect that is available on the parent surface. It may be smaller
|
||||
// than desired because this is a picture cache tile covering only part of
|
||||
// the wanted rect and/or because the parent surface was clipped.
|
||||
let avail_rect = DeviceRect::new(
|
||||
let avail_rect = DeviceRect::from_origin_and_size(
|
||||
backdrop_screen_origin,
|
||||
backdrop_rect.size.to_f32(),
|
||||
backdrop_rect.size().to_f32(),
|
||||
);
|
||||
|
||||
if let Some(int_rect) = wanted_rect.intersection(&avail_rect) {
|
||||
// If there is a valid intersection, work out the correct origins and
|
||||
// sizes of the copy rects, and do the blit.
|
||||
let copy_size = int_rect.size.to_i32();
|
||||
let copy_size = int_rect.size().to_i32();
|
||||
|
||||
let src_origin = backdrop_rect.origin.to_f32() +
|
||||
int_rect.origin.to_vector() -
|
||||
let src_origin = backdrop_rect.min.to_f32() +
|
||||
int_rect.min.to_vector() -
|
||||
backdrop_screen_origin.to_vector();
|
||||
|
||||
let src = DeviceIntRect::new(
|
||||
let src = DeviceIntRect::from_origin_and_size(
|
||||
src_origin.to_i32(),
|
||||
copy_size,
|
||||
);
|
||||
|
||||
let dest_origin = readback_rect.origin.to_f32() +
|
||||
int_rect.origin.to_vector() -
|
||||
let dest_origin = readback_rect.min.to_f32() +
|
||||
int_rect.min.to_vector() -
|
||||
readback_origin.to_vector();
|
||||
|
||||
let dest = DeviceIntRect::new(
|
||||
let dest = DeviceIntRect::from_origin_and_size(
|
||||
dest_origin.to_i32(),
|
||||
copy_size,
|
||||
);
|
||||
|
@ -2474,7 +2464,7 @@ impl Renderer {
|
|||
(source_texture, source_rect)
|
||||
};
|
||||
|
||||
debug_assert_eq!(source_rect.size, blit.target_rect.size);
|
||||
debug_assert_eq!(source_rect.size(), blit.target_rect.size());
|
||||
let (texture, swizzle) = self.texture_resolver
|
||||
.resolve(&source)
|
||||
.expect("BUG: invalid source texture");
|
||||
|
@ -2598,8 +2588,8 @@ impl Renderer {
|
|||
}
|
||||
let instance = ClearInstance {
|
||||
rect: [
|
||||
r.origin.x as f32, r.origin.y as f32,
|
||||
r.size.width as f32, r.size.height as f32,
|
||||
r.min.x as f32, r.min.y as f32,
|
||||
r.width() as f32, r.height() as f32,
|
||||
],
|
||||
color: clear_color.unwrap_or([0.0; 4]),
|
||||
};
|
||||
|
@ -3051,7 +3041,7 @@ impl Renderer {
|
|||
for item in tiles_iter {
|
||||
let tile = &composite_state.tiles[item.key];
|
||||
|
||||
let clip_rect = item.rectangle.to_rect();
|
||||
let clip_rect = item.rectangle;
|
||||
|
||||
// Work out the draw params based on the tile surface
|
||||
let (instance, textures, shader_params) = match tile.surface {
|
||||
|
@ -3270,17 +3260,17 @@ impl Renderer {
|
|||
// Determine a clip rect to apply to this tile, depending on what
|
||||
// the partial present mode is.
|
||||
let partial_clip_rect = match partial_present_mode {
|
||||
Some(PartialPresentMode::Single { dirty_rect }) => dirty_rect.to_box2d(),
|
||||
None => tile.rect.to_box2d(),
|
||||
Some(PartialPresentMode::Single { dirty_rect }) => dirty_rect,
|
||||
None => tile.rect,
|
||||
};
|
||||
|
||||
// Simple compositor needs the valid rect in device space to match clip rect
|
||||
let valid_device_rect = tile.valid_rect.translate(
|
||||
tile.rect.origin.to_vector()
|
||||
).to_box2d();
|
||||
tile.rect.min.to_vector()
|
||||
);
|
||||
|
||||
let rect = tile.rect.to_box2d()
|
||||
.intersection_unchecked(&tile.clip_rect.to_box2d())
|
||||
let rect = tile.rect
|
||||
.intersection_unchecked(&tile.clip_rect)
|
||||
.intersection_unchecked(&partial_clip_rect)
|
||||
.intersection_unchecked(&valid_device_rect);
|
||||
|
||||
|
@ -3309,7 +3299,7 @@ impl Renderer {
|
|||
// on Mali-G77 we have observed artefacts when calling glClear (even with
|
||||
// the empty scissor rect set) after calling eglSetDamageRegion with an
|
||||
// empty damage region. So avoid clearing in that case. See bug 1709548.
|
||||
if !dirty_rect.is_empty() && occlusion.test(&dirty_rect.to_box2d()) {
|
||||
if !dirty_rect.is_empty() && occlusion.test(&dirty_rect) {
|
||||
// We have a single dirty rect, so clear only that
|
||||
self.device.clear_target(clear_color,
|
||||
None,
|
||||
|
@ -3414,7 +3404,7 @@ impl Renderer {
|
|||
DrawTarget::NativeSurface { .. } => {
|
||||
unreachable!("bug: native compositor surface in child target");
|
||||
}
|
||||
DrawTarget::Default { rect, total_size, .. } if rect.origin == FramebufferIntPoint::zero() && rect.size == total_size => {
|
||||
DrawTarget::Default { rect, total_size, .. } if rect.min == FramebufferIntPoint::zero() && rect.size() == total_size => {
|
||||
// whole screen is covered, no need for scissor
|
||||
None
|
||||
}
|
||||
|
@ -3666,8 +3656,8 @@ impl Renderer {
|
|||
let rect = render_tasks[*task_id].get_target_rect().to_f32();
|
||||
ClearInstance {
|
||||
rect: [
|
||||
rect.origin.x, rect.origin.y,
|
||||
rect.size.width, rect.size.height,
|
||||
rect.min.x, rect.min.y,
|
||||
rect.width(), rect.height(),
|
||||
],
|
||||
color: zero_color,
|
||||
}
|
||||
|
@ -3679,8 +3669,8 @@ impl Renderer {
|
|||
let rect = render_tasks[*task_id].get_target_rect().to_f32();
|
||||
ClearInstance {
|
||||
rect: [
|
||||
rect.origin.x, rect.origin.y,
|
||||
rect.size.width, rect.size.height,
|
||||
rect.min.x, rect.min.y,
|
||||
rect.width(), rect.height(),
|
||||
],
|
||||
color: one_color,
|
||||
}
|
||||
|
@ -3836,8 +3826,8 @@ impl Renderer {
|
|||
.iter()
|
||||
.map(|r| ClearInstance {
|
||||
rect: [
|
||||
r.origin.x as f32, r.origin.y as f32,
|
||||
r.size.width as f32, r.size.height as f32,
|
||||
r.min.x as f32, r.min.y as f32,
|
||||
r.width() as f32, r.height() as f32,
|
||||
],
|
||||
color,
|
||||
})
|
||||
|
@ -4209,9 +4199,9 @@ impl Renderer {
|
|||
if tile.kind == TileKind::Clear {
|
||||
continue;
|
||||
}
|
||||
let tile_dirty_rect = tile.dirty_rect.translate(tile.rect.origin.to_vector());
|
||||
let tile_dirty_rect = tile.dirty_rect.translate(tile.rect.min.to_vector());
|
||||
let transformed_dirty_rect = if let Some(transform) = tile.transform {
|
||||
transform.outer_transformed_rect(&tile_dirty_rect)
|
||||
transform.outer_transformed_box2d(&tile_dirty_rect)
|
||||
} else {
|
||||
Some(tile_dirty_rect)
|
||||
};
|
||||
|
@ -4251,8 +4241,7 @@ impl Renderer {
|
|||
} else {
|
||||
// If we don't have a valid partial present scenario, return a single
|
||||
// dirty rect to the client that covers the entire framebuffer.
|
||||
let fb_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
let fb_rect = DeviceIntRect::from_size(
|
||||
draw_target_dimensions,
|
||||
);
|
||||
results.dirty_rects.push(fb_rect);
|
||||
|
@ -4634,7 +4623,7 @@ impl Renderer {
|
|||
PictureCacheDebugInfo::new(),
|
||||
);
|
||||
|
||||
let size = frame.device_rect.size.to_f32();
|
||||
let size = frame.device_rect.size().to_f32();
|
||||
let surface_origin_is_top_left = self.device.surface_origin_is_top_left();
|
||||
let (bottom, top) = if surface_origin_is_top_left {
|
||||
(0.0, size.height)
|
||||
|
@ -4655,7 +4644,9 @@ impl Renderer {
|
|||
let mut fb_rect = frame.device_rect * fb_scale;
|
||||
|
||||
if !surface_origin_is_top_left {
|
||||
fb_rect.origin.y = device_size.height - fb_rect.origin.y - fb_rect.size.height;
|
||||
let h = fb_rect.height();
|
||||
fb_rect.min.y = device_size.height - fb_rect.max.y;
|
||||
fb_rect.max.y = fb_rect.min.y + h;
|
||||
}
|
||||
|
||||
let draw_target = DrawTarget::Default {
|
||||
|
@ -4741,10 +4732,10 @@ impl Renderer {
|
|||
match item {
|
||||
DebugItem::Rect { rect, outer_color, inner_color } => {
|
||||
debug_renderer.add_quad(
|
||||
rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + rect.size.height,
|
||||
rect.min.x,
|
||||
rect.min.y,
|
||||
rect.max.x,
|
||||
rect.max.y,
|
||||
(*inner_color).into(),
|
||||
(*inner_color).into(),
|
||||
);
|
||||
|
@ -4818,12 +4809,12 @@ impl Renderer {
|
|||
.max(0),
|
||||
);
|
||||
|
||||
let source_rect = DeviceIntRect::new(
|
||||
let source_rect = DeviceIntRect::from_origin_and_size(
|
||||
source_origin,
|
||||
source_size,
|
||||
);
|
||||
|
||||
let target_rect = DeviceIntRect::new(
|
||||
let target_rect = DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(
|
||||
device_size.width - target_size.width - 64,
|
||||
device_size.height - target_size.height - 64,
|
||||
|
@ -4831,9 +4822,8 @@ impl Renderer {
|
|||
target_size,
|
||||
);
|
||||
|
||||
let texture_rect = FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
source_rect.size.cast_unit(),
|
||||
let texture_rect = FramebufferIntRect::from_size(
|
||||
source_rect.size().cast_unit(),
|
||||
);
|
||||
|
||||
debug_renderer.add_rect(
|
||||
|
@ -4845,8 +4835,8 @@ impl Renderer {
|
|||
let texture = self.device.create_texture(
|
||||
ImageBufferKind::Texture2D,
|
||||
ImageFormat::BGRA8,
|
||||
source_rect.size.width,
|
||||
source_rect.size.height,
|
||||
source_rect.width(),
|
||||
source_rect.height(),
|
||||
TextureFilter::Nearest,
|
||||
Some(RenderTargetInfo { has_depth: false }),
|
||||
);
|
||||
|
@ -4953,8 +4943,7 @@ impl Renderer {
|
|||
continue;
|
||||
}
|
||||
let dimensions = texture.get_dimensions();
|
||||
let src_rect = FramebufferIntRect::new(
|
||||
FramebufferIntPoint::zero(),
|
||||
let src_rect = FramebufferIntRect::from_size(
|
||||
FramebufferIntSize::new(dimensions.width as i32, dimensions.height as i32),
|
||||
);
|
||||
|
||||
|
@ -4966,7 +4955,7 @@ impl Renderer {
|
|||
}
|
||||
|
||||
// Draw the info tag.
|
||||
let tag_rect = rect(x, tag_y, size, tag_height);
|
||||
let tag_rect = rect(x, tag_y, size, tag_height).to_box2d();
|
||||
let tag_color = select_color(texture);
|
||||
device.clear_target(
|
||||
Some(tag_color),
|
||||
|
@ -4978,15 +4967,15 @@ impl Renderer {
|
|||
let dim = texture.get_dimensions();
|
||||
let text_rect = tag_rect.inflate(-text_margin, -text_margin);
|
||||
debug_renderer.add_text(
|
||||
text_rect.min_x() as f32,
|
||||
text_rect.max_y() as f32, // Top-relative.
|
||||
text_rect.min.x as f32,
|
||||
text_rect.max.y as f32, // Top-relative.
|
||||
&format!("{}x{}", dim.width, dim.height),
|
||||
ColorU::new(0, 0, 0, 255),
|
||||
Some(tag_rect.to_f32())
|
||||
);
|
||||
|
||||
// Blit the contents of the texture.
|
||||
let dest_rect = draw_target.to_framebuffer_rect(rect(x, image_y, size, size));
|
||||
let dest_rect = draw_target.to_framebuffer_rect(rect(x, image_y, size, size).to_box2d());
|
||||
let read_target = ReadTarget::from_texture(texture);
|
||||
|
||||
if surface_origin_is_top_left {
|
||||
|
@ -5089,7 +5078,7 @@ impl Renderer {
|
|||
}
|
||||
|
||||
pub fn read_pixels_rgba8(&mut self, rect: FramebufferIntRect) -> Vec<u8> {
|
||||
let mut pixels = vec![0; (rect.size.width * rect.size.height * 4) as usize];
|
||||
let mut pixels = vec![0; (rect.area() * 4) as usize];
|
||||
self.device.read_pixels_into(rect, ImageFormat::RGBA8, &mut pixels);
|
||||
pixels
|
||||
}
|
||||
|
@ -5987,8 +5976,8 @@ mod tests {
|
|||
assert_eq!(tracker.get_damage_rect(3), Some(DeviceRect::zero()));
|
||||
assert_eq!(tracker.get_damage_rect(4), None);
|
||||
|
||||
let damage1 = DeviceRect::new(DevicePoint::new(10.0, 10.0), DeviceSize::new(10.0, 10.0));
|
||||
let damage2 = DeviceRect::new(DevicePoint::new(20.0, 20.0), DeviceSize::new(10.0, 10.0));
|
||||
let damage1 = DeviceRect::from_origin_and_size(DevicePoint::new(10.0, 10.0), DeviceSize::new(10.0, 10.0));
|
||||
let damage2 = DeviceRect::from_origin_and_size(DevicePoint::new(20.0, 20.0), DeviceSize::new(10.0, 10.0));
|
||||
let combined = damage1.union(&damage2);
|
||||
|
||||
tracker.push_dirty_rect(&damage1);
|
||||
|
|
|
@ -103,8 +103,8 @@ pub fn upload_to_texture_cache(
|
|||
ExternalImageSource::Invalid => {
|
||||
// Create a local buffer to fill the pbo.
|
||||
let bpp = texture.get_format().bytes_per_pixel();
|
||||
let width = stride.unwrap_or(rect.size.width * bpp);
|
||||
let total_size = width * rect.size.height;
|
||||
let width = stride.unwrap_or(rect.width() * bpp);
|
||||
let total_size = width * rect.height();
|
||||
// WR haven't support RGBAF32 format in texture_cache, so
|
||||
// we use u8 type here.
|
||||
dummy_data = vec![0xFFu8; total_size as usize];
|
||||
|
@ -133,8 +133,8 @@ pub fn upload_to_texture_cache(
|
|||
|
||||
let use_batch_upload = renderer.device.use_batched_texture_uploads() &&
|
||||
texture.flags().contains(TextureFlags::IS_SHARED_TEXTURE_CACHE) &&
|
||||
rect.size.width <= BATCH_UPLOAD_TEXTURE_SIZE.width &&
|
||||
rect.size.height <= BATCH_UPLOAD_TEXTURE_SIZE.height;
|
||||
rect.width() <= BATCH_UPLOAD_TEXTURE_SIZE.width &&
|
||||
rect.height() <= BATCH_UPLOAD_TEXTURE_SIZE.height;
|
||||
|
||||
if use_batch_upload {
|
||||
copy_into_staging_buffer(
|
||||
|
@ -327,11 +327,11 @@ fn copy_into_staging_buffer<'a>(
|
|||
|
||||
// Allocate a region within the staging buffer for this update. If there is
|
||||
// no room in an existing buffer then allocate another texture and buffer.
|
||||
let (slice, origin) = match allocator.allocate(&update_rect.size) {
|
||||
let (slice, origin) = match allocator.allocate(&update_rect.size()) {
|
||||
Some((slice, origin)) => (slice, origin),
|
||||
None => {
|
||||
let new_slice = FreeRectSlice(buffers.len() as u32);
|
||||
allocator.extend(new_slice, BATCH_UPLOAD_TEXTURE_SIZE, update_rect.size);
|
||||
allocator.extend(new_slice, BATCH_UPLOAD_TEXTURE_SIZE, update_rect.size());
|
||||
|
||||
let texture_alloc_time_start = precise_time_ns();
|
||||
let staging_texture = staging_texture_pool.get_texture(device, texture.get_format());
|
||||
|
@ -367,26 +367,26 @@ fn copy_into_staging_buffer<'a>(
|
|||
}
|
||||
};
|
||||
let buffer = &mut buffers[slice.0 as usize];
|
||||
let allocated_rect = DeviceIntRect::new(origin, update_rect.size);
|
||||
let allocated_rect = DeviceIntRect::from_origin_and_size(origin, update_rect.size());
|
||||
buffer.upload_rect = buffer.upload_rect.union(&allocated_rect);
|
||||
|
||||
batch_upload_copies.push(BatchUploadCopy {
|
||||
src_texture_index: buffer.texture_index,
|
||||
src_offset: allocated_rect.origin,
|
||||
src_offset: allocated_rect.min,
|
||||
dest_texture_id,
|
||||
dest_offset: update_rect.origin,
|
||||
size: update_rect.size,
|
||||
dest_offset: update_rect.min,
|
||||
size: update_rect.size(),
|
||||
});
|
||||
|
||||
unsafe {
|
||||
let memcpy_start_time = precise_time_ns();
|
||||
let bpp = texture.get_format().bytes_per_pixel() as usize;
|
||||
let width_bytes = update_rect.size.width as usize * bpp;
|
||||
let width_bytes = update_rect.width() as usize * bpp;
|
||||
let src_stride = update_stride.map_or(width_bytes, |stride| {
|
||||
assert!(stride >= 0);
|
||||
stride as usize
|
||||
});
|
||||
let src_size = (update_rect.size.height as usize - 1) * src_stride + width_bytes;
|
||||
let src_size = (update_rect.height() as usize - 1) * src_stride + width_bytes;
|
||||
assert!(src_size <= data.len());
|
||||
|
||||
let src: &[mem::MaybeUninit<u8>] = std::slice::from_raw_parts(data.as_ptr() as *const _, src_size);
|
||||
|
@ -403,11 +403,11 @@ fn copy_into_staging_buffer<'a>(
|
|||
|
||||
// copy the data line-by-line in to the buffer so that we do not overwrite
|
||||
// any other region of the buffer.
|
||||
for y in 0..allocated_rect.size.height as usize {
|
||||
for y in 0..allocated_rect.height() as usize {
|
||||
let src_start = y * src_stride;
|
||||
let src_end = src_start + width_bytes;
|
||||
let dst_start = (allocated_rect.origin.y as usize + y as usize) * dst_stride +
|
||||
allocated_rect.origin.x as usize * bpp;
|
||||
let dst_start = (allocated_rect.min.y as usize + y as usize) * dst_stride +
|
||||
allocated_rect.min.x as usize * bpp;
|
||||
let dst_end = dst_start + width_bytes;
|
||||
|
||||
dst[dst_start..dst_end].copy_from_slice(&src[src_start..src_end])
|
||||
|
@ -539,10 +539,10 @@ fn copy_from_staging_to_cache_using_draw_calls(
|
|||
prev_src = Some(copy.src_texture_index)
|
||||
}
|
||||
|
||||
let dest_rect = DeviceRect {
|
||||
origin: copy.dest_offset.to_f32(),
|
||||
size: copy.size.to_f32(),
|
||||
};
|
||||
let dest_rect = DeviceRect::from_origin_and_size(
|
||||
copy.dest_offset.to_f32(),
|
||||
copy.size.to_f32(),
|
||||
);
|
||||
|
||||
let src_rect = TexelRect::new(
|
||||
copy.src_offset.x as f32,
|
||||
|
|
|
@ -880,8 +880,7 @@ impl<T> VertexDataTexture<T> {
|
|||
MAX_VERTEX_TEXTURE_WIDTH - (MAX_VERTEX_TEXTURE_WIDTH % texels_per_item)
|
||||
};
|
||||
|
||||
let rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
let rect = DeviceIntRect::from_size(
|
||||
DeviceIntSize::new(logical_width as i32, needed_height),
|
||||
);
|
||||
|
||||
|
|
|
@ -831,7 +831,7 @@ impl ResourceCache {
|
|||
tile.x as i32,
|
||||
tile.y as i32,
|
||||
) * tile_size as i32;
|
||||
rect.origin -= tile_offset.to_vector();
|
||||
rect = rect.translate(-tile_offset.to_vector());
|
||||
|
||||
let tile_rect = compute_tile_size(
|
||||
&descriptor.size.into(),
|
||||
|
@ -1063,7 +1063,7 @@ impl ResourceCache {
|
|||
fn set_image_visible_rect(&mut self, key: ImageKey, rect: &DeviceIntRect) {
|
||||
if let Some(image) = self.resources.image_templates.get_mut(key) {
|
||||
image.visible_rect = *rect;
|
||||
image.descriptor.size = rect.size;
|
||||
image.descriptor.size = rect.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1131,7 +1131,7 @@ impl ResourceCache {
|
|||
index_in_text_run: loop_index as i32,
|
||||
uv_rect_address: gpu_cache.get_address(&cache_item.uv_rect_handle),
|
||||
offset: DevicePoint::new(cache_item.user_data[0], cache_item.user_data[1]),
|
||||
size: cache_item.uv_rect.size,
|
||||
size: cache_item.uv_rect.size(),
|
||||
scale: cache_item.user_data[2],
|
||||
});
|
||||
}
|
||||
|
@ -1296,7 +1296,7 @@ impl ResourceCache {
|
|||
if !tiled_on_cpu {
|
||||
// we don't expect to have partial tiles at the top and left of non-blob
|
||||
// images.
|
||||
debug_assert_eq!(image_template.visible_rect.origin, point2(0, 0));
|
||||
debug_assert_eq!(image_template.visible_rect.min, point2(0, 0));
|
||||
let bpp = descriptor.format.bytes_per_pixel();
|
||||
let stride = descriptor.compute_stride();
|
||||
descriptor.stride = Some(stride);
|
||||
|
@ -1796,12 +1796,7 @@ const NATIVE_FONT: &'static [u8] = include_bytes!("../res/Proggy.ttf");
|
|||
// This currently only casts the unit but will soon apply an offset
|
||||
fn to_image_dirty_rect(blob_dirty_rect: &BlobDirtyRect) -> ImageDirtyRect {
|
||||
match *blob_dirty_rect {
|
||||
DirtyRect::Partial(rect) => DirtyRect::Partial(
|
||||
DeviceIntRect {
|
||||
origin: DeviceIntPoint::new(rect.origin.x, rect.origin.y),
|
||||
size: DeviceIntSize::new(rect.size.width, rect.size.height),
|
||||
}
|
||||
),
|
||||
DirtyRect::Partial(rect) => DirtyRect::Partial(rect.cast_unit()),
|
||||
DirtyRect::All => DirtyRect::All,
|
||||
}
|
||||
}
|
||||
|
@ -1892,7 +1887,7 @@ impl ResourceCache {
|
|||
data: Arc::new(vec![0; desc.compute_total_size() as usize])
|
||||
};
|
||||
|
||||
assert_eq!(result.rasterized_rect.size, desc.size);
|
||||
assert_eq!(result.rasterized_rect.size(), desc.size);
|
||||
assert_eq!(result.data.len(), desc.compute_total_size() as usize);
|
||||
|
||||
num_blobs += 1;
|
||||
|
|
|
@ -575,7 +575,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
BuiltScene {
|
||||
has_root_pipeline: scene.has_root_pipeline(),
|
||||
pipeline_epochs: scene.pipeline_epochs.clone(),
|
||||
output_rect: view.device_rect.size.into(),
|
||||
output_rect: view.device_rect.size().into(),
|
||||
background_color,
|
||||
hit_testing_scene: Arc::new(builder.hit_testing_scene),
|
||||
spatial_tree: builder.spatial_tree,
|
||||
|
|
|
@ -115,17 +115,17 @@ impl AsyncScreenshotGrabber {
|
|||
) -> (AsyncScreenshotHandle, DeviceIntSize) {
|
||||
let screenshot_size = match self.mode {
|
||||
AsyncScreenshotGrabberMode::ProfilerScreenshots => {
|
||||
assert_ne!(window_rect.size.width, 0);
|
||||
assert_ne!(window_rect.size.height, 0);
|
||||
assert_ne!(window_rect.width(), 0);
|
||||
assert_ne!(window_rect.height(), 0);
|
||||
|
||||
let scale = (buffer_size.width as f32 / window_rect.size.width as f32)
|
||||
.min(buffer_size.height as f32 / window_rect.size.height as f32);
|
||||
let scale = (buffer_size.width as f32 / window_rect.width() as f32)
|
||||
.min(buffer_size.height as f32 / window_rect.height() as f32);
|
||||
|
||||
(window_rect.size.to_f32() * scale).round().to_i32()
|
||||
(window_rect.size().to_f32() * scale).round().to_i32()
|
||||
}
|
||||
|
||||
AsyncScreenshotGrabberMode::CompositionRecorder => {
|
||||
assert_eq!(buffer_size, window_rect.size);
|
||||
assert_eq!(buffer_size, window_rect.size());
|
||||
buffer_size
|
||||
}
|
||||
};
|
||||
|
@ -193,7 +193,7 @@ impl AsyncScreenshotGrabber {
|
|||
|
||||
device.read_pixels_into_pbo(
|
||||
read_target,
|
||||
DeviceIntRect::new(DeviceIntPoint::new(0, 0), read_size),
|
||||
DeviceIntRect::from_size(read_size),
|
||||
image_format,
|
||||
&pbo,
|
||||
);
|
||||
|
@ -267,7 +267,7 @@ impl AsyncScreenshotGrabber {
|
|||
}
|
||||
assert_eq!(self.scaling_textures[level].get_dimensions(), texture_size);
|
||||
|
||||
let (read_target, read_target_rect) = if read_target_rect.size.width > 2 * dest_size.width {
|
||||
let (read_target, read_target_rect) = if read_target_rect.width() > 2 * dest_size.width {
|
||||
self.scale_screenshot(
|
||||
device,
|
||||
read_target,
|
||||
|
@ -281,7 +281,7 @@ impl AsyncScreenshotGrabber {
|
|||
|
||||
(
|
||||
ReadTarget::from_texture(&self.scaling_textures[level + 1]),
|
||||
DeviceIntRect::new(DeviceIntPoint::new(0, 0), dest_size * 2),
|
||||
DeviceIntRect::from_size(dest_size * 2),
|
||||
)
|
||||
} else {
|
||||
(read_target, read_target_rect)
|
||||
|
@ -290,7 +290,7 @@ impl AsyncScreenshotGrabber {
|
|||
let draw_target = DrawTarget::from_texture(&self.scaling_textures[level], false);
|
||||
|
||||
let draw_target_rect = draw_target
|
||||
.to_framebuffer_rect(DeviceIntRect::new(DeviceIntPoint::new(0, 0), dest_size));
|
||||
.to_framebuffer_rect(DeviceIntRect::from_size(dest_size));
|
||||
|
||||
let read_target_rect = device_rect_as_framebuffer_rect(&read_target_rect);
|
||||
|
||||
|
@ -402,7 +402,7 @@ impl Renderer {
|
|||
.get_or_insert_with(AsyncScreenshotGrabber::new_composition_recorder)
|
||||
.get_screenshot(
|
||||
&mut self.device,
|
||||
DeviceIntRect::new(DeviceIntPoint::new(0, 0), device_size),
|
||||
DeviceIntRect::from_size(device_size),
|
||||
device_size,
|
||||
image_format,
|
||||
);
|
||||
|
|
|
@ -234,8 +234,8 @@ impl SpaceSnapper {
|
|||
debug_assert!(self.current_target_spatial_node_index != SpatialNodeIndex::INVALID);
|
||||
match self.snapping_transform {
|
||||
Some(ref scale_offset) => {
|
||||
let snapped_device_rect : DeviceRect = scale_offset.map_rect(rect).snap();
|
||||
scale_offset.unmap_rect(&snapped_device_rect)
|
||||
let snapped_device_rect: DeviceRect = scale_offset.map_rect(rect).snap().to_box2d();
|
||||
scale_offset.unmap_rect(&snapped_device_rect.to_rect())
|
||||
}
|
||||
None => *rect,
|
||||
}
|
||||
|
|
|
@ -1199,7 +1199,7 @@ impl TextureCache {
|
|||
let origin = entry.details.describe();
|
||||
(
|
||||
entry.texture_id,
|
||||
DeviceIntRect::new(origin, entry.size),
|
||||
DeviceIntRect::from_origin_and_size(origin, entry.size),
|
||||
entry.swizzle,
|
||||
entry.uv_rect_handle,
|
||||
entry.user_data,
|
||||
|
@ -1504,7 +1504,7 @@ impl TextureCache {
|
|||
};
|
||||
|
||||
let bpp = formats.internal.bytes_per_pixel();
|
||||
let allocated_size_in_bytes = (allocated_rect.size.area() * bpp) as usize;
|
||||
let allocated_size_in_bytes = (allocated_rect.area() * bpp) as usize;
|
||||
self.bytes_allocated[budget_type as usize] += allocated_size_in_bytes;
|
||||
|
||||
(CacheEntry {
|
||||
|
@ -1512,7 +1512,7 @@ impl TextureCache {
|
|||
user_data: params.user_data,
|
||||
last_access: self.now,
|
||||
details: EntryDetails::Cache {
|
||||
origin: allocated_rect.origin,
|
||||
origin: allocated_rect.min,
|
||||
alloc_id,
|
||||
allocated_size_in_bytes,
|
||||
},
|
||||
|
@ -1827,14 +1827,14 @@ impl TextureCacheUpdate {
|
|||
DirtyRect::Partial(dirty) => {
|
||||
// the dirty rectangle doesn't have to be within the area but has to intersect it, at least
|
||||
let stride = descriptor.compute_stride();
|
||||
let offset = descriptor.offset + dirty.origin.y * stride + dirty.origin.x * descriptor.format.bytes_per_pixel();
|
||||
let offset = descriptor.offset + dirty.min.y * stride + dirty.min.x * descriptor.format.bytes_per_pixel();
|
||||
|
||||
TextureCacheUpdate {
|
||||
rect: DeviceIntRect::new(
|
||||
DeviceIntPoint::new(origin.x + dirty.origin.x, origin.y + dirty.origin.y),
|
||||
rect: DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(origin.x + dirty.min.x, origin.y + dirty.min.y),
|
||||
DeviceIntSize::new(
|
||||
dirty.size.width.min(size.width - dirty.origin.x),
|
||||
dirty.size.height.min(size.height - dirty.origin.y),
|
||||
dirty.width().min(size.width - dirty.min.x),
|
||||
dirty.height().min(size.height - dirty.min.y),
|
||||
),
|
||||
),
|
||||
source,
|
||||
|
@ -1845,7 +1845,7 @@ impl TextureCacheUpdate {
|
|||
}
|
||||
DirtyRect::All => {
|
||||
TextureCacheUpdate {
|
||||
rect: DeviceIntRect::new(origin, size),
|
||||
rect: DeviceIntRect::from_origin_and_size(origin, size),
|
||||
source,
|
||||
stride: descriptor.stride,
|
||||
offset: descriptor.offset,
|
||||
|
|
|
@ -84,7 +84,7 @@ impl GuillotineAllocator {
|
|||
}
|
||||
|
||||
fn push(&mut self, slice: FreeRectSlice, rect: DeviceIntRect) {
|
||||
let id = FreeListBin::for_size(&rect.size).0 as usize;
|
||||
let id = FreeListBin::for_size(&rect.size()).0 as usize;
|
||||
self.bins[id].push(FreeRect {
|
||||
slice,
|
||||
rect,
|
||||
|
@ -102,13 +102,13 @@ impl GuillotineAllocator {
|
|||
.find_map(|id| if FIND_SMALLEST_AREA {
|
||||
let mut smallest_index_and_area = None;
|
||||
for (candidate_index, candidate) in self.bins[id as usize].iter().enumerate() {
|
||||
if requested_dimensions.width > candidate.rect.size.width ||
|
||||
requested_dimensions.height > candidate.rect.size.height
|
||||
if requested_dimensions.width > candidate.rect.width() ||
|
||||
requested_dimensions.height > candidate.rect.height()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
let candidate_area = candidate.rect.size.area();
|
||||
let candidate_area = candidate.rect.area();
|
||||
match smallest_index_and_area {
|
||||
Some((_, area)) if candidate_area >= area => continue,
|
||||
_ => smallest_index_and_area = Some((candidate_index, candidate_area)),
|
||||
|
@ -121,8 +121,8 @@ impl GuillotineAllocator {
|
|||
self.bins[id as usize]
|
||||
.iter()
|
||||
.position(|candidate| {
|
||||
requested_dimensions.width <= candidate.rect.size.width &&
|
||||
requested_dimensions.height <= candidate.rect.size.height
|
||||
requested_dimensions.width <= candidate.rect.width() &&
|
||||
requested_dimensions.height <= candidate.rect.height()
|
||||
})
|
||||
.map(|index| (FreeListBin(id), FreeListIndex(index)))
|
||||
})
|
||||
|
@ -130,46 +130,46 @@ impl GuillotineAllocator {
|
|||
|
||||
// Split that results in the single largest area (Min Area Split Rule, MINAS).
|
||||
fn split_guillotine(&mut self, chosen: &FreeRect, requested_dimensions: &DeviceIntSize) {
|
||||
let candidate_free_rect_to_right = DeviceIntRect::new(
|
||||
let candidate_free_rect_to_right = DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(
|
||||
chosen.rect.origin.x + requested_dimensions.width,
|
||||
chosen.rect.origin.y,
|
||||
chosen.rect.min.x + requested_dimensions.width,
|
||||
chosen.rect.min.y,
|
||||
),
|
||||
DeviceIntSize::new(
|
||||
chosen.rect.size.width - requested_dimensions.width,
|
||||
chosen.rect.width() - requested_dimensions.width,
|
||||
requested_dimensions.height,
|
||||
),
|
||||
);
|
||||
let candidate_free_rect_to_bottom = DeviceIntRect::new(
|
||||
let candidate_free_rect_to_bottom = DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(
|
||||
chosen.rect.origin.x,
|
||||
chosen.rect.origin.y + requested_dimensions.height,
|
||||
chosen.rect.min.x,
|
||||
chosen.rect.min.y + requested_dimensions.height,
|
||||
),
|
||||
DeviceIntSize::new(
|
||||
requested_dimensions.width,
|
||||
chosen.rect.size.height - requested_dimensions.height,
|
||||
chosen.rect.height() - requested_dimensions.height,
|
||||
),
|
||||
);
|
||||
|
||||
// Guillotine the rectangle.
|
||||
let new_free_rect_to_right;
|
||||
let new_free_rect_to_bottom;
|
||||
if candidate_free_rect_to_right.size.area() > candidate_free_rect_to_bottom.size.area() {
|
||||
new_free_rect_to_right = DeviceIntRect::new(
|
||||
candidate_free_rect_to_right.origin,
|
||||
if candidate_free_rect_to_right.area() > candidate_free_rect_to_bottom.area() {
|
||||
new_free_rect_to_right = DeviceIntRect::from_origin_and_size(
|
||||
candidate_free_rect_to_right.min,
|
||||
DeviceIntSize::new(
|
||||
candidate_free_rect_to_right.size.width,
|
||||
chosen.rect.size.height,
|
||||
candidate_free_rect_to_right.width(),
|
||||
chosen.rect.height(),
|
||||
),
|
||||
);
|
||||
new_free_rect_to_bottom = candidate_free_rect_to_bottom
|
||||
} else {
|
||||
new_free_rect_to_right = candidate_free_rect_to_right;
|
||||
new_free_rect_to_bottom = DeviceIntRect::new(
|
||||
candidate_free_rect_to_bottom.origin,
|
||||
new_free_rect_to_bottom = DeviceIntRect::from_origin_and_size(
|
||||
candidate_free_rect_to_bottom.min,
|
||||
DeviceIntSize::new(
|
||||
chosen.rect.size.width,
|
||||
candidate_free_rect_to_bottom.size.height,
|
||||
chosen.rect.width(),
|
||||
candidate_free_rect_to_bottom.height(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ impl GuillotineAllocator {
|
|||
self.split_guillotine(&chosen, requested_dimensions);
|
||||
|
||||
// Return the result.
|
||||
Some((chosen.slice, chosen.rect.origin))
|
||||
Some((chosen.slice, chosen.rect.min))
|
||||
}
|
||||
|
||||
/// Add a new slice to the allocator, and immediately allocate a rect from it.
|
||||
|
@ -217,8 +217,7 @@ impl GuillotineAllocator {
|
|||
fn random_fill(count: usize, texture_size: i32) -> f32 {
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
let total_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
let total_rect = DeviceIntRect::from_size(
|
||||
DeviceIntSize::new(texture_size, texture_size),
|
||||
);
|
||||
let mut rng = thread_rng();
|
||||
|
@ -242,14 +241,14 @@ fn random_fill(count: usize, texture_size: i32) -> f32 {
|
|||
|
||||
match allocator.allocate(&size) {
|
||||
Some((slice, origin)) => {
|
||||
let rect = DeviceIntRect::new(origin, size);
|
||||
let rect = DeviceIntRect::from_origin_and_size(origin, size);
|
||||
assert_eq!(None, slices[slice.0 as usize].iter().find(|r| r.intersects(&rect)));
|
||||
assert!(total_rect.contains_rect(&rect));
|
||||
assert!(total_rect.contains_box(&rect));
|
||||
slices[slice.0 as usize].push(rect);
|
||||
}
|
||||
None => {
|
||||
allocator.extend(FreeRectSlice(slices.len() as u32), total_rect.size, size);
|
||||
let rect = DeviceIntRect::new(DeviceIntPoint::zero(), size);
|
||||
allocator.extend(FreeRectSlice(slices.len() as u32), total_rect.size(), size);
|
||||
let rect = DeviceIntRect::from_size(size);
|
||||
slices.push(vec![rect]);
|
||||
}
|
||||
}
|
||||
|
@ -257,9 +256,9 @@ fn random_fill(count: usize, texture_size: i32) -> f32 {
|
|||
// validate the free rects
|
||||
for (i, free_vecs) in allocator.bins.iter().enumerate() {
|
||||
for fr in free_vecs {
|
||||
assert_eq!(FreeListBin(i as u8), FreeListBin::for_size(&fr.rect.size));
|
||||
assert_eq!(FreeListBin(i as u8), FreeListBin::for_size(&fr.rect.size()));
|
||||
assert_eq!(None, slices[fr.slice.0 as usize].iter().find(|r| r.intersects(&fr.rect)));
|
||||
assert!(total_rect.contains_rect(&fr.rect));
|
||||
assert!(total_rect.contains_box(&fr.rect));
|
||||
slices[fr.slice.0 as usize].push(fr.rect);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ impl AtlasAllocator for BucketedShelfAllocator {
|
|||
|
||||
fn allocate(&mut self, size: DeviceIntSize) -> Option<(AllocId, DeviceIntRect)> {
|
||||
self.allocate(size.to_untyped()).map(|alloc| {
|
||||
(AllocId(alloc.id.serialize()), alloc.rectangle.to_rect().cast_unit())
|
||||
(AllocId(alloc.id.serialize()), alloc.rectangle.cast_unit())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ impl AtlasAllocator for ShelfAllocator {
|
|||
|
||||
fn allocate(&mut self, size: DeviceIntSize) -> Option<(AllocId, DeviceIntRect)> {
|
||||
self.allocate(size.to_untyped()).map(|alloc| {
|
||||
(AllocId(alloc.id.serialize()), alloc.rectangle.to_rect().cast_unit())
|
||||
(AllocId(alloc.id.serialize()), alloc.rectangle.cast_unit())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -247,10 +247,10 @@ impl SlabAllocator {
|
|||
if let Some((origin, location)) = region.alloc() {
|
||||
return Some((
|
||||
pack_alloc_id(region.index, location),
|
||||
DeviceIntRect {
|
||||
DeviceIntRect::from_origin_and_size(
|
||||
origin,
|
||||
size: allocated_size,
|
||||
}
|
||||
allocated_size,
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -263,10 +263,10 @@ impl SlabAllocator {
|
|||
|
||||
return Some((
|
||||
pack_alloc_id(region.index, location),
|
||||
DeviceIntRect {
|
||||
DeviceIntRect::from_origin_and_size(
|
||||
origin,
|
||||
size: allocated_size,
|
||||
},
|
||||
allocated_size,
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ impl SlabAllocator {
|
|||
let region_spacing = 5.0;
|
||||
let text_spacing = 15.0;
|
||||
let regions_per_row = (self.size / self.region_size) as usize;
|
||||
let wh = rect.size().width.min(rect.size().height);
|
||||
let wh = rect.width().min(rect.height());
|
||||
let region_wh = (wh - region_spacing) / regions_per_row as f32 - region_spacing;
|
||||
|
||||
let x0 = rect.min.x;
|
||||
|
|
|
@ -927,7 +927,7 @@ pub trait MaxRect {
|
|||
|
||||
impl MaxRect for DeviceIntRect {
|
||||
fn max_rect() -> Self {
|
||||
DeviceIntRect::new(
|
||||
DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::new(i32::MIN / 2, i32::MIN / 2),
|
||||
DeviceIntSize::new(i32::MAX, i32::MAX),
|
||||
)
|
||||
|
@ -1207,7 +1207,7 @@ pub fn raster_rect_to_device_pixels(
|
|||
device_pixel_scale: DevicePixelScale,
|
||||
) -> DeviceRect {
|
||||
let world_rect = rect * Scale::new(1.0);
|
||||
let device_rect = world_rect * device_pixel_scale;
|
||||
let device_rect = (world_rect * device_pixel_scale).to_box2d();
|
||||
device_rect.round_out()
|
||||
}
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ pub fn update_primitive_visibility(
|
|||
&map_surface_to_world,
|
||||
) {
|
||||
let debug_rect = rect * frame_context.global_device_pixel_scale;
|
||||
frame_state.scratch.primitive.push_debug_rect(debug_rect, debug_color, debug_color.scale_alpha(0.5));
|
||||
frame_state.scratch.primitive.push_debug_rect(debug_rect.to_box2d(), debug_color, debug_color.scale_alpha(0.5));
|
||||
}
|
||||
}
|
||||
} else if frame_context.debug_flags.contains(::api::DebugFlags::OBSCURE_IMAGES) {
|
||||
|
@ -527,7 +527,7 @@ pub fn update_primitive_visibility(
|
|||
) {
|
||||
let rect = rect * frame_context.global_device_pixel_scale;
|
||||
if rect.size.width > 70.0 && rect.size.height > 70.0 {
|
||||
frame_state.scratch.primitive.push_debug_rect(rect, debug_colors::PURPLE, debug_colors::PURPLE);
|
||||
frame_state.scratch.primitive.push_debug_rect(rect.to_box2d(), debug_colors::PURPLE, debug_colors::PURPLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use euclid::{size2, Rect, num::Zero};
|
||||
use euclid::{size2, Box2D, num::Zero};
|
||||
use peek_poke::PeekPoke;
|
||||
use std::ops::{Add, Sub};
|
||||
use std::sync::Arc;
|
||||
|
@ -296,7 +296,7 @@ impl ImageDescriptor {
|
|||
|
||||
/// Computes the bounding rectangle for the image, rooted at (0, 0).
|
||||
pub fn full_rect(&self) -> DeviceIntRect {
|
||||
DeviceIntRect::new(
|
||||
DeviceIntRect::from_origin_and_size(
|
||||
DeviceIntPoint::zero(),
|
||||
self.size,
|
||||
)
|
||||
|
@ -439,13 +439,13 @@ pub struct BlobImageParams {
|
|||
|
||||
/// The possible states of a Dirty rect.
|
||||
///
|
||||
/// This exists because people kept getting confused with `Option<Rect>`.
|
||||
/// This exists because people kept getting confused with `Option<Box2D>`.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum DirtyRect<T: Copy, U> {
|
||||
/// Everything is Dirty, equivalent to Partial(image_bounds)
|
||||
All,
|
||||
/// Some specific amount is dirty
|
||||
Partial(Rect<T, U>)
|
||||
Partial(Box2D<T, U>)
|
||||
}
|
||||
|
||||
impl<T, U> DirtyRect<T, U>
|
||||
|
@ -458,7 +458,7 @@ where
|
|||
{
|
||||
/// Creates an empty DirtyRect (indicating nothing is invalid)
|
||||
pub fn empty() -> Self {
|
||||
DirtyRect::Partial(Rect::zero())
|
||||
DirtyRect::Partial(Box2D::zero())
|
||||
}
|
||||
|
||||
/// Returns whether the dirty rect is empty
|
||||
|
@ -476,7 +476,7 @@ where
|
|||
|
||||
/// Maps over the contents of Partial.
|
||||
pub fn map<F>(self, func: F) -> Self
|
||||
where F: FnOnce(Rect<T, U>) -> Rect<T, U>,
|
||||
where F: FnOnce(Box2D<T, U>) -> Box2D<T, U>,
|
||||
{
|
||||
use crate::DirtyRect::*;
|
||||
|
||||
|
@ -503,19 +503,19 @@ where
|
|||
match (*self, *other) {
|
||||
(All, rect) | (rect, All) => rect,
|
||||
(Partial(rect1), Partial(rect2)) => {
|
||||
Partial(rect1.intersection(&rect2).unwrap_or_else(Rect::zero))
|
||||
Partial(rect1.intersection(&rect2).unwrap_or_else(Box2D::zero))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the dirty rect into a subrect of the given one via intersection.
|
||||
pub fn to_subrect_of(&self, rect: &Rect<T, U>) -> Rect<T, U> {
|
||||
pub fn to_subrect_of(&self, rect: &Box2D<T, U>) -> Box2D<T, U> {
|
||||
use crate::DirtyRect::*;
|
||||
|
||||
match *self {
|
||||
All => *rect,
|
||||
Partial(dirty_rect) => {
|
||||
dirty_rect.intersection(rect).unwrap_or_else(Rect::zero)
|
||||
dirty_rect.intersection(rect).unwrap_or_else(Box2D::zero)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,8 +526,8 @@ impl<T: Copy, U> Clone for DirtyRect<T, U> {
|
|||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
|
||||
impl<T: Copy, U> From<Rect<T, U>> for DirtyRect<T, U> {
|
||||
fn from(rect: Rect<T, U>) -> Self {
|
||||
impl<T: Copy, U> From<Box2D<T, U>> for DirtyRect<T, U> {
|
||||
fn from(rect: Box2D<T, U>) -> Self {
|
||||
DirtyRect::Partial(rect)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,13 @@ use crate::image::DirtyRect;
|
|||
#[derive(Hash, Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct DevicePixel;
|
||||
|
||||
pub type DeviceIntRect = Rect<i32, DevicePixel>;
|
||||
pub type DeviceIntRect = Box2D<i32, DevicePixel>;
|
||||
pub type DeviceIntPoint = Point2D<i32, DevicePixel>;
|
||||
pub type DeviceIntSize = Size2D<i32, DevicePixel>;
|
||||
pub type DeviceIntLength = Length<i32, DevicePixel>;
|
||||
pub type DeviceIntSideOffsets = SideOffsets2D<i32, DevicePixel>;
|
||||
|
||||
pub type DeviceRect = Rect<f32, DevicePixel>;
|
||||
pub type DeviceRect = Box2D<f32, DevicePixel>;
|
||||
pub type DeviceBox2D = Box2D<f32, DevicePixel>;
|
||||
pub type DevicePoint = Point2D<f32, DevicePixel>;
|
||||
pub type DeviceVector2D = Vector2D<f32, DevicePixel>;
|
||||
|
@ -45,7 +45,7 @@ pub struct FramebufferPixel;
|
|||
|
||||
pub type FramebufferIntPoint = Point2D<i32, FramebufferPixel>;
|
||||
pub type FramebufferIntSize = Size2D<i32, FramebufferPixel>;
|
||||
pub type FramebufferIntRect = Rect<i32, FramebufferPixel>;
|
||||
pub type FramebufferIntRect = Box2D<i32, FramebufferPixel>;
|
||||
|
||||
/// Geometry in the coordinate system of a Picture (intermediate
|
||||
/// surface) in physical pixels.
|
||||
|
@ -179,8 +179,8 @@ impl TexelRect {
|
|||
impl Into<TexelRect> for DeviceIntRect {
|
||||
fn into(self) -> TexelRect {
|
||||
TexelRect {
|
||||
uv0: self.min().to_f32(),
|
||||
uv1: self.max().to_f32(),
|
||||
uv0: self.min.to_f32(),
|
||||
uv1: self.max.to_f32(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,15 +51,15 @@ fn render_blob(
|
|||
// make sense for the rendered content to depend on its tile.
|
||||
let tile_checker = (tile.x % 2 == 0) != (tile.y % 2 == 0);
|
||||
|
||||
let dirty_rect = dirty_rect.to_subrect_of(&descriptor.rect);
|
||||
let dirty_rect = dirty_rect.to_subrect_of(&descriptor.rect.to_box2d());
|
||||
|
||||
// We want the dirty rect local to the tile rather than the whole image.
|
||||
let tx: BlobToDeviceTranslation = (-descriptor.rect.origin.to_vector()).into();
|
||||
|
||||
let rasterized_rect = tx.transform_rect(&dirty_rect);
|
||||
let rasterized_rect = tx.transform_box(&dirty_rect);
|
||||
|
||||
for y in rasterized_rect.min_y() .. rasterized_rect.max_y() {
|
||||
for x in rasterized_rect.min_x() .. rasterized_rect.max_x() {
|
||||
for y in rasterized_rect.min.y .. rasterized_rect.max.y {
|
||||
for x in rasterized_rect.min.x .. rasterized_rect.max.x {
|
||||
// Apply the tile's offset. This is important: all drawing commands should be
|
||||
// translated by this offset to give correct results with tiled blob images.
|
||||
let x2 = x + descriptor.rect.origin.x;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
use euclid::{point2, size2, rect};
|
||||
use euclid::{point2, size2, rect, Box2D};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
@ -238,7 +238,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(151, 56, ImageFormat::BGRA8, ImageDescriptorFlags::IS_OPAQUE),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 151, 56),
|
||||
DeviceIntRect::from_size(DeviceIntSize::new(151, 56)),
|
||||
Some(128),
|
||||
);
|
||||
|
||||
|
@ -279,7 +279,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let test_size = FramebufferIntSize::new(800, 800);
|
||||
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
FramebufferIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -293,7 +293,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(15000, 15000, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 15000, 15000),
|
||||
DeviceIntRect::from_size(DeviceIntSize::new(15000, 15000)),
|
||||
Some(100),
|
||||
);
|
||||
|
||||
|
@ -344,8 +344,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
//png::save_flipped("out.png", pixels.clone(), size2(window_rect.size.width, window_rect.size.height));
|
||||
|
||||
// make sure things are in the right spot
|
||||
let w = window_rect.size.width as usize;
|
||||
let h = window_rect.size.height as usize;
|
||||
let w = window_rect.width() as usize;
|
||||
let h = window_rect.height() as usize;
|
||||
let p1 = (40 + (h - 100) * w) * 4;
|
||||
assert_eq!(pixels[p1 + 0], 50);
|
||||
assert_eq!(pixels[p1 + 1], 50);
|
||||
|
@ -366,7 +366,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let window_size = self.window.get_inner_size();
|
||||
let test_size = FramebufferIntSize::new(800, 800);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
FramebufferIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -379,8 +379,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
DeviceIntRect {
|
||||
origin: point2(50, 20),
|
||||
size: size2(400, 400),
|
||||
min: point2(50, 20),
|
||||
max: point2(450, 420),
|
||||
},
|
||||
Some(100),
|
||||
);
|
||||
|
@ -423,8 +423,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
|
||||
// make sure things are in the right spot
|
||||
let w = window_rect.size.width as usize;
|
||||
let h = window_rect.size.height as usize;
|
||||
let w = window_rect.width() as usize;
|
||||
let h = window_rect.height() as usize;
|
||||
let p1 = (65 + (h - 15) * w) * 4;
|
||||
assert_eq!(pixels[p1 + 0], 255);
|
||||
assert_eq!(pixels[p1 + 1], 255);
|
||||
|
@ -460,7 +460,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let window_size = self.window.get_inner_size();
|
||||
let test_size = FramebufferIntSize::new(800, 800);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
FramebufferIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -473,8 +473,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
DeviceIntRect {
|
||||
origin: point2(0, 0),
|
||||
size: size2(500, 500),
|
||||
min: point2(0, 0),
|
||||
max: point2(500, 500),
|
||||
},
|
||||
Some(128),
|
||||
);
|
||||
|
@ -519,8 +519,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
let mut txn = Transaction::new();
|
||||
|
||||
txn.set_blob_image_visible_area(blob_img, DeviceIntRect {
|
||||
origin: point2(50, 50),
|
||||
size: size2(400, 400),
|
||||
min: point2(50, 50),
|
||||
max: point2(450, 450),
|
||||
});
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
@ -563,8 +563,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
DeviceIntRect {
|
||||
origin: point2(50, 50),
|
||||
size: size2(400, 400),
|
||||
min: point2(50, 50),
|
||||
max: point2(450, 450),
|
||||
},
|
||||
Some(128),
|
||||
);
|
||||
|
@ -614,7 +614,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = FramebufferIntSize::new(800, 800);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
point2(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -628,7 +628,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(1510, 1510, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 1510, 1510),
|
||||
DeviceIntRect::from_size(size2(1510, 1510)),
|
||||
None,
|
||||
);
|
||||
|
||||
|
@ -686,8 +686,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(1510, 1510, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 1510, 1510),
|
||||
&rect(10, 10, 100, 100).into(),
|
||||
DeviceIntRect::from_size(size2(1510, 1510)),
|
||||
&Box2D { min: point2(10, 10), max: point2(110, 110) }.into(),
|
||||
);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
@ -714,7 +714,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let pixels = self.render_and_get_pixels(window_rect);
|
||||
|
||||
self.compare_pixels(original_pixels, pixels, window_rect.size);
|
||||
self.compare_pixels(original_pixels, pixels, window_rect.size());
|
||||
|
||||
// Leaving a tiled blob image in the resource cache
|
||||
// confuses the `test_capture`. TODO: remove this
|
||||
|
@ -729,7 +729,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = FramebufferIntSize::new(400, 400);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
FramebufferIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -744,7 +744,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = FramebufferIntSize::new(400, 400);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
point2(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -831,7 +831,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
None,
|
||||
);
|
||||
blob_img2 = api.generate_blob_image_key();
|
||||
|
@ -839,7 +839,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img2,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(80, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
None,
|
||||
);
|
||||
(blob_img, blob_img2)
|
||||
|
@ -899,15 +899,15 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
&rect(100, 100, 100, 100).into(),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
&Box2D { min: point2(100, 100), max: point2(200, 200) }.into(),
|
||||
);
|
||||
txn.update_blob_image(
|
||||
blob_img2,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(59, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
&rect(100, 100, 100, 100).into(),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
&Box2D { min: point2(100, 100), max: point2(200, 200) }.into(),
|
||||
);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
@ -921,8 +921,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 150, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
&rect(200, 200, 100, 100).into(),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
&Box2D { min: point2(200, 200), max: point2(300, 300) }.into(),
|
||||
);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
@ -944,7 +944,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = FramebufferIntSize::new(400, 400);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
point2(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -957,7 +957,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
None,
|
||||
);
|
||||
img
|
||||
|
@ -987,8 +987,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 50, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
&rect(100, 100, 100, 100).into(),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
&Box2D { min: point2(100, 100), max: point2(200, 200) }.into(),
|
||||
);
|
||||
|
||||
// make a new display list that refers to the first image
|
||||
|
@ -1012,8 +1012,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
blob_img,
|
||||
ImageDescriptor::new(500, 500, ImageFormat::BGRA8, ImageDescriptorFlags::empty()),
|
||||
blob::serialize_blob(ColorU::new(50, 150, 150, 255)),
|
||||
rect(0, 0, 500, 500),
|
||||
&rect(200, 200, 100, 100).into(),
|
||||
DeviceIntRect::from_size(size2(500, 500)),
|
||||
&Box2D { min: point2(200, 200), max: point2(300, 300) }.into(),
|
||||
);
|
||||
|
||||
// make a new display list that refers to the first image
|
||||
|
@ -1032,7 +1032,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let pixels_third = self.render_and_get_pixels(window_rect);
|
||||
|
||||
assert!(pixels_first != pixels_third);
|
||||
self.compare_pixels(pixels_first, pixels_second, window_rect.size);
|
||||
self.compare_pixels(pixels_first, pixels_second, window_rect.size());
|
||||
}
|
||||
|
||||
// Ensures that content doing a save-restore produces the same results as not
|
||||
|
@ -1041,7 +1041,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = FramebufferIntSize::new(400, 400);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
point2(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -1134,7 +1134,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let first = do_test(false);
|
||||
let second = do_test(true);
|
||||
|
||||
self.compare_pixels(first, second, window_rect.size);
|
||||
self.compare_pixels(first, second, window_rect.size());
|
||||
}
|
||||
|
||||
// regression test for #2769
|
||||
|
@ -1144,7 +1144,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = FramebufferIntSize::new(400, 400);
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
point2(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
@ -1194,7 +1194,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
let path = "../captures/test";
|
||||
let layout_size = LayoutSize::new(400., 400.);
|
||||
let dim = self.window.get_inner_size();
|
||||
let window_rect = FramebufferIntRect::new(
|
||||
let window_rect = FramebufferIntRect::from_origin_and_size(
|
||||
point2(0, dim.height - layout_size.height as i32),
|
||||
size2(layout_size.width as i32, layout_size.height as i32),
|
||||
);
|
||||
|
@ -1261,7 +1261,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// 5. render the built frame and compare
|
||||
let pixels1 = self.render_and_get_pixels(window_rect);
|
||||
self.compare_pixels(pixels0.clone(), pixels1, window_rect.size);
|
||||
self.compare_pixels(pixels0.clone(), pixels1, window_rect.size());
|
||||
|
||||
// 6. rebuild the scene and compare again
|
||||
let mut txn = Transaction::new();
|
||||
|
@ -1269,7 +1269,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
txn.generate_frame(0);
|
||||
self.wrench.api.send_transaction(captured.document_id, txn);
|
||||
let pixels2 = self.render_and_get_pixels(window_rect);
|
||||
self.compare_pixels(pixels0, pixels2, window_rect.size);
|
||||
self.compare_pixels(pixels0, pixels2, window_rect.size());
|
||||
}
|
||||
|
||||
fn test_zero_height_window(&mut self) {
|
||||
|
|
|
@ -966,7 +966,7 @@ impl<'a> ReftestHarness<'a> {
|
|||
);
|
||||
|
||||
// taking the bottom left sub-rectangle
|
||||
let rect = FramebufferIntRect::new(
|
||||
let rect = FramebufferIntRect::from_origin_and_size(
|
||||
FramebufferIntPoint::new(0, window_size.height - size.height),
|
||||
FramebufferIntSize::new(size.width, size.height),
|
||||
);
|
||||
|
|
|
@ -79,7 +79,7 @@ fuzzy-if(webrender&&winWidget,0-1,0-75) == grid-track-intrinsic-sizing-003.html
|
|||
== grid-track-fit-content-sizing-001.html grid-track-fit-content-sizing-001-ref.html
|
||||
== grid-track-fit-content-sizing-002.html grid-track-fit-content-sizing-002-ref.html
|
||||
== grid-max-sizing-flex-001.html grid-max-sizing-flex-001-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-10) == grid-max-sizing-flex-002.html grid-max-sizing-flex-002-ref.html
|
||||
fuzzy-if(webrender,0-2,0-100) == grid-max-sizing-flex-002.html grid-max-sizing-flex-002-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-10) == grid-max-sizing-flex-003.html grid-max-sizing-flex-003-ref.html
|
||||
== grid-max-sizing-flex-004.html grid-max-sizing-flex-004-ref.html
|
||||
== grid-max-sizing-flex-005.html grid-max-sizing-flex-005-ref.html
|
||||
|
@ -142,7 +142,7 @@ skip-if(!gtkWidget) == grid-container-baselines-003.html grid-container-baseline
|
|||
== grid-container-synthesized-baseline-001.html grid-container-synthesized-baseline-001-ref.html
|
||||
== grid-column-gap-001.html grid-column-gap-001-ref.html
|
||||
== grid-column-gap-002.html grid-column-gap-002-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-column-gap-003.html grid-column-gap-003-ref.html
|
||||
fuzzy-if(webrender,0-2,0-60) == grid-column-gap-003.html grid-column-gap-003-ref.html
|
||||
== grid-column-gap-004.html grid-column-gap-004-ref.html
|
||||
== grid-row-gap-001.html grid-row-gap-001-ref.html
|
||||
== grid-percent-grid-gap-001.html grid-percent-grid-gap-001-ref.html
|
||||
|
@ -206,7 +206,7 @@ fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-017.html grid-fragm
|
|||
== grid-fragmentation-023.html grid-fragmentation-023-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-024.html grid-fragmentation-024-ref.html
|
||||
== grid-fragmentation-025.html grid-fragmentation-025-ref.html
|
||||
== grid-fragmentation-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&swgl,0-2,0-200) == grid-fragmentation-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-027.html grid-fragmentation-025-ref.html
|
||||
== grid-fragmentation-028.html grid-fragmentation-028-ref.html
|
||||
== grid-fragmentation-029.html grid-fragmentation-029-ref.html
|
||||
|
@ -254,11 +254,11 @@ fuzzy-if(webrender&>kWidget,0-1,0-4) == grid-fragmentation-dyn5-021.html grid-
|
|||
== grid-fragmentation-dyn5-023.html grid-fragmentation-023-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-dyn1-024.html grid-fragmentation-024-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-dyn2-025.html grid-fragmentation-025-ref.html
|
||||
== grid-fragmentation-dyn1-026.html grid-fragmentation-026-ref.html
|
||||
== grid-fragmentation-dyn2-026.html grid-fragmentation-026-ref.html
|
||||
== grid-fragmentation-dyn3-026.html grid-fragmentation-026-ref.html
|
||||
== grid-fragmentation-dyn4-026.html grid-fragmentation-026-ref.html
|
||||
== grid-fragmentation-dyn5-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&swgl,0-2,0-200) == grid-fragmentation-dyn1-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&swgl,0-2,0-200) == grid-fragmentation-dyn2-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&swgl,0-2,0-200) == grid-fragmentation-dyn3-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&swgl,0-2,0-200) == grid-fragmentation-dyn4-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&swgl,0-2,0-200) == grid-fragmentation-dyn5-026.html grid-fragmentation-026-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-dyn1-027.html grid-fragmentation-025-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-dyn2-027.html grid-fragmentation-025-ref.html
|
||||
fuzzy-if(webrender&&winWidget,0-1,0-5) == grid-fragmentation-dyn3-027.html grid-fragmentation-025-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче