Backed out 2 changesets (bug 1723665, bug 1724846) as per gw`s request
Backed out changeset 5f2aff372a24 (bug 1724846) Backed out changeset 0cc8e08b6937 (bug 1723665)
This commit is contained in:
@@ -465,7 +465,7 @@ void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
|
|||||||
aSceneBuilderTxn.SetDisplayList(gfx::DeviceColor(0.f, 0.f, 0.f, 0.f), aEpoch,
|
aSceneBuilderTxn.SetDisplayList(gfx::DeviceColor(0.f, 0.f, 0.f, 0.f), aEpoch,
|
||||||
wr::ToLayoutSize(aPipeline->mScBounds.Size()),
|
wr::ToLayoutSize(aPipeline->mScBounds.Size()),
|
||||||
aPipelineId, dl.dl_desc, dl.dl_items,
|
aPipelineId, dl.dl_desc, dl.dl_items,
|
||||||
dl.dl_cache, dl.dl_spatial_tree);
|
dl.dl_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
|
void AsyncImagePipelineManager::ApplyAsyncImageForPipeline(
|
||||||
@@ -520,7 +520,7 @@ void AsyncImagePipelineManager::SetEmptyDisplayList(
|
|||||||
builder.Finalize(dl);
|
builder.Finalize(dl);
|
||||||
txn.SetDisplayList(gfx::DeviceColor(0.f, 0.f, 0.f, 0.f), epoch,
|
txn.SetDisplayList(gfx::DeviceColor(0.f, 0.f, 0.f, 0.f), epoch,
|
||||||
wr::ToLayoutSize(pipeline->mScBounds.Size()), aPipelineId,
|
wr::ToLayoutSize(pipeline->mScBounds.Size()), aPipelineId,
|
||||||
dl.dl_desc, dl.dl_items, dl.dl_cache, dl.dl_spatial_tree);
|
dl.dl_desc, dl.dl_items, dl.dl_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncImagePipelineManager::HoldExternalImage(
|
void AsyncImagePipelineManager::HoldExternalImage(
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ void IPDLParamTraits<mozilla::layers::DisplayListData>::Write(
|
|||||||
WriteIPDLParam(aMsg, aActor, aParam.mCommands);
|
WriteIPDLParam(aMsg, aActor, aParam.mCommands);
|
||||||
WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLItems));
|
WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLItems));
|
||||||
WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLCache));
|
WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLCache));
|
||||||
WriteIPDLParam(aMsg, aActor, std::move(aParam.mDLSpatialTree));
|
|
||||||
WriteIPDLParam(aMsg, aActor, aParam.mDLDesc);
|
WriteIPDLParam(aMsg, aActor, aParam.mDLDesc);
|
||||||
WriteIPDLParam(aMsg, aActor, aParam.mRemotePipelineIds);
|
WriteIPDLParam(aMsg, aActor, aParam.mRemotePipelineIds);
|
||||||
WriteIPDLParam(aMsg, aActor, aParam.mResourceUpdates);
|
WriteIPDLParam(aMsg, aActor, aParam.mResourceUpdates);
|
||||||
@@ -35,7 +34,6 @@ bool IPDLParamTraits<mozilla::layers::DisplayListData>::Read(
|
|||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCommands) &&
|
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mCommands) &&
|
||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLItems) &&
|
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLItems) &&
|
||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLCache) &&
|
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLCache) &&
|
||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLSpatialTree) &&
|
|
||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLDesc) &&
|
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mDLDesc) &&
|
||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRemotePipelineIds) &&
|
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRemotePipelineIds) &&
|
||||||
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResourceUpdates) &&
|
ReadIPDLParam(aMsg, aIter, aActor, &aResult->mResourceUpdates) &&
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ struct DisplayListData {
|
|||||||
nsTArray<WebRenderParentCommand> mCommands;
|
nsTArray<WebRenderParentCommand> mCommands;
|
||||||
Maybe<mozilla::ipc::ByteBuf> mDLItems;
|
Maybe<mozilla::ipc::ByteBuf> mDLItems;
|
||||||
Maybe<mozilla::ipc::ByteBuf> mDLCache;
|
Maybe<mozilla::ipc::ByteBuf> mDLCache;
|
||||||
Maybe<mozilla::ipc::ByteBuf> mDLSpatialTree;
|
|
||||||
wr::BuiltDisplayListDescriptor mDLDesc;
|
wr::BuiltDisplayListDescriptor mDLDesc;
|
||||||
nsTArray<wr::PipelineId> mRemotePipelineIds;
|
nsTArray<wr::PipelineId> mRemotePipelineIds;
|
||||||
nsTArray<OpUpdateResource> mResourceUpdates;
|
nsTArray<OpUpdateResource> mResourceUpdates;
|
||||||
|
|||||||
@@ -1101,8 +1101,7 @@ void WebRenderBridgeParent::SetAPZSampleTime() {
|
|||||||
|
|
||||||
bool WebRenderBridgeParent::SetDisplayList(
|
bool WebRenderBridgeParent::SetDisplayList(
|
||||||
const LayoutDeviceRect& aRect, ipc::ByteBuf&& aDLItems,
|
const LayoutDeviceRect& aRect, ipc::ByteBuf&& aDLItems,
|
||||||
ipc::ByteBuf&& aDLCache, ipc::ByteBuf&& aSpatialTreeDL,
|
ipc::ByteBuf&& aDLCache, const wr::BuiltDisplayListDescriptor& aDLDesc,
|
||||||
const wr::BuiltDisplayListDescriptor& aDLDesc,
|
|
||||||
const nsTArray<OpUpdateResource>& aResourceUpdates,
|
const nsTArray<OpUpdateResource>& aResourceUpdates,
|
||||||
const nsTArray<RefCountedShmem>& aSmallShmems,
|
const nsTArray<RefCountedShmem>& aSmallShmems,
|
||||||
const nsTArray<ipc::Shmem>& aLargeShmems, const TimeStamp& aTxnStartTime,
|
const nsTArray<ipc::Shmem>& aLargeShmems, const TimeStamp& aTxnStartTime,
|
||||||
@@ -1115,7 +1114,6 @@ bool WebRenderBridgeParent::SetDisplayList(
|
|||||||
|
|
||||||
wr::Vec<uint8_t> dlItems(std::move(aDLItems));
|
wr::Vec<uint8_t> dlItems(std::move(aDLItems));
|
||||||
wr::Vec<uint8_t> dlCache(std::move(aDLCache));
|
wr::Vec<uint8_t> dlCache(std::move(aDLCache));
|
||||||
wr::Vec<uint8_t> dlSpatialTreeData(std::move(aSpatialTreeDL));
|
|
||||||
|
|
||||||
if (IsRootWebRenderBridgeParent()) {
|
if (IsRootWebRenderBridgeParent()) {
|
||||||
#ifdef MOZ_WIDGET_GTK
|
#ifdef MOZ_WIDGET_GTK
|
||||||
@@ -1131,7 +1129,7 @@ bool WebRenderBridgeParent::SetDisplayList(
|
|||||||
gfx::DeviceColor clearColor(0.f, 0.f, 0.f, 0.f);
|
gfx::DeviceColor clearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
aTxn.SetDisplayList(clearColor, aWrEpoch,
|
aTxn.SetDisplayList(clearColor, aWrEpoch,
|
||||||
wr::ToLayoutSize(RoundedToInt(aRect).Size()), mPipelineId,
|
wr::ToLayoutSize(RoundedToInt(aRect).Size()), mPipelineId,
|
||||||
aDLDesc, dlItems, dlCache, dlSpatialTreeData);
|
aDLDesc, dlItems, dlCache);
|
||||||
|
|
||||||
if (aObserveLayersUpdate) {
|
if (aObserveLayersUpdate) {
|
||||||
aTxn.Notify(
|
aTxn.Notify(
|
||||||
@@ -1177,12 +1175,10 @@ bool WebRenderBridgeParent::ProcessDisplayListData(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aDisplayList.mDLItems && aDisplayList.mDLCache &&
|
if (aDisplayList.mDLItems && aDisplayList.mDLCache && aValidTransaction &&
|
||||||
aDisplayList.mDLSpatialTree && aValidTransaction &&
|
|
||||||
!SetDisplayList(aDisplayList.mRect,
|
!SetDisplayList(aDisplayList.mRect,
|
||||||
std::move(aDisplayList.mDLItems.ref()),
|
std::move(aDisplayList.mDLItems.ref()),
|
||||||
std::move(aDisplayList.mDLCache.ref()),
|
std::move(aDisplayList.mDLCache.ref()),
|
||||||
std::move(aDisplayList.mDLSpatialTree.ref()),
|
|
||||||
aDisplayList.mDLDesc, aDisplayList.mResourceUpdates,
|
aDisplayList.mDLDesc, aDisplayList.mResourceUpdates,
|
||||||
aDisplayList.mSmallShmems, aDisplayList.mLargeShmems,
|
aDisplayList.mSmallShmems, aDisplayList.mLargeShmems,
|
||||||
aTxnStartTime, txn, aWrEpoch, aObserveLayersUpdate)) {
|
aTxnStartTime, txn, aWrEpoch, aObserveLayersUpdate)) {
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
|
|||||||
bool aObserveLayersUpdate);
|
bool aObserveLayersUpdate);
|
||||||
|
|
||||||
bool SetDisplayList(const LayoutDeviceRect& aRect, ipc::ByteBuf&& aDLItems,
|
bool SetDisplayList(const LayoutDeviceRect& aRect, ipc::ByteBuf&& aDLItems,
|
||||||
ipc::ByteBuf&& aDLCache, ipc::ByteBuf&& aSpatialTreeDL,
|
ipc::ByteBuf&& aDLCache,
|
||||||
const wr::BuiltDisplayListDescriptor& aDLDesc,
|
const wr::BuiltDisplayListDescriptor& aDLDesc,
|
||||||
const nsTArray<OpUpdateResource>& aResourceUpdates,
|
const nsTArray<OpUpdateResource>& aResourceUpdates,
|
||||||
const nsTArray<RefCountedShmem>& aSmallShmems,
|
const nsTArray<RefCountedShmem>& aSmallShmems,
|
||||||
|
|||||||
@@ -455,7 +455,6 @@ void WebRenderLayerManager::EndTransactionWithoutLayer(
|
|||||||
builder.Finalize(dlData);
|
builder.Finalize(dlData);
|
||||||
mLastDisplayListSize.items_size = dlData.mDLItems->mCapacity;
|
mLastDisplayListSize.items_size = dlData.mDLItems->mCapacity;
|
||||||
mLastDisplayListSize.cache_size = dlData.mDLCache->mCapacity;
|
mLastDisplayListSize.cache_size = dlData.mDLCache->mCapacity;
|
||||||
mLastDisplayListSize.spatial_tree_size = dlData.mDLSpatialTree->mCapacity;
|
|
||||||
resourceUpdates.Flush(dlData.mResourceUpdates, dlData.mSmallShmems,
|
resourceUpdates.Flush(dlData.mResourceUpdates, dlData.mSmallShmems,
|
||||||
dlData.mLargeShmems);
|
dlData.mLargeShmems);
|
||||||
dlData.mRect =
|
dlData.mRect =
|
||||||
|
|||||||
@@ -263,12 +263,10 @@ void TransactionBuilder::SetDisplayList(
|
|||||||
const gfx::DeviceColor& aBgColor, Epoch aEpoch,
|
const gfx::DeviceColor& aBgColor, Epoch aEpoch,
|
||||||
const wr::LayoutSize& aViewportSize, wr::WrPipelineId pipeline_id,
|
const wr::LayoutSize& aViewportSize, wr::WrPipelineId pipeline_id,
|
||||||
wr::BuiltDisplayListDescriptor dl_descriptor,
|
wr::BuiltDisplayListDescriptor dl_descriptor,
|
||||||
wr::Vec<uint8_t>& dl_items_data, wr::Vec<uint8_t>& dl_cache_data,
|
wr::Vec<uint8_t>& dl_items_data, wr::Vec<uint8_t>& dl_cache_data) {
|
||||||
wr::Vec<uint8_t>& dl_spatial_tree) {
|
|
||||||
wr_transaction_set_display_list(mTxn, aEpoch, ToColorF(aBgColor),
|
wr_transaction_set_display_list(mTxn, aEpoch, ToColorF(aBgColor),
|
||||||
aViewportSize, pipeline_id, dl_descriptor,
|
aViewportSize, pipeline_id, dl_descriptor,
|
||||||
&dl_items_data.inner, &dl_cache_data.inner,
|
&dl_items_data.inner, &dl_cache_data.inner);
|
||||||
&dl_spatial_tree.inner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionBuilder::ClearDisplayList(Epoch aEpoch,
|
void TransactionBuilder::ClearDisplayList(Epoch aEpoch,
|
||||||
@@ -998,9 +996,9 @@ void DisplayListBuilder::DumpSerializedDisplayList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DisplayListBuilder::Finalize(BuiltDisplayList& aOutDisplayList) {
|
void DisplayListBuilder::Finalize(BuiltDisplayList& aOutDisplayList) {
|
||||||
wr_api_finalize_builder(
|
wr_api_finalize_builder(mWrState, &aOutDisplayList.dl_desc,
|
||||||
mWrState, &aOutDisplayList.dl_desc, &aOutDisplayList.dl_items.inner,
|
&aOutDisplayList.dl_items.inner,
|
||||||
&aOutDisplayList.dl_cache.inner, &aOutDisplayList.dl_spatial_tree.inner);
|
&aOutDisplayList.dl_cache.inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayListBuilder::Finalize(layers::DisplayListData& aOutTransaction) {
|
void DisplayListBuilder::Finalize(layers::DisplayListData& aOutTransaction) {
|
||||||
@@ -1008,23 +1006,18 @@ void DisplayListBuilder::Finalize(layers::DisplayListData& aOutTransaction) {
|
|||||||
wr_dp_set_cache_size(mWrState, mDisplayItemCache->CurrentSize());
|
wr_dp_set_cache_size(mWrState, mDisplayItemCache->CurrentSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
wr::VecU8 dlItems, dlCache, dlSpatialTree;
|
wr::VecU8 dlItems, dlCache;
|
||||||
wr_api_finalize_builder(mWrState, &aOutTransaction.mDLDesc, &dlItems.inner,
|
wr_api_finalize_builder(mWrState, &aOutTransaction.mDLDesc, &dlItems.inner,
|
||||||
&dlCache.inner, &dlSpatialTree.inner);
|
&dlCache.inner);
|
||||||
aOutTransaction.mDLItems.emplace(dlItems.inner.data, dlItems.inner.length,
|
aOutTransaction.mDLItems.emplace(dlItems.inner.data, dlItems.inner.length,
|
||||||
dlItems.inner.capacity);
|
dlItems.inner.capacity);
|
||||||
aOutTransaction.mDLCache.emplace(dlCache.inner.data, dlCache.inner.length,
|
aOutTransaction.mDLCache.emplace(dlCache.inner.data, dlCache.inner.length,
|
||||||
dlCache.inner.capacity);
|
dlCache.inner.capacity);
|
||||||
aOutTransaction.mDLSpatialTree.emplace(dlSpatialTree.inner.data,
|
|
||||||
dlSpatialTree.inner.length,
|
|
||||||
dlSpatialTree.inner.capacity);
|
|
||||||
aOutTransaction.mRemotePipelineIds = std::move(mRemotePipelineIds);
|
aOutTransaction.mRemotePipelineIds = std::move(mRemotePipelineIds);
|
||||||
dlItems.inner.capacity = 0;
|
dlItems.inner.capacity = 0;
|
||||||
dlItems.inner.data = nullptr;
|
dlItems.inner.data = nullptr;
|
||||||
dlCache.inner.capacity = 0;
|
dlCache.inner.capacity = 0;
|
||||||
dlCache.inner.data = nullptr;
|
dlCache.inner.data = nullptr;
|
||||||
dlSpatialTree.inner.capacity = 0;
|
|
||||||
dlSpatialTree.inner.data = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<wr::WrSpatialId> DisplayListBuilder::PushStackingContext(
|
Maybe<wr::WrSpatialId> DisplayListBuilder::PushStackingContext(
|
||||||
|
|||||||
@@ -113,8 +113,7 @@ class TransactionBuilder final {
|
|||||||
wr::WrPipelineId pipeline_id,
|
wr::WrPipelineId pipeline_id,
|
||||||
wr::BuiltDisplayListDescriptor dl_descriptor,
|
wr::BuiltDisplayListDescriptor dl_descriptor,
|
||||||
wr::Vec<uint8_t>& dl_items_data,
|
wr::Vec<uint8_t>& dl_items_data,
|
||||||
wr::Vec<uint8_t>& dl_cache_data,
|
wr::Vec<uint8_t>& dl_cache_data);
|
||||||
wr::Vec<uint8_t>& dl_spatial_tree);
|
|
||||||
|
|
||||||
void ClearDisplayList(Epoch aEpoch, wr::WrPipelineId aPipeline);
|
void ClearDisplayList(Epoch aEpoch, wr::WrPipelineId aPipeline);
|
||||||
|
|
||||||
|
|||||||
@@ -740,7 +740,6 @@ struct ByteBuffer {
|
|||||||
struct BuiltDisplayList {
|
struct BuiltDisplayList {
|
||||||
wr::VecU8 dl_items;
|
wr::VecU8 dl_items;
|
||||||
wr::VecU8 dl_cache;
|
wr::VecU8 dl_cache;
|
||||||
wr::VecU8 dl_spatial_tree;
|
|
||||||
wr::BuiltDisplayListDescriptor dl_desc;
|
wr::BuiltDisplayListDescriptor dl_desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1837,7 +1837,6 @@ pub extern "C" fn wr_transaction_set_display_list(
|
|||||||
dl_descriptor: BuiltDisplayListDescriptor,
|
dl_descriptor: BuiltDisplayListDescriptor,
|
||||||
dl_items_data: &mut WrVecU8,
|
dl_items_data: &mut WrVecU8,
|
||||||
dl_cache_data: &mut WrVecU8,
|
dl_cache_data: &mut WrVecU8,
|
||||||
dl_spatial_tree_data: &mut WrVecU8,
|
|
||||||
) {
|
) {
|
||||||
let color = if background.a == 0.0 { None } else { Some(background) };
|
let color = if background.a == 0.0 { None } else { Some(background) };
|
||||||
|
|
||||||
@@ -1849,7 +1848,6 @@ pub extern "C" fn wr_transaction_set_display_list(
|
|||||||
let payload = DisplayListPayload {
|
let payload = DisplayListPayload {
|
||||||
items_data: dl_items_data.flush_into_vec(),
|
items_data: dl_items_data.flush_into_vec(),
|
||||||
cache_data: dl_cache_data.flush_into_vec(),
|
cache_data: dl_cache_data.flush_into_vec(),
|
||||||
spatial_tree: dl_spatial_tree_data.flush_into_vec(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let dl = BuiltDisplayList::from_data(payload, dl_descriptor);
|
let dl = BuiltDisplayList::from_data(payload, dl_descriptor);
|
||||||
@@ -3781,14 +3779,12 @@ pub unsafe extern "C" fn wr_api_finalize_builder(
|
|||||||
dl_descriptor: &mut BuiltDisplayListDescriptor,
|
dl_descriptor: &mut BuiltDisplayListDescriptor,
|
||||||
dl_items_data: &mut WrVecU8,
|
dl_items_data: &mut WrVecU8,
|
||||||
dl_cache_data: &mut WrVecU8,
|
dl_cache_data: &mut WrVecU8,
|
||||||
dl_spatial_tree: &mut WrVecU8,
|
|
||||||
) {
|
) {
|
||||||
let frame_builder = mem::replace(&mut state.frame_builder, WebRenderFrameBuilder::new(state.pipeline_id));
|
let frame_builder = mem::replace(&mut state.frame_builder, WebRenderFrameBuilder::new(state.pipeline_id));
|
||||||
let (_, dl) = frame_builder.dl_builder.finalize();
|
let (_, dl) = frame_builder.dl_builder.finalize();
|
||||||
let (payload, descriptor) = dl.into_data();
|
let (payload, descriptor) = dl.into_data();
|
||||||
*dl_items_data = WrVecU8::from_vec(payload.items_data);
|
*dl_items_data = WrVecU8::from_vec(payload.items_data);
|
||||||
*dl_cache_data = WrVecU8::from_vec(payload.cache_data);
|
*dl_cache_data = WrVecU8::from_vec(payload.cache_data);
|
||||||
*dl_spatial_tree = WrVecU8::from_vec(payload.spatial_tree);
|
|
||||||
*dl_descriptor = descriptor;
|
*dl_descriptor = descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ impl InternablePrimitive for Backdrop {
|
|||||||
_key: BackdropKey,
|
_key: BackdropKey,
|
||||||
data_handle: BackdropDataHandle,
|
data_handle: BackdropDataHandle,
|
||||||
_prim_store: &mut PrimitiveStore,
|
_prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::Backdrop {
|
PrimitiveInstanceKind::Backdrop {
|
||||||
data_handle,
|
data_handle,
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ impl InternablePrimitive for NormalBorderPrim {
|
|||||||
_key: NormalBorderKey,
|
_key: NormalBorderKey,
|
||||||
data_handle: NormalBorderDataHandle,
|
data_handle: NormalBorderDataHandle,
|
||||||
_: &mut PrimitiveStore,
|
_: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::NormalBorder {
|
PrimitiveInstanceKind::NormalBorder {
|
||||||
data_handle,
|
data_handle,
|
||||||
@@ -354,6 +355,7 @@ impl InternablePrimitive for ImageBorder {
|
|||||||
_key: ImageBorderKey,
|
_key: ImageBorderKey,
|
||||||
data_handle: ImageBorderDataHandle,
|
data_handle: ImageBorderDataHandle,
|
||||||
_: &mut PrimitiveStore,
|
_: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::ImageBorder {
|
PrimitiveInstanceKind::ImageBorder {
|
||||||
data_handle
|
data_handle
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ impl InternablePrimitive for ConicGradient {
|
|||||||
_key: ConicGradientKey,
|
_key: ConicGradientKey,
|
||||||
data_handle: ConicGradientDataHandle,
|
data_handle: ConicGradientDataHandle,
|
||||||
_prim_store: &mut PrimitiveStore,
|
_prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::ConicGradient {
|
PrimitiveInstanceKind::ConicGradient {
|
||||||
data_handle,
|
data_handle,
|
||||||
|
|||||||
@@ -594,6 +594,7 @@ impl InternablePrimitive for LinearGradient {
|
|||||||
key: LinearGradientKey,
|
key: LinearGradientKey,
|
||||||
data_handle: LinearGradientDataHandle,
|
data_handle: LinearGradientDataHandle,
|
||||||
_prim_store: &mut PrimitiveStore,
|
_prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
if key.cached {
|
if key.cached {
|
||||||
PrimitiveInstanceKind::CachedLinearGradient {
|
PrimitiveInstanceKind::CachedLinearGradient {
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ impl InternablePrimitive for RadialGradient {
|
|||||||
_key: RadialGradientKey,
|
_key: RadialGradientKey,
|
||||||
data_handle: RadialGradientDataHandle,
|
data_handle: RadialGradientDataHandle,
|
||||||
_prim_store: &mut PrimitiveStore,
|
_prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::RadialGradient {
|
PrimitiveInstanceKind::RadialGradient {
|
||||||
data_handle,
|
data_handle,
|
||||||
|
|||||||
@@ -441,6 +441,7 @@ impl InternablePrimitive for Image {
|
|||||||
_key: ImageKey,
|
_key: ImageKey,
|
||||||
data_handle: ImageDataHandle,
|
data_handle: ImageDataHandle,
|
||||||
prim_store: &mut PrimitiveStore,
|
prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
// TODO(gw): Refactor this to not need a separate image
|
// TODO(gw): Refactor this to not need a separate image
|
||||||
// instance (see ImageInstance struct).
|
// instance (see ImageInstance struct).
|
||||||
@@ -646,6 +647,7 @@ impl InternablePrimitive for YuvImage {
|
|||||||
_key: YuvImageKey,
|
_key: YuvImageKey,
|
||||||
data_handle: YuvImageDataHandle,
|
data_handle: YuvImageDataHandle,
|
||||||
_prim_store: &mut PrimitiveStore,
|
_prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::YuvImage {
|
PrimitiveInstanceKind::YuvImage {
|
||||||
data_handle,
|
data_handle,
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ impl InternablePrimitive for LineDecoration {
|
|||||||
_key: LineDecorationKey,
|
_key: LineDecorationKey,
|
||||||
data_handle: LineDecorationDataHandle,
|
data_handle: LineDecorationDataHandle,
|
||||||
_: &mut PrimitiveStore,
|
_: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
PrimitiveInstanceKind::LineDecoration {
|
PrimitiveInstanceKind::LineDecoration {
|
||||||
data_handle,
|
data_handle,
|
||||||
|
|||||||
@@ -650,6 +650,7 @@ impl InternablePrimitive for PrimitiveKeyKind {
|
|||||||
key: PrimitiveKey,
|
key: PrimitiveKey,
|
||||||
data_handle: PrimitiveDataHandle,
|
data_handle: PrimitiveDataHandle,
|
||||||
prim_store: &mut PrimitiveStore,
|
prim_store: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
match key.kind {
|
match key.kind {
|
||||||
PrimitiveKeyKind::Clear => {
|
PrimitiveKeyKind::Clear => {
|
||||||
@@ -1452,6 +1453,7 @@ pub trait InternablePrimitive: intern::Internable<InternData = ()> + Sized {
|
|||||||
key: Self::Key,
|
key: Self::Key,
|
||||||
data_handle: intern::Handle<Self>,
|
data_handle: intern::Handle<Self>,
|
||||||
prim_store: &mut PrimitiveStore,
|
prim_store: &mut PrimitiveStore,
|
||||||
|
reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind;
|
) -> PrimitiveInstanceKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use api::{
|
|||||||
ColorU, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveKind, ColorSpace,
|
ColorU, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveKind, ColorSpace,
|
||||||
PropertyBinding, PropertyBindingId, CompositeOperator,
|
PropertyBinding, PropertyBindingId, CompositeOperator,
|
||||||
};
|
};
|
||||||
use api::units::Au;
|
use api::units::{Au, LayoutVector2D};
|
||||||
use crate::scene_building::IsVisible;
|
use crate::scene_building::IsVisible;
|
||||||
use crate::filterdata::SFilterData;
|
use crate::filterdata::SFilterData;
|
||||||
use crate::intern::ItemUid;
|
use crate::intern::ItemUid;
|
||||||
@@ -292,6 +292,7 @@ impl InternablePrimitive for Picture {
|
|||||||
_key: PictureKey,
|
_key: PictureKey,
|
||||||
_: PictureDataHandle,
|
_: PictureDataHandle,
|
||||||
_: &mut PrimitiveStore,
|
_: &mut PrimitiveStore,
|
||||||
|
_reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
// Should never be hit as this method should not be
|
// Should never be hit as this method should not be
|
||||||
// called for pictures.
|
// called for pictures.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::prim_store::{PrimitiveStore, PrimKeyCommonData, PrimTemplateCommonDat
|
|||||||
use crate::renderer::{MAX_VERTEX_TEXTURE_WIDTH};
|
use crate::renderer::{MAX_VERTEX_TEXTURE_WIDTH};
|
||||||
use crate::resource_cache::{ResourceCache};
|
use crate::resource_cache::{ResourceCache};
|
||||||
use crate::util::{MatrixHelpers};
|
use crate::util::{MatrixHelpers};
|
||||||
use crate::prim_store::{InternablePrimitive, PrimitiveInstanceKind, VectorKey};
|
use crate::prim_store::{InternablePrimitive, PrimitiveInstanceKind};
|
||||||
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex, ROOT_SPATIAL_NODE_INDEX};
|
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex, ROOT_SPATIAL_NODE_INDEX};
|
||||||
use crate::space::SpaceSnapper;
|
use crate::space::SpaceSnapper;
|
||||||
use crate::util::PrimaryArc;
|
use crate::util::PrimaryArc;
|
||||||
@@ -36,7 +36,6 @@ pub struct TextRunKey {
|
|||||||
pub glyphs: PrimaryArc<Vec<GlyphInstance>>,
|
pub glyphs: PrimaryArc<Vec<GlyphInstance>>,
|
||||||
pub shadow: bool,
|
pub shadow: bool,
|
||||||
pub requested_raster_space: RasterSpace,
|
pub requested_raster_space: RasterSpace,
|
||||||
pub reference_frame_relative_offset: VectorKey,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextRunKey {
|
impl TextRunKey {
|
||||||
@@ -50,7 +49,6 @@ impl TextRunKey {
|
|||||||
glyphs: PrimaryArc(text_run.glyphs),
|
glyphs: PrimaryArc(text_run.glyphs),
|
||||||
shadow: text_run.shadow,
|
shadow: text_run.shadow,
|
||||||
requested_raster_space: text_run.requested_raster_space,
|
requested_raster_space: text_run.requested_raster_space,
|
||||||
reference_frame_relative_offset: text_run.reference_frame_relative_offset.into(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +149,6 @@ pub struct TextRun {
|
|||||||
pub glyphs: Arc<Vec<GlyphInstance>>,
|
pub glyphs: Arc<Vec<GlyphInstance>>,
|
||||||
pub shadow: bool,
|
pub shadow: bool,
|
||||||
pub requested_raster_space: RasterSpace,
|
pub requested_raster_space: RasterSpace,
|
||||||
pub reference_frame_relative_offset: LayoutVector2D,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl intern::Internable for TextRun {
|
impl intern::Internable for TextRun {
|
||||||
@@ -176,12 +173,13 @@ impl InternablePrimitive for TextRun {
|
|||||||
key: TextRunKey,
|
key: TextRunKey,
|
||||||
data_handle: TextRunDataHandle,
|
data_handle: TextRunDataHandle,
|
||||||
prim_store: &mut PrimitiveStore,
|
prim_store: &mut PrimitiveStore,
|
||||||
|
reference_frame_relative_offset: LayoutVector2D,
|
||||||
) -> PrimitiveInstanceKind {
|
) -> PrimitiveInstanceKind {
|
||||||
let run_index = prim_store.text_runs.push(TextRunPrimitive {
|
let run_index = prim_store.text_runs.push(TextRunPrimitive {
|
||||||
used_font: key.font.clone(),
|
used_font: key.font.clone(),
|
||||||
glyph_keys_range: storage::Range::empty(),
|
glyph_keys_range: storage::Range::empty(),
|
||||||
reference_frame_relative_offset: key.reference_frame_relative_offset.into(),
|
reference_frame_relative_offset,
|
||||||
snapped_reference_frame_relative_offset: key.reference_frame_relative_offset.into(),
|
snapped_reference_frame_relative_offset: reference_frame_relative_offset,
|
||||||
shadow: key.shadow,
|
shadow: key.shadow,
|
||||||
raster_scale: 1.0,
|
raster_scale: 1.0,
|
||||||
requested_raster_space: key.requested_raster_space,
|
requested_raster_space: key.requested_raster_space,
|
||||||
@@ -217,7 +215,6 @@ impl CreateShadow for TextRun {
|
|||||||
glyphs: self.glyphs.clone(),
|
glyphs: self.glyphs.clone(),
|
||||||
shadow: true,
|
shadow: true,
|
||||||
requested_raster_space,
|
requested_raster_space,
|
||||||
reference_frame_relative_offset: self.reference_frame_relative_offset,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -500,8 +497,8 @@ fn test_struct_sizes() {
|
|||||||
// test expectations and move on.
|
// test expectations and move on.
|
||||||
// (b) You made a structure larger. This is not necessarily a problem, but should only
|
// (b) You made a structure larger. This is not necessarily a problem, but should only
|
||||||
// be done with care, and after checking if talos performance regresses badly.
|
// be done with care, and after checking if talos performance regresses badly.
|
||||||
assert_eq!(mem::size_of::<TextRun>(), 72, "TextRun size changed");
|
assert_eq!(mem::size_of::<TextRun>(), 64, "TextRun size changed");
|
||||||
assert_eq!(mem::size_of::<TextRunTemplate>(), 80, "TextRunTemplate size changed");
|
assert_eq!(mem::size_of::<TextRunTemplate>(), 80, "TextRunTemplate size changed");
|
||||||
assert_eq!(mem::size_of::<TextRunKey>(), 88, "TextRunKey size changed");
|
assert_eq!(mem::size_of::<TextRunKey>(), 80, "TextRunKey size changed");
|
||||||
assert_eq!(mem::size_of::<TextRunPrimitive>(), 80, "TextRunPrimitive size changed");
|
assert_eq!(mem::size_of::<TextRunPrimitive>(), 80, "TextRunPrimitive size changed");
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
|||||||
use api::BorderRadius;
|
use api::BorderRadius;
|
||||||
use api::units::*;
|
use api::units::*;
|
||||||
use euclid::{Point2D, Rect, Box2D, Size2D, Vector2D, point2};
|
use euclid::{Point2D, Rect, Box2D, Size2D, Vector2D, point2};
|
||||||
use euclid::{Transform2D, Transform3D, Scale};
|
use euclid::{default, Transform2D, Transform3D, Scale};
|
||||||
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
|
||||||
use plane_split::{Clipper, Polygon};
|
use plane_split::{Clipper, Polygon};
|
||||||
use std::{i32, f32, fmt, ptr};
|
use std::{i32, f32, fmt, ptr};
|
||||||
@@ -15,7 +15,6 @@ use std::os::raw::c_void;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
|
|
||||||
pub use api::ScaleOffset;
|
|
||||||
|
|
||||||
// Matches the definition of SK_ScalarNearlyZero in Skia.
|
// Matches the definition of SK_ScalarNearlyZero in Skia.
|
||||||
const NEARLY_ZERO: f32 = 1.0 / 4096.0;
|
const NEARLY_ZERO: f32 = 1.0 / 4096.0;
|
||||||
@@ -119,6 +118,253 @@ impl<T> VecHelper<T> for Vec<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Represents an optimized transform where there is only
|
||||||
|
// a scale and translation (which are guaranteed to maintain
|
||||||
|
// an axis align rectangle under transformation). The
|
||||||
|
// scaling is applied first, followed by the translation.
|
||||||
|
// TODO(gw): We should try and incorporate F <-> T units here,
|
||||||
|
// but it's a bit tricky to do that now with the
|
||||||
|
// way the current spatial tree works.
|
||||||
|
#[derive(Debug, Clone, Copy, MallocSizeOf)]
|
||||||
|
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||||
|
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||||
|
pub struct ScaleOffset {
|
||||||
|
pub scale: default::Vector2D<f32>,
|
||||||
|
pub offset: default::Vector2D<f32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ScaleOffset {
|
||||||
|
pub fn identity() -> Self {
|
||||||
|
ScaleOffset {
|
||||||
|
scale: Vector2D::new(1.0, 1.0),
|
||||||
|
offset: Vector2D::zero(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct a ScaleOffset from a transform. Returns
|
||||||
|
// None if the matrix is not a pure scale / translation.
|
||||||
|
pub fn from_transform<F, T>(
|
||||||
|
m: &Transform3D<f32, F, T>,
|
||||||
|
) -> Option<ScaleOffset> {
|
||||||
|
|
||||||
|
// To check that we have a pure scale / translation:
|
||||||
|
// Every field must match an identity matrix, except:
|
||||||
|
// - Any value present in tx,ty
|
||||||
|
// - Any value present in sx,sy
|
||||||
|
|
||||||
|
if m.m12.abs() > NEARLY_ZERO ||
|
||||||
|
m.m13.abs() > NEARLY_ZERO ||
|
||||||
|
m.m14.abs() > NEARLY_ZERO ||
|
||||||
|
m.m21.abs() > NEARLY_ZERO ||
|
||||||
|
m.m23.abs() > NEARLY_ZERO ||
|
||||||
|
m.m24.abs() > NEARLY_ZERO ||
|
||||||
|
m.m31.abs() > NEARLY_ZERO ||
|
||||||
|
m.m32.abs() > NEARLY_ZERO ||
|
||||||
|
(m.m33 - 1.0).abs() > NEARLY_ZERO ||
|
||||||
|
m.m34.abs() > NEARLY_ZERO ||
|
||||||
|
m.m43.abs() > NEARLY_ZERO ||
|
||||||
|
(m.m44 - 1.0).abs() > NEARLY_ZERO {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(ScaleOffset {
|
||||||
|
scale: Vector2D::new(m.m11, m.m22),
|
||||||
|
offset: Vector2D::new(m.m41, m.m42),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_offset(offset: default::Vector2D<f32>) -> Self {
|
||||||
|
ScaleOffset {
|
||||||
|
scale: Vector2D::new(1.0, 1.0),
|
||||||
|
offset,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_scale(scale: default::Vector2D<f32>) -> Self {
|
||||||
|
ScaleOffset {
|
||||||
|
scale,
|
||||||
|
offset: Vector2D::new(0.0, 0.0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inverse(&self) -> Self {
|
||||||
|
ScaleOffset {
|
||||||
|
scale: Vector2D::new(
|
||||||
|
1.0 / self.scale.x,
|
||||||
|
1.0 / self.scale.y,
|
||||||
|
),
|
||||||
|
offset: Vector2D::new(
|
||||||
|
-self.offset.x / self.scale.x,
|
||||||
|
-self.offset.y / self.scale.y,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn offset(&self, offset: default::Vector2D<f32>) -> Self {
|
||||||
|
self.accumulate(
|
||||||
|
&ScaleOffset {
|
||||||
|
scale: Vector2D::new(1.0, 1.0),
|
||||||
|
offset,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn scale(&self, scale: f32) -> Self {
|
||||||
|
self.accumulate(
|
||||||
|
&ScaleOffset {
|
||||||
|
scale: Vector2D::new(scale, scale),
|
||||||
|
offset: Vector2D::zero(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Produce a ScaleOffset that includes both self and other.
|
||||||
|
/// The 'self' ScaleOffset is applied after other.
|
||||||
|
/// This is equivalent to `Transform3D::pre_transform`.
|
||||||
|
pub fn accumulate(&self, other: &ScaleOffset) -> Self {
|
||||||
|
ScaleOffset {
|
||||||
|
scale: Vector2D::new(
|
||||||
|
self.scale.x * other.scale.x,
|
||||||
|
self.scale.y * other.scale.y,
|
||||||
|
),
|
||||||
|
offset: Vector2D::new(
|
||||||
|
self.offset.x + self.scale.x * other.offset.x,
|
||||||
|
self.offset.y + self.scale.y * other.offset.y,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_rect<F, T>(&self, rect: &Box2D<f32, F>) -> Box2D<f32, T> {
|
||||||
|
// TODO(gw): The logic below can return an unexpected result if the supplied
|
||||||
|
// rect is invalid (has size < 0). Since Gecko currently supplied
|
||||||
|
// invalid rects in some cases, adding a max(0) here ensures that
|
||||||
|
// mapping an invalid rect retains the property that rect.is_empty()
|
||||||
|
// will return true (the mapped rect output will have size 0 instead
|
||||||
|
// of a negative size). In future we could catch / assert / fix
|
||||||
|
// these invalid rects earlier, and assert here instead.
|
||||||
|
|
||||||
|
let w = rect.width().max(0.0);
|
||||||
|
let h = rect.height().max(0.0);
|
||||||
|
|
||||||
|
let mut x0 = rect.min.x * self.scale.x + self.offset.x;
|
||||||
|
let mut y0 = rect.min.y * self.scale.y + self.offset.y;
|
||||||
|
|
||||||
|
let mut sx = w * self.scale.x;
|
||||||
|
let mut sy = h * self.scale.y;
|
||||||
|
// Handle negative scale. Previously, branchless float math was used to find the
|
||||||
|
// min / max vertices and size. However, that sequence of operations was producind
|
||||||
|
// additional floating point accuracy on android emulator builds, causing one test
|
||||||
|
// to fail an assert. Instead, we retain the same math as previously, and adjust
|
||||||
|
// the origin / size if required.
|
||||||
|
|
||||||
|
if self.scale.x < 0.0 {
|
||||||
|
x0 += sx;
|
||||||
|
sx = -sx;
|
||||||
|
}
|
||||||
|
if self.scale.y < 0.0 {
|
||||||
|
y0 += sy;
|
||||||
|
sy = -sy;
|
||||||
|
}
|
||||||
|
|
||||||
|
Box2D::from_origin_and_size(
|
||||||
|
Point2D::new(x0, y0),
|
||||||
|
Size2D::new(sx, sy),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_rect<F, T>(&self, rect: &Box2D<f32, F>) -> Box2D<f32, T> {
|
||||||
|
// TODO(gw): The logic below can return an unexpected result if the supplied
|
||||||
|
// rect is invalid (has size < 0). Since Gecko currently supplied
|
||||||
|
// invalid rects in some cases, adding a max(0) here ensures that
|
||||||
|
// mapping an invalid rect retains the property that rect.is_empty()
|
||||||
|
// will return true (the mapped rect output will have size 0 instead
|
||||||
|
// of a negative size). In future we could catch / assert / fix
|
||||||
|
// these invalid rects earlier, and assert here instead.
|
||||||
|
|
||||||
|
let w = rect.width().max(0.0);
|
||||||
|
let h = rect.height().max(0.0);
|
||||||
|
|
||||||
|
let mut x0 = (rect.min.x - self.offset.x) / self.scale.x;
|
||||||
|
let mut y0 = (rect.min.y - self.offset.y) / self.scale.y;
|
||||||
|
|
||||||
|
let mut sx = w / self.scale.x;
|
||||||
|
let mut sy = h / self.scale.y;
|
||||||
|
|
||||||
|
// Handle negative scale. Previously, branchless float math was used to find the
|
||||||
|
// min / max vertices and size. However, that sequence of operations was producind
|
||||||
|
// additional floating point accuracy on android emulator builds, causing one test
|
||||||
|
// to fail an assert. Instead, we retain the same math as previously, and adjust
|
||||||
|
// the origin / size if required.
|
||||||
|
|
||||||
|
if self.scale.x < 0.0 {
|
||||||
|
x0 += sx;
|
||||||
|
sx = -sx;
|
||||||
|
}
|
||||||
|
if self.scale.y < 0.0 {
|
||||||
|
y0 += sy;
|
||||||
|
sy = -sy;
|
||||||
|
}
|
||||||
|
|
||||||
|
Box2D::from_origin_and_size(
|
||||||
|
Point2D::new(x0, y0),
|
||||||
|
Size2D::new(sx, sy),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_vector<F, T>(&self, vector: &Vector2D<f32, F>) -> Vector2D<f32, T> {
|
||||||
|
Vector2D::new(
|
||||||
|
vector.x * self.scale.x,
|
||||||
|
vector.y * self.scale.y,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_vector<F, T>(&self, vector: &Vector2D<f32, F>) -> Vector2D<f32, T> {
|
||||||
|
Vector2D::new(
|
||||||
|
vector.x / self.scale.x,
|
||||||
|
vector.y / self.scale.y,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn map_point<F, T>(&self, point: &Point2D<f32, F>) -> Point2D<f32, T> {
|
||||||
|
Point2D::new(
|
||||||
|
point.x * self.scale.x + self.offset.x,
|
||||||
|
point.y * self.scale.y + self.offset.y,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unmap_point<F, T>(&self, point: &Point2D<f32, F>) -> Point2D<f32, T> {
|
||||||
|
Point2D::new(
|
||||||
|
(point.x - self.offset.x) / self.scale.x,
|
||||||
|
(point.y - self.offset.y) / self.scale.y,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_transform<F, T>(&self) -> Transform3D<f32, F, T> {
|
||||||
|
Transform3D::new(
|
||||||
|
self.scale.x,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
|
||||||
|
0.0,
|
||||||
|
self.scale.y,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
0.0,
|
||||||
|
|
||||||
|
self.offset.x,
|
||||||
|
self.offset.y,
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Implement these in euclid!
|
// TODO: Implement these in euclid!
|
||||||
pub trait MatrixHelpers<Src, Dst> {
|
pub trait MatrixHelpers<Src, Dst> {
|
||||||
/// A port of the preserves2dAxisAlignment function in Skia.
|
/// A port of the preserves2dAxisAlignment function in Skia.
|
||||||
|
|||||||
@@ -115,15 +115,6 @@ impl SpaceAndClipInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u8)]
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize, PeekPoke)]
|
|
||||||
pub enum SpatialTreeItem {
|
|
||||||
ScrollFrame(ScrollFrameDescriptor),
|
|
||||||
ReferenceFrame(ReferenceFrameDescriptor),
|
|
||||||
StickyFrame(StickyFrameDescriptor),
|
|
||||||
Invalid,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize, PeekPoke)]
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize, PeekPoke)]
|
||||||
pub enum DisplayItem {
|
pub enum DisplayItem {
|
||||||
@@ -151,6 +142,8 @@ pub enum DisplayItem {
|
|||||||
ClipChain(ClipChainItem),
|
ClipChain(ClipChainItem),
|
||||||
|
|
||||||
// Spaces and Frames that content can be scoped under.
|
// Spaces and Frames that content can be scoped under.
|
||||||
|
ScrollFrame(ScrollFrameDisplayItem),
|
||||||
|
StickyFrame(StickyFrameDisplayItem),
|
||||||
Iframe(IframeDisplayItem),
|
Iframe(IframeDisplayItem),
|
||||||
PushReferenceFrame(ReferenceFrameDisplayListItem),
|
PushReferenceFrame(ReferenceFrameDisplayListItem),
|
||||||
PushStackingContext(PushStackingContextDisplayItem),
|
PushStackingContext(PushStackingContextDisplayItem),
|
||||||
@@ -199,6 +192,8 @@ pub enum DebugDisplayItem {
|
|||||||
RectClip(RectClipDisplayItem),
|
RectClip(RectClipDisplayItem),
|
||||||
ClipChain(ClipChainItem, Vec<ClipId>),
|
ClipChain(ClipChainItem, Vec<ClipId>),
|
||||||
|
|
||||||
|
ScrollFrame(ScrollFrameDisplayItem),
|
||||||
|
StickyFrame(StickyFrameDisplayItem),
|
||||||
Iframe(IframeDisplayItem),
|
Iframe(IframeDisplayItem),
|
||||||
PushReferenceFrame(ReferenceFrameDisplayListItem),
|
PushReferenceFrame(ReferenceFrameDisplayListItem),
|
||||||
PushStackingContext(PushStackingContextDisplayItem),
|
PushStackingContext(PushStackingContextDisplayItem),
|
||||||
@@ -265,7 +260,7 @@ impl StickyOffsetBounds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
||||||
pub struct StickyFrameDescriptor {
|
pub struct StickyFrameDisplayItem {
|
||||||
pub id: SpatialId,
|
pub id: SpatialId,
|
||||||
pub parent_spatial_id: SpatialId,
|
pub parent_spatial_id: SpatialId,
|
||||||
pub bounds: LayoutRect,
|
pub bounds: LayoutRect,
|
||||||
@@ -302,7 +297,7 @@ pub enum ScrollSensitivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
||||||
pub struct ScrollFrameDescriptor {
|
pub struct ScrollFrameDisplayItem {
|
||||||
/// The id of the space this scroll frame creates
|
/// The id of the space this scroll frame creates
|
||||||
pub scroll_frame_id: SpatialId,
|
pub scroll_frame_id: SpatialId,
|
||||||
/// The size of the contents this contains (so the backend knows how far it can scroll).
|
/// The size of the contents this contains (so the backend knows how far it can scroll).
|
||||||
@@ -396,7 +391,6 @@ pub struct TextDisplayItem {
|
|||||||
pub font_key: font::FontInstanceKey,
|
pub font_key: font::FontInstanceKey,
|
||||||
pub color: ColorF,
|
pub color: ColorF,
|
||||||
pub glyph_options: Option<font::GlyphOptions>,
|
pub glyph_options: Option<font::GlyphOptions>,
|
||||||
pub reference_frame_relative_offset: LayoutVector2D,
|
|
||||||
} // IMPLICIT: glyphs: Vec<font::GlyphInstance>
|
} // IMPLICIT: glyphs: Vec<font::GlyphInstance>
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
|
||||||
@@ -652,9 +646,6 @@ pub struct GradientDisplayItem {
|
|||||||
/// The space between tiles of the gradient (common case: 0)
|
/// The space between tiles of the gradient (common case: 0)
|
||||||
pub tile_spacing: LayoutSize,
|
pub tile_spacing: LayoutSize,
|
||||||
pub gradient: Gradient,
|
pub gradient: Gradient,
|
||||||
/// The unsnapped rect is used for calculating repeats, so is replicated here
|
|
||||||
/// to maintain existing behavior.
|
|
||||||
pub unsnapped_rect: LayoutRect,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@@ -718,9 +709,6 @@ pub struct RadialGradientDisplayItem {
|
|||||||
pub gradient: RadialGradient,
|
pub gradient: RadialGradient,
|
||||||
pub tile_size: LayoutSize,
|
pub tile_size: LayoutSize,
|
||||||
pub tile_spacing: LayoutSize,
|
pub tile_spacing: LayoutSize,
|
||||||
/// The unsnapped rect is used for calculating repeats, so is replicated here
|
|
||||||
/// to maintain existing behavior.
|
|
||||||
pub unsnapped_rect: LayoutRect,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
||||||
@@ -733,9 +721,6 @@ pub struct ConicGradientDisplayItem {
|
|||||||
pub gradient: ConicGradient,
|
pub gradient: ConicGradient,
|
||||||
pub tile_size: LayoutSize,
|
pub tile_size: LayoutSize,
|
||||||
pub tile_spacing: LayoutSize,
|
pub tile_spacing: LayoutSize,
|
||||||
/// The unsnapped rect is used for calculating repeats, so is replicated here
|
|
||||||
/// to maintain existing behavior.
|
|
||||||
pub unsnapped_rect: LayoutRect,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Renders a filtered region of its backdrop
|
/// Renders a filtered region of its backdrop
|
||||||
@@ -747,10 +732,6 @@ pub struct BackdropFilterDisplayItem {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
||||||
pub struct ReferenceFrameDisplayListItem {
|
pub struct ReferenceFrameDisplayListItem {
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
|
|
||||||
pub struct ReferenceFrameDescriptor {
|
|
||||||
pub origin: LayoutPoint,
|
pub origin: LayoutPoint,
|
||||||
pub parent_spatial_id: SpatialId,
|
pub parent_spatial_id: SpatialId,
|
||||||
pub reference_frame: ReferenceFrame,
|
pub reference_frame: ReferenceFrame,
|
||||||
@@ -1326,9 +1307,6 @@ pub struct RepeatingImageDisplayItem {
|
|||||||
pub alpha_type: AlphaType,
|
pub alpha_type: AlphaType,
|
||||||
/// A hack used by gecko to color a simple bitmap font used for tofu glyphs
|
/// A hack used by gecko to color a simple bitmap font used for tofu glyphs
|
||||||
pub color: ColorF,
|
pub color: ColorF,
|
||||||
/// The unsnapped rect is used for calculating repeats, so is replicated here
|
|
||||||
/// to maintain existing behavior.
|
|
||||||
pub unsnapped_rect: LayoutRect,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
@@ -1732,9 +1710,11 @@ impl DisplayItem {
|
|||||||
DisplayItem::SetPoints => "set_points",
|
DisplayItem::SetPoints => "set_points",
|
||||||
DisplayItem::RadialGradient(..) => "radial_gradient",
|
DisplayItem::RadialGradient(..) => "radial_gradient",
|
||||||
DisplayItem::Rectangle(..) => "rectangle",
|
DisplayItem::Rectangle(..) => "rectangle",
|
||||||
|
DisplayItem::ScrollFrame(..) => "scroll_frame",
|
||||||
DisplayItem::SetGradientStops => "set_gradient_stops",
|
DisplayItem::SetGradientStops => "set_gradient_stops",
|
||||||
DisplayItem::ReuseItems(..) => "reuse_item",
|
DisplayItem::ReuseItems(..) => "reuse_item",
|
||||||
DisplayItem::RetainedItems(..) => "retained_items",
|
DisplayItem::RetainedItems(..) => "retained_items",
|
||||||
|
DisplayItem::StickyFrame(..) => "sticky_frame",
|
||||||
DisplayItem::Text(..) => "text",
|
DisplayItem::Text(..) => "text",
|
||||||
DisplayItem::YuvImage(..) => "yuv_image",
|
DisplayItem::YuvImage(..) => "yuv_image",
|
||||||
DisplayItem::BackdropFilter(..) => "backdrop_filter",
|
DisplayItem::BackdropFilter(..) => "backdrop_filter",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,6 @@ mod font;
|
|||||||
mod gradient_builder;
|
mod gradient_builder;
|
||||||
mod image;
|
mod image;
|
||||||
pub mod units;
|
pub mod units;
|
||||||
mod util;
|
|
||||||
|
|
||||||
pub use crate::color::*;
|
pub use crate::color::*;
|
||||||
pub use crate::display_item::*;
|
pub use crate::display_item::*;
|
||||||
@@ -57,7 +56,6 @@ pub use crate::display_list::*;
|
|||||||
pub use crate::font::*;
|
pub use crate::font::*;
|
||||||
pub use crate::gradient_builder::*;
|
pub use crate::gradient_builder::*;
|
||||||
pub use crate::image::*;
|
pub use crate::image::*;
|
||||||
pub use crate::util::ScaleOffset;
|
|
||||||
|
|
||||||
use crate::units::*;
|
use crate::units::*;
|
||||||
use crate::channel::Receiver;
|
use crate::channel::Receiver;
|
||||||
|
|||||||
@@ -1,266 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use euclid::{Point2D, Box2D, Size2D, Vector2D};
|
|
||||||
use euclid::{default, Transform3D};
|
|
||||||
|
|
||||||
// Matches the definition of SK_ScalarNearlyZero in Skia.
|
|
||||||
const NEARLY_ZERO: f32 = 1.0 / 4096.0;
|
|
||||||
|
|
||||||
// Represents an optimized transform where there is only
|
|
||||||
// a scale and translation (which are guaranteed to maintain
|
|
||||||
// an axis align rectangle under transformation). The
|
|
||||||
// scaling is applied first, followed by the translation.
|
|
||||||
// TODO(gw): We should try and incorporate F <-> T units here,
|
|
||||||
// but it's a bit tricky to do that now with the
|
|
||||||
// way the current spatial tree works.
|
|
||||||
#[derive(Debug, Clone, Copy, MallocSizeOf)]
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct ScaleOffset {
|
|
||||||
pub scale: default::Vector2D<f32>,
|
|
||||||
pub offset: default::Vector2D<f32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ScaleOffset {
|
|
||||||
pub fn identity() -> Self {
|
|
||||||
ScaleOffset {
|
|
||||||
scale: Vector2D::new(1.0, 1.0),
|
|
||||||
offset: Vector2D::zero(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct a ScaleOffset from a transform. Returns
|
|
||||||
// None if the matrix is not a pure scale / translation.
|
|
||||||
pub fn from_transform<F, T>(
|
|
||||||
m: &Transform3D<f32, F, T>,
|
|
||||||
) -> Option<ScaleOffset> {
|
|
||||||
// To check that we have a pure scale / translation:
|
|
||||||
// Every field must match an identity matrix, except:
|
|
||||||
// - Any value present in tx,ty
|
|
||||||
// - Any value present in sx,sy
|
|
||||||
|
|
||||||
if m.m12.abs() > NEARLY_ZERO ||
|
|
||||||
m.m13.abs() > NEARLY_ZERO ||
|
|
||||||
m.m14.abs() > NEARLY_ZERO ||
|
|
||||||
m.m21.abs() > NEARLY_ZERO ||
|
|
||||||
m.m23.abs() > NEARLY_ZERO ||
|
|
||||||
m.m24.abs() > NEARLY_ZERO ||
|
|
||||||
m.m31.abs() > NEARLY_ZERO ||
|
|
||||||
m.m32.abs() > NEARLY_ZERO ||
|
|
||||||
(m.m33 - 1.0).abs() > NEARLY_ZERO ||
|
|
||||||
m.m34.abs() > NEARLY_ZERO ||
|
|
||||||
m.m43.abs() > NEARLY_ZERO ||
|
|
||||||
(m.m44 - 1.0).abs() > NEARLY_ZERO {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(ScaleOffset {
|
|
||||||
scale: Vector2D::new(m.m11, m.m22),
|
|
||||||
offset: Vector2D::new(m.m41, m.m42),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_offset(offset: default::Vector2D<f32>) -> Self {
|
|
||||||
ScaleOffset {
|
|
||||||
scale: Vector2D::new(1.0, 1.0),
|
|
||||||
offset,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_scale(scale: default::Vector2D<f32>) -> Self {
|
|
||||||
ScaleOffset {
|
|
||||||
scale,
|
|
||||||
offset: Vector2D::new(0.0, 0.0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn inverse(&self) -> Self {
|
|
||||||
ScaleOffset {
|
|
||||||
scale: Vector2D::new(
|
|
||||||
1.0 / self.scale.x,
|
|
||||||
1.0 / self.scale.y,
|
|
||||||
),
|
|
||||||
offset: Vector2D::new(
|
|
||||||
-self.offset.x / self.scale.x,
|
|
||||||
-self.offset.y / self.scale.y,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn offset(&self, offset: default::Vector2D<f32>) -> Self {
|
|
||||||
self.accumulate(
|
|
||||||
&ScaleOffset {
|
|
||||||
scale: Vector2D::new(1.0, 1.0),
|
|
||||||
offset,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn scale(&self, scale: f32) -> Self {
|
|
||||||
self.accumulate(
|
|
||||||
&ScaleOffset {
|
|
||||||
scale: Vector2D::new(scale, scale),
|
|
||||||
offset: Vector2D::zero(),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Produce a ScaleOffset that includes both self and other.
|
|
||||||
/// The 'self' ScaleOffset is applied after other.
|
|
||||||
/// This is equivalent to `Transform3D::pre_transform`.
|
|
||||||
pub fn accumulate(&self, other: &ScaleOffset) -> Self {
|
|
||||||
ScaleOffset {
|
|
||||||
scale: Vector2D::new(
|
|
||||||
self.scale.x * other.scale.x,
|
|
||||||
self.scale.y * other.scale.y,
|
|
||||||
),
|
|
||||||
offset: Vector2D::new(
|
|
||||||
self.offset.x + self.scale.x * other.offset.x,
|
|
||||||
self.offset.y + self.scale.y * other.offset.y,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map_rect<F, T>(&self, rect: &Box2D<f32, F>) -> Box2D<f32, T> {
|
|
||||||
// TODO(gw): The logic below can return an unexpected result if the supplied
|
|
||||||
// rect is invalid (has size < 0). Since Gecko currently supplied
|
|
||||||
// invalid rects in some cases, adding a max(0) here ensures that
|
|
||||||
// mapping an invalid rect retains the property that rect.is_empty()
|
|
||||||
// will return true (the mapped rect output will have size 0 instead
|
|
||||||
// of a negative size). In future we could catch / assert / fix
|
|
||||||
// these invalid rects earlier, and assert here instead.
|
|
||||||
|
|
||||||
let w = rect.width().max(0.0);
|
|
||||||
let h = rect.height().max(0.0);
|
|
||||||
|
|
||||||
let mut x0 = rect.min.x * self.scale.x + self.offset.x;
|
|
||||||
let mut y0 = rect.min.y * self.scale.y + self.offset.y;
|
|
||||||
|
|
||||||
let mut sx = w * self.scale.x;
|
|
||||||
let mut sy = h * self.scale.y;
|
|
||||||
// Handle negative scale. Previously, branchless float math was used to find the
|
|
||||||
// min / max vertices and size. However, that sequence of operations was producind
|
|
||||||
// additional floating point accuracy on android emulator builds, causing one test
|
|
||||||
// to fail an assert. Instead, we retain the same math as previously, and adjust
|
|
||||||
// the origin / size if required.
|
|
||||||
|
|
||||||
if self.scale.x < 0.0 {
|
|
||||||
x0 += sx;
|
|
||||||
sx = -sx;
|
|
||||||
}
|
|
||||||
if self.scale.y < 0.0 {
|
|
||||||
y0 += sy;
|
|
||||||
sy = -sy;
|
|
||||||
}
|
|
||||||
|
|
||||||
Box2D::from_origin_and_size(
|
|
||||||
Point2D::new(x0, y0),
|
|
||||||
Size2D::new(sx, sy),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unmap_rect<F, T>(&self, rect: &Box2D<f32, F>) -> Box2D<f32, T> {
|
|
||||||
// TODO(gw): The logic below can return an unexpected result if the supplied
|
|
||||||
// rect is invalid (has size < 0). Since Gecko currently supplied
|
|
||||||
// invalid rects in some cases, adding a max(0) here ensures that
|
|
||||||
// mapping an invalid rect retains the property that rect.is_empty()
|
|
||||||
// will return true (the mapped rect output will have size 0 instead
|
|
||||||
// of a negative size). In future we could catch / assert / fix
|
|
||||||
// these invalid rects earlier, and assert here instead.
|
|
||||||
|
|
||||||
let w = rect.width().max(0.0);
|
|
||||||
let h = rect.height().max(0.0);
|
|
||||||
|
|
||||||
let mut x0 = (rect.min.x - self.offset.x) / self.scale.x;
|
|
||||||
let mut y0 = (rect.min.y - self.offset.y) / self.scale.y;
|
|
||||||
|
|
||||||
let mut sx = w / self.scale.x;
|
|
||||||
let mut sy = h / self.scale.y;
|
|
||||||
|
|
||||||
// Handle negative scale. Previously, branchless float math was used to find the
|
|
||||||
// min / max vertices and size. However, that sequence of operations was producind
|
|
||||||
// additional floating point accuracy on android emulator builds, causing one test
|
|
||||||
// to fail an assert. Instead, we retain the same math as previously, and adjust
|
|
||||||
// the origin / size if required.
|
|
||||||
|
|
||||||
if self.scale.x < 0.0 {
|
|
||||||
x0 += sx;
|
|
||||||
sx = -sx;
|
|
||||||
}
|
|
||||||
if self.scale.y < 0.0 {
|
|
||||||
y0 += sy;
|
|
||||||
sy = -sy;
|
|
||||||
}
|
|
||||||
|
|
||||||
Box2D::from_origin_and_size(
|
|
||||||
Point2D::new(x0, y0),
|
|
||||||
Size2D::new(sx, sy),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map_vector<F, T>(&self, vector: &Vector2D<f32, F>) -> Vector2D<f32, T> {
|
|
||||||
Vector2D::new(
|
|
||||||
vector.x * self.scale.x,
|
|
||||||
vector.y * self.scale.y,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unmap_vector<F, T>(&self, vector: &Vector2D<f32, F>) -> Vector2D<f32, T> {
|
|
||||||
Vector2D::new(
|
|
||||||
vector.x / self.scale.x,
|
|
||||||
vector.y / self.scale.y,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map_point<F, T>(&self, point: &Point2D<f32, F>) -> Point2D<f32, T> {
|
|
||||||
Point2D::new(
|
|
||||||
point.x * self.scale.x + self.offset.x,
|
|
||||||
point.y * self.scale.y + self.offset.y,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unmap_point<F, T>(&self, point: &Point2D<f32, F>) -> Point2D<f32, T> {
|
|
||||||
Point2D::new(
|
|
||||||
(point.x - self.offset.x) / self.scale.x,
|
|
||||||
(point.y - self.offset.y) / self.scale.y,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_transform<F, T>(&self) -> Transform3D<f32, F, T> {
|
|
||||||
Transform3D::new(
|
|
||||||
self.scale.x,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
|
|
||||||
0.0,
|
|
||||||
self.scale.y,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
0.0,
|
|
||||||
|
|
||||||
self.offset.x,
|
|
||||||
self.offset.y,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait RectHelpers<U>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
fn snap(&self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<U> RectHelpers<U> for Box2D<f32, U> {
|
|
||||||
fn snap(&self) -> Self {
|
|
||||||
self.round()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -76,7 +76,7 @@ fuzzy(1,7) == tiling-conic-3.yaml tiling-conic-3-ref.yaml
|
|||||||
== radial-zero-size-2.yaml radial-zero-size-ref.yaml
|
== radial-zero-size-2.yaml radial-zero-size-ref.yaml
|
||||||
== radial-zero-size-3.yaml radial-zero-size-ref.yaml
|
== radial-zero-size-3.yaml radial-zero-size-ref.yaml
|
||||||
|
|
||||||
fuzzy(2,34) == linear-adjust-tile-size.yaml linear-adjust-tile-size-ref.yaml
|
== linear-adjust-tile-size.yaml linear-adjust-tile-size-ref.yaml
|
||||||
== linear-repeat-clip.yaml linear-repeat-clip-ref.yaml
|
== linear-repeat-clip.yaml linear-repeat-clip-ref.yaml
|
||||||
|
|
||||||
platform(linux,mac) == linear-aligned-border-radius.yaml linear-aligned-border-radius.png
|
platform(linux,mac) == linear-aligned-border-radius.yaml linear-aligned-border-radius.png
|
||||||
|
|||||||
Reference in New Issue
Block a user