mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1094442 - Part 1: Refactor how tile w/h is queried r=kats
--HG-- extra : rebase_source : 70ef00318a718e2ce3149955d2908615d6125cf3
This commit is contained in:
parent
c08cddcfb8
commit
660dd0fe19
@ -415,8 +415,6 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
|
||||
float aTopMargin,
|
||||
float aRightMargin,
|
||||
float aBottomMargin,
|
||||
uint32_t aAlignmentX,
|
||||
uint32_t aAlignmentY,
|
||||
nsIDOMElement* aElement,
|
||||
uint32_t aPriority)
|
||||
{
|
||||
@ -451,7 +449,7 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
|
||||
aLeftMargin);
|
||||
|
||||
nsLayoutUtils::SetDisplayPortMargins(content, presShell, displayportMargins,
|
||||
aAlignmentX, aAlignmentY, aPriority);
|
||||
aPriority);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ interface nsITranslationNodeList;
|
||||
interface nsIJSRAIIHelper;
|
||||
interface nsIContentPermissionRequest;
|
||||
|
||||
[scriptable, uuid(e293355b-ae7f-4ef7-9237-452bcf3e9e6b)]
|
||||
[scriptable, uuid(9621eb05-b498-4e87-a012-95d817987624)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -188,8 +188,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
in float aTopMargin,
|
||||
in float aRightMargin,
|
||||
in float aBottomMargin,
|
||||
in uint32_t aAlignmentX,
|
||||
in uint32_t aAlignmentY,
|
||||
in nsIDOMElement aElement,
|
||||
in uint32_t aPriority);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <stdint.h> // for uint16_t, uint32_t
|
||||
#include <sys/types.h> // for int32_t
|
||||
#include "gfxPrefs.h" // for gfxPrefs::LayersTileWidth/Height
|
||||
#include "gfxPlatform.h" // for GetTileWidth/GetTileHeight
|
||||
#include "nsDebug.h" // for NS_ABORT_IF_FALSE
|
||||
#include "nsPoint.h" // for nsIntPoint
|
||||
#include "nsRect.h" // for nsIntRect
|
||||
@ -94,7 +94,7 @@ public:
|
||||
: mRetainedWidth(0)
|
||||
, mRetainedHeight(0)
|
||||
, mResolution(1)
|
||||
, mTileSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight())
|
||||
, mTileSize(gfxPlatform::GetPlatform()->GetTileWidth(), gfxPlatform::GetPlatform()->GetTileHeight())
|
||||
{}
|
||||
|
||||
~TiledLayerBuffer() {}
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "APZCCallbackHelper.h"
|
||||
#include "gfxPlatform.h" // For gfxPlatform::UseTiling
|
||||
#include "gfxPrefs.h" // For gfxPrefs::LayersTileWidth/Height
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -158,16 +157,11 @@ APZCCallbackHelper::UpdateRootFrame(nsIDOMWindowUtils* aUtils,
|
||||
return;
|
||||
}
|
||||
|
||||
gfx::IntSize alignment = gfxPlatform::GetPlatform()->UseTiling()
|
||||
? gfx::IntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()) :
|
||||
gfx::IntSize(0, 0);
|
||||
ScreenMargin margins = aMetrics.GetDisplayPortMargins();
|
||||
aUtils->SetDisplayPortMarginsForElement(margins.left,
|
||||
margins.top,
|
||||
margins.right,
|
||||
margins.bottom,
|
||||
alignment.width,
|
||||
alignment.height,
|
||||
element, 0);
|
||||
CSSRect baseCSS = aMetrics.CalculateCompositedRectInCssPixels();
|
||||
nsRect base(baseCSS.x * nsPresContext::AppUnitsPerCSSPixel(),
|
||||
@ -207,16 +201,11 @@ APZCCallbackHelper::UpdateSubFrame(nsIContent* aContent,
|
||||
} else {
|
||||
RecenterDisplayPort(aMetrics);
|
||||
}
|
||||
gfx::IntSize alignment = gfxPlatform::GetPlatform()->UseTiling()
|
||||
? gfx::IntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()) :
|
||||
gfx::IntSize(0, 0);
|
||||
ScreenMargin margins = aMetrics.GetDisplayPortMargins();
|
||||
utils->SetDisplayPortMarginsForElement(margins.left,
|
||||
margins.top,
|
||||
margins.right,
|
||||
margins.bottom,
|
||||
alignment.width,
|
||||
alignment.height,
|
||||
element, 0);
|
||||
CSSRect baseCSS = aMetrics.CalculateCompositedRectInCssPixels();
|
||||
nsRect base(baseCSS.x * nsPresContext::AppUnitsPerCSSPixel(),
|
||||
|
@ -662,8 +662,8 @@ ClientLayerManager::GetTexturePool(SurfaceFormat aFormat)
|
||||
}
|
||||
|
||||
mTexturePools.AppendElement(
|
||||
new TextureClientPool(aFormat, IntSize(gfxPrefs::LayersTileWidth(),
|
||||
gfxPrefs::LayersTileHeight()),
|
||||
new TextureClientPool(aFormat, IntSize(gfxPlatform::GetPlatform()->GetTileWidth(),
|
||||
gfxPlatform::GetPlatform()->GetTileHeight()),
|
||||
gfxPrefs::LayersTileMaxPoolSize(),
|
||||
gfxPrefs::LayersTileShrinkPoolTimeout(),
|
||||
mForwarder));
|
||||
|
@ -350,7 +350,9 @@ ClientTiledPaintedLayer::RenderLayer()
|
||||
// we always have valid content or transparent pixels to sample from.
|
||||
nsIntRect bounds = neededRegion.GetBounds();
|
||||
nsIntRect wholeTiles = bounds;
|
||||
wholeTiles.Inflate(nsIntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()));
|
||||
wholeTiles.Inflate(nsIntSize(
|
||||
gfxPlatform::GetPlatform()->GetTileWidth(),
|
||||
gfxPlatform::GetPlatform()->GetTileHeight()));
|
||||
nsIntRect padded = bounds;
|
||||
padded.Inflate(1);
|
||||
padded.IntersectRect(padded, wholeTiles);
|
||||
|
@ -386,6 +386,10 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
|
||||
if (gfxPrefs::VsyncAlignedCompositor()) {
|
||||
mCompositorVsyncObserver = new CompositorVsyncObserver(this);
|
||||
}
|
||||
|
||||
gfxPlatform::GetPlatform()->SetTileSize(
|
||||
gfxPrefs::LayersTileWidth(),
|
||||
gfxPrefs::LayersTileHeight());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -282,7 +282,9 @@ static const char *gPrefLangNames[] = {
|
||||
};
|
||||
|
||||
gfxPlatform::gfxPlatform()
|
||||
: mAzureCanvasBackendCollector(MOZ_THIS_IN_INITIALIZER_LIST(),
|
||||
: mTileWidth(-1)
|
||||
, mTileHeight(-1)
|
||||
, mAzureCanvasBackendCollector(MOZ_THIS_IN_INITIALIZER_LIST(),
|
||||
&gfxPlatform::GetAzureBackendInfo)
|
||||
{
|
||||
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
||||
@ -857,6 +859,32 @@ gfxPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
|
||||
return scaledFont;
|
||||
}
|
||||
|
||||
int
|
||||
gfxPlatform::GetTileWidth()
|
||||
{
|
||||
MOZ_ASSERT(mTileWidth != -1);
|
||||
return mTileWidth;
|
||||
}
|
||||
|
||||
int
|
||||
gfxPlatform::GetTileHeight()
|
||||
{
|
||||
MOZ_ASSERT(mTileHeight != -1);
|
||||
return mTileHeight;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::SetTileSize(int aWidth, int aHeight)
|
||||
{
|
||||
// Don't allow changing the tile size after we've set it.
|
||||
// Right now the code assumes that the tile size doesn't change.
|
||||
MOZ_ASSERT((mTileWidth == -1 && mTileHeight == -1) ||
|
||||
(mTileWidth == aWidth && mTileHeight == aHeight));
|
||||
|
||||
mTileWidth = aWidth;
|
||||
mTileHeight = aHeight;
|
||||
}
|
||||
|
||||
bool
|
||||
gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget)
|
||||
{
|
||||
|
@ -298,6 +298,10 @@ public:
|
||||
const nsACString& aGenericFamily,
|
||||
nsTArray<nsString>& aListOfFonts);
|
||||
|
||||
int GetTileWidth();
|
||||
int GetTileHeight();
|
||||
void SetTileSize(int aWidth, int aHeight);
|
||||
|
||||
/**
|
||||
* Rebuilds the any cached system font lists
|
||||
*/
|
||||
@ -666,6 +670,9 @@ private:
|
||||
// Bitmask of backend types we can use to render content
|
||||
uint32_t mContentBackendBitmask;
|
||||
|
||||
int mTileWidth;
|
||||
int mTileHeight;
|
||||
|
||||
mozilla::widget::GfxInfoCollector<gfxPlatform> mAzureCanvasBackendCollector;
|
||||
|
||||
mozilla::RefPtr<mozilla::gfx::DrawEventRecorder> mRecorder;
|
||||
|
@ -854,6 +854,9 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||
// Expand the rect by the margins
|
||||
screenRect.Inflate(aMarginsData->mMargins);
|
||||
|
||||
int alignmentX = gfxPlatform::GetPlatform()->GetTileWidth();
|
||||
int alignmentY = gfxPlatform::GetPlatform()->GetTileHeight();
|
||||
|
||||
// And then align it to the requested alignment.
|
||||
// Note on the correctness of applying the alignment in Screen space:
|
||||
// The correct space to apply the alignment in would be Layer space, but
|
||||
@ -865,7 +868,7 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||
// screen resolution; since this is what Layout does most of the time,
|
||||
// this is a good approximation. A proper solution would involve moving the
|
||||
// choosing of the resolution to display-list building time.
|
||||
if (aMarginsData->mAlignmentX > 0 || aMarginsData->mAlignmentY > 0) {
|
||||
if (alignmentX > 0 && alignmentY > 0) {
|
||||
// Inflate the rectangle by 1 so that we always push to the next tile
|
||||
// boundary. This is desirable to stop from having a rectangle with a
|
||||
// moving origin occasionally being smaller when it coincidentally lines
|
||||
@ -873,21 +876,21 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||
screenRect.Inflate(1);
|
||||
|
||||
// Avoid division by zero.
|
||||
if (aMarginsData->mAlignmentX == 0) {
|
||||
aMarginsData->mAlignmentX = 1;
|
||||
if (alignmentX == 0) {
|
||||
alignmentX = 1;
|
||||
}
|
||||
if (aMarginsData->mAlignmentY == 0) {
|
||||
aMarginsData->mAlignmentY = 1;
|
||||
if (alignmentY == 0) {
|
||||
alignmentY = 1;
|
||||
}
|
||||
|
||||
ScreenPoint scrollPosScreen = LayoutDevicePoint::FromAppUnits(scrollPos, auPerDevPixel)
|
||||
* res;
|
||||
|
||||
screenRect += scrollPosScreen;
|
||||
float x = aMarginsData->mAlignmentX * floor(screenRect.x / aMarginsData->mAlignmentX);
|
||||
float y = aMarginsData->mAlignmentY * floor(screenRect.y / aMarginsData->mAlignmentY);
|
||||
float w = aMarginsData->mAlignmentX * ceil(screenRect.XMost() / aMarginsData->mAlignmentX) - x;
|
||||
float h = aMarginsData->mAlignmentY * ceil(screenRect.YMost() / aMarginsData->mAlignmentY) - y;
|
||||
float x = alignmentX * floor(screenRect.x / alignmentX);
|
||||
float y = alignmentY * floor(screenRect.y / alignmentY);
|
||||
float w = alignmentX * ceil(screenRect.XMost() / alignmentX) - x;
|
||||
float h = alignmentY * ceil(screenRect.YMost() / alignmentY) - y;
|
||||
screenRect = ScreenRect(x, y, w, h);
|
||||
screenRect -= scrollPosScreen;
|
||||
}
|
||||
@ -957,8 +960,6 @@ void
|
||||
nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent,
|
||||
nsIPresShell* aPresShell,
|
||||
const ScreenMargin& aMargins,
|
||||
uint32_t aAlignmentX,
|
||||
uint32_t aAlignmentY,
|
||||
uint32_t aPriority,
|
||||
RepaintMode aRepaintMode)
|
||||
{
|
||||
@ -970,7 +971,7 @@ nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent,
|
||||
|
||||
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
|
||||
new DisplayPortMarginsPropertyData(
|
||||
aMargins, aAlignmentX, aAlignmentY, aPriority),
|
||||
aMargins, aPriority),
|
||||
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
|
||||
|
||||
if (nsLayoutUtils::UsesAsyncScrolling()) {
|
||||
@ -2869,12 +2870,9 @@ nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
|
||||
ScreenMargin displayportMargins = APZCTreeManager::CalculatePendingDisplayPort(
|
||||
metrics, ParentLayerPoint(0.0f, 0.0f), 0.0);
|
||||
nsIPresShell* presShell = aScrollFrame->PresContext()->GetPresShell();
|
||||
gfx::IntSize alignment = gfxPlatform::GetPlatform()->UseTiling()
|
||||
? gfx::IntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()) :
|
||||
gfx::IntSize(0, 0);
|
||||
nsLayoutUtils::SetDisplayPortMargins(
|
||||
content, presShell, displayportMargins, alignment.width,
|
||||
alignment.height, 0, nsLayoutUtils::RepaintMode::DoNotRepaint);
|
||||
content, presShell, displayportMargins,
|
||||
0, nsLayoutUtils::RepaintMode::DoNotRepaint);
|
||||
haveDisplayPort = GetDisplayPort(content, aOutDisplayport);
|
||||
NS_ASSERTION(haveDisplayPort, "should have a displayport after having just set it");
|
||||
}
|
||||
|
@ -96,16 +96,11 @@ struct DisplayPortPropertyData {
|
||||
|
||||
struct DisplayPortMarginsPropertyData {
|
||||
DisplayPortMarginsPropertyData(const ScreenMargin& aMargins,
|
||||
uint32_t aAlignmentX, uint32_t aAlignmentY,
|
||||
uint32_t aPriority)
|
||||
: mMargins(aMargins)
|
||||
, mAlignmentX(aAlignmentX)
|
||||
, mAlignmentY(aAlignmentY)
|
||||
, mPriority(aPriority)
|
||||
{}
|
||||
ScreenMargin mMargins;
|
||||
uint32_t mAlignmentX;
|
||||
uint32_t mAlignmentY;
|
||||
uint32_t mPriority;
|
||||
};
|
||||
|
||||
@ -189,8 +184,6 @@ public:
|
||||
static void SetDisplayPortMargins(nsIContent* aContent,
|
||||
nsIPresShell* aPresShell,
|
||||
const ScreenMargin& aMargins,
|
||||
uint32_t aAlignmentX,
|
||||
uint32_t aAlignmentY,
|
||||
uint32_t aPriority = 0,
|
||||
RepaintMode aRepaintMode = RepaintMode::Repaint);
|
||||
|
||||
|
@ -1877,7 +1877,6 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
|
||||
nsLayoutUtils::SetDisplayPortMargins(mOuter->GetContent(),
|
||||
mOuter->PresContext()->PresShell(),
|
||||
ScreenMargin(),
|
||||
gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight(),
|
||||
0,
|
||||
nsLayoutUtils::RepaintMode::DoNotRepaint);
|
||||
}
|
||||
|
@ -1925,18 +1925,6 @@ var BrowserApp = {
|
||||
return this.defaultBrowserWidth = width;
|
||||
},
|
||||
|
||||
get layersTileWidth() {
|
||||
delete this.layersTileWidth;
|
||||
let width = Services.prefs.getIntPref("layers.tile-width");
|
||||
return this.layersTileWidth = width;
|
||||
},
|
||||
|
||||
get layersTileHeight() {
|
||||
delete this.layersTileHeight;
|
||||
let height = Services.prefs.getIntPref("layers.tile-height");
|
||||
return this.layersTileHeight = height;
|
||||
},
|
||||
|
||||
// nsIAndroidBrowserApp
|
||||
get selectedTab() {
|
||||
return this._selectedTab;
|
||||
@ -3597,7 +3585,6 @@ Tab.prototype = {
|
||||
displayPortMargins.top,
|
||||
displayPortMargins.right,
|
||||
displayPortMargins.bottom,
|
||||
BrowserApp.layersTileWidth, BrowserApp.layersTileHeight,
|
||||
element, 0);
|
||||
}
|
||||
this._oldDisplayPortMargins = displayPortMargins;
|
||||
|
Loading…
Reference in New Issue
Block a user