mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1225007 (part 1, attempt 2) - Use LayoutDevicePixel more in Cocoa widget code. r=kats.
This commit is contained in:
parent
8b9c5c2392
commit
dc42acdb6f
@ -810,10 +810,9 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion)
|
||||
}
|
||||
|
||||
// Allow widget to render a custom foreground.
|
||||
mCompositor->GetWidget()->DrawWindowOverlay(this, IntRect(actualBounds.x,
|
||||
actualBounds.y,
|
||||
actualBounds.width,
|
||||
actualBounds.height));
|
||||
mCompositor->GetWidget()->DrawWindowOverlay(
|
||||
this, LayoutDeviceIntRect(actualBounds.x, actualBounds.y,
|
||||
actualBounds.width, actualBounds.height));
|
||||
|
||||
// Debugging
|
||||
RenderDebugOverlay(actualBounds);
|
||||
|
@ -4954,7 +4954,7 @@ ScrollFrameHelper::AdjustScrollbarRectForResizer(
|
||||
else {
|
||||
nsPoint offset;
|
||||
nsIWidget* widget = aFrame->GetNearestWidget(offset);
|
||||
nsIntRect widgetRect;
|
||||
LayoutDeviceIntRect widgetRect;
|
||||
if (!widget || !widget->ShowsResizeIndicator(&widgetRect))
|
||||
return;
|
||||
|
||||
|
@ -2636,7 +2636,8 @@ nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect)
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect)
|
||||
nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
PROFILER_LABEL("nsWindow", "DrawWindowOverlay",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
|
@ -152,7 +152,7 @@ public:
|
||||
|
||||
virtual bool NeedsPaint() override;
|
||||
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) override;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) override;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
|
||||
|
||||
virtual mozilla::layers::CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight) override;
|
||||
|
||||
|
@ -3316,8 +3316,7 @@ IMEInputHandler::FirstRectForCharacterRange(NSRange& aRange,
|
||||
if (!rootWindow || !rootView) {
|
||||
return rect;
|
||||
}
|
||||
rect = nsCocoaUtils::DevPixelsToCocoaPoints(r.ToUnknownRect(),
|
||||
mWidget->BackingScaleFactor());
|
||||
rect = nsCocoaUtils::DevPixelsToCocoaPoints(r, mWidget->BackingScaleFactor());
|
||||
rect = [rootView convertRect:rect toView:nil];
|
||||
rect.origin = [rootWindow convertBaseToScreen:rect.origin];
|
||||
|
||||
|
@ -32,7 +32,7 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType, const nsIntRegion& aReg
|
||||
for (size_t i = 0; (iterRect = iter.Next()) || i < viewsToRecycle.Length(); ++i) {
|
||||
if (iterRect) {
|
||||
NSView* view = nil;
|
||||
NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(*iterRect);
|
||||
NSRect rect = mCoordinateConverter.UntypedDevPixelsToCocoaPoints(*iterRect);
|
||||
if (i < viewsToRecycle.Length()) {
|
||||
view = viewsToRecycle[i];
|
||||
[view setFrame:rect];
|
||||
@ -72,7 +72,7 @@ VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const
|
||||
|
||||
nsIntRegionRectIterator iter(aVibrantRegion.region);
|
||||
while (const nsIntRect* rect = iter.Next()) {
|
||||
NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(*rect));
|
||||
NSRectFill(mCoordinateConverter.UntypedDevPixelsToCocoaPoints(*rect));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ public:
|
||||
virtual void* GetNativeData(uint32_t aDataType) override;
|
||||
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) override;
|
||||
virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
|
||||
|
||||
static bool ConvertStatus(nsEventStatus aStatus)
|
||||
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
||||
@ -487,12 +487,13 @@ public:
|
||||
virtual void CleanupWindowEffects() override;
|
||||
virtual bool PreRender(LayerManagerComposite* aManager) override;
|
||||
virtual void PostRender(LayerManagerComposite* aManager) override;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) override;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect) override;
|
||||
|
||||
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
|
||||
|
||||
virtual void UpdateWindowDraggingRegion(const nsIntRegion& aRegion) override;
|
||||
const nsIntRegion& GetDraggableRegion() { return mDraggableRegion; }
|
||||
const LayoutDeviceIntRegion& GetDraggableRegion() { return mDraggableRegion; }
|
||||
|
||||
virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) override;
|
||||
|
||||
@ -524,13 +525,18 @@ public:
|
||||
nsIntPoint CocoaPointsToDevPixels(const NSPoint& aPt) const {
|
||||
return nsCocoaUtils::CocoaPointsToDevPixels(aPt, BackingScaleFactor());
|
||||
}
|
||||
nsIntRect CocoaPointsToDevPixels(const NSRect& aRect) const {
|
||||
LayoutDeviceIntRect CocoaPointsToDevPixels(const NSRect& aRect) const {
|
||||
return nsCocoaUtils::CocoaPointsToDevPixels(aRect, BackingScaleFactor());
|
||||
}
|
||||
CGFloat DevPixelsToCocoaPoints(int32_t aPixels) const {
|
||||
return nsCocoaUtils::DevPixelsToCocoaPoints(aPixels, BackingScaleFactor());
|
||||
}
|
||||
NSRect DevPixelsToCocoaPoints(const nsIntRect& aRect) const {
|
||||
// XXX: all calls to this function should eventually be replaced with calls
|
||||
// to DevPixelsToCocoaPoints().
|
||||
NSRect UntypedDevPixelsToCocoaPoints(const nsIntRect& aRect) const {
|
||||
return nsCocoaUtils::UntypedDevPixelsToCocoaPoints(aRect, BackingScaleFactor());
|
||||
}
|
||||
NSRect DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect) const {
|
||||
return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor());
|
||||
}
|
||||
|
||||
@ -577,19 +583,19 @@ protected:
|
||||
void ConfigureAPZCTreeManager() override;
|
||||
void ConfigureAPZControllerThread() override;
|
||||
|
||||
void DoRemoteComposition(const nsIntRect& aRenderRect);
|
||||
void DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect);
|
||||
|
||||
// Overlay drawing functions for OpenGL drawing
|
||||
void DrawWindowOverlay(mozilla::layers::GLManager* aManager, nsIntRect aRect);
|
||||
void MaybeDrawResizeIndicator(mozilla::layers::GLManager* aManager, const nsIntRect& aRect);
|
||||
void MaybeDrawRoundedCorners(mozilla::layers::GLManager* aManager, const nsIntRect& aRect);
|
||||
void MaybeDrawTitlebar(mozilla::layers::GLManager* aManager, const nsIntRect& aRect);
|
||||
void DrawWindowOverlay(mozilla::layers::GLManager* aManager, LayoutDeviceIntRect aRect);
|
||||
void MaybeDrawResizeIndicator(mozilla::layers::GLManager* aManager);
|
||||
void MaybeDrawRoundedCorners(mozilla::layers::GLManager* aManager, const LayoutDeviceIntRect& aRect);
|
||||
void MaybeDrawTitlebar(mozilla::layers::GLManager* aManager);
|
||||
|
||||
// Redraw the contents of mTitlebarCGContext on the main thread, as
|
||||
// determined by mDirtyTitlebarRegion.
|
||||
void UpdateTitlebarCGContext();
|
||||
|
||||
nsIntRect RectContainingTitlebarControls();
|
||||
LayoutDeviceIntRect RectContainingTitlebarControls();
|
||||
void UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries);
|
||||
mozilla::VibrancyManager& EnsureVibrancyManager();
|
||||
|
||||
@ -631,16 +637,16 @@ protected:
|
||||
// May be accessed from any thread, protected
|
||||
// by mEffectsLock.
|
||||
bool mShowsResizeIndicator;
|
||||
nsIntRect mResizeIndicatorRect;
|
||||
LayoutDeviceIntRect mResizeIndicatorRect;
|
||||
bool mHasRoundedBottomCorners;
|
||||
int mDevPixelCornerRadius;
|
||||
bool mIsCoveringTitlebar;
|
||||
bool mIsFullscreen;
|
||||
nsIntRect mTitlebarRect;
|
||||
LayoutDeviceIntRect mTitlebarRect;
|
||||
|
||||
// The area of mTitlebarCGContext that needs to be redrawn during the next
|
||||
// transaction. Accessed from any thread, protected by mEffectsLock.
|
||||
nsIntRegion mUpdatedTitlebarRegion;
|
||||
LayoutDeviceIntRegion mUpdatedTitlebarRegion;
|
||||
CGContextRef mTitlebarCGContext;
|
||||
|
||||
// Compositor thread only
|
||||
@ -653,7 +659,7 @@ protected:
|
||||
// uploaded to to mTitlebarImage. Main thread only.
|
||||
nsIntRegion mDirtyTitlebarRegion;
|
||||
|
||||
nsIntRegion mDraggableRegion;
|
||||
LayoutDeviceIntRegion mDraggableRegion;
|
||||
|
||||
// Cached value of [mView backingScaleFactor], to avoid sending two obj-c
|
||||
// messages (respondsToSelector, backingScaleFactor) every time we need to
|
||||
|
@ -162,7 +162,7 @@ static uint32_t gNumberOfWidgetsNeedingEventThread = 0;
|
||||
- (void)processPendingRedraws;
|
||||
|
||||
- (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext;
|
||||
- (nsIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect;
|
||||
- (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect;
|
||||
- (BOOL)isUsingMainThreadOpenGL;
|
||||
- (BOOL)isUsingOpenGL;
|
||||
- (void)drawUsingOpenGL;
|
||||
@ -279,13 +279,15 @@ public:
|
||||
virtual ~RectTextureImage();
|
||||
|
||||
already_AddRefed<gfx::DrawTarget>
|
||||
BeginUpdate(const nsIntSize& aNewSize,
|
||||
const nsIntRegion& aDirtyRegion = nsIntRegion());
|
||||
BeginUpdate(const LayoutDeviceIntSize& aNewSize,
|
||||
const LayoutDeviceIntRegion& aDirtyRegion =
|
||||
LayoutDeviceIntRegion());
|
||||
void EndUpdate(bool aKeepSurface = false);
|
||||
|
||||
void UpdateIfNeeded(const nsIntSize& aNewSize,
|
||||
const nsIntRegion& aDirtyRegion,
|
||||
void (^aCallback)(gfx::DrawTarget*, const nsIntRegion&))
|
||||
void UpdateIfNeeded(const LayoutDeviceIntSize& aNewSize,
|
||||
const LayoutDeviceIntRegion& aDirtyRegion,
|
||||
void (^aCallback)(gfx::DrawTarget*,
|
||||
const LayoutDeviceIntRegion&))
|
||||
{
|
||||
RefPtr<gfx::DrawTarget> drawTarget = BeginUpdate(aNewSize, aDirtyRegion);
|
||||
if (drawTarget) {
|
||||
@ -294,29 +296,30 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateFromCGContext(const nsIntSize& aNewSize,
|
||||
const nsIntRegion& aDirtyRegion,
|
||||
void UpdateFromCGContext(const LayoutDeviceIntSize& aNewSize,
|
||||
const LayoutDeviceIntRegion& aDirtyRegion,
|
||||
CGContextRef aCGContext);
|
||||
|
||||
nsIntRegion GetUpdateRegion() {
|
||||
LayoutDeviceIntRegion GetUpdateRegion() {
|
||||
MOZ_ASSERT(mInUpdate, "update region only valid during update");
|
||||
return mUpdateRegion;
|
||||
}
|
||||
|
||||
void Draw(mozilla::layers::GLManager* aManager,
|
||||
const nsIntPoint& aLocation,
|
||||
const LayoutDeviceIntPoint& aLocation,
|
||||
const Matrix4x4& aTransform = Matrix4x4());
|
||||
|
||||
static nsIntSize TextureSizeForSize(const nsIntSize& aSize);
|
||||
static LayoutDeviceIntSize TextureSizeForSize(
|
||||
const LayoutDeviceIntSize& aSize);
|
||||
|
||||
protected:
|
||||
|
||||
RefPtr<gfx::DrawTarget> mUpdateDrawTarget;
|
||||
GLContext* mGLContext;
|
||||
nsIntRegion mUpdateRegion;
|
||||
nsIntSize mUsedSize;
|
||||
nsIntSize mBufferSize;
|
||||
nsIntSize mTextureSize;
|
||||
LayoutDeviceIntRegion mUpdateRegion;
|
||||
LayoutDeviceIntSize mUsedSize;
|
||||
LayoutDeviceIntSize mBufferSize;
|
||||
LayoutDeviceIntSize mTextureSize;
|
||||
GLuint mTexture;
|
||||
bool mInUpdate;
|
||||
};
|
||||
@ -356,7 +359,7 @@ public:
|
||||
const gfx::Rect& aLayerRect,
|
||||
const gfx::Rect& aTextureRect) override;
|
||||
|
||||
void BeginFrame(nsIntSize aRenderSize);
|
||||
void BeginFrame(LayoutDeviceIntSize aRenderSize);
|
||||
void EndFrame();
|
||||
|
||||
NSOpenGLContext* GetNSOpenGLContext()
|
||||
@ -513,7 +516,8 @@ nsresult nsChildView::Create(nsIWidget *aParent,
|
||||
// create our parallel NSView and hook it up to our parent. Recall
|
||||
// that NS_NATIVE_WIDGET is the NSView.
|
||||
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mParentView);
|
||||
NSRect r = nsCocoaUtils::DevPixelsToCocoaPoints(mBounds, scaleFactor);
|
||||
NSRect r = nsCocoaUtils::DevPixelsToCocoaPoints(
|
||||
LayoutDeviceIntRect::FromUnknownRect(mBounds), scaleFactor);
|
||||
mView = [(NSView<mozView>*)CreateCocoaView(r) retain];
|
||||
if (!mView) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -908,13 +912,9 @@ NS_IMETHODIMP nsChildView::SetCursor(imgIContainer* aCursor,
|
||||
// Get this component dimension
|
||||
NS_IMETHODIMP nsChildView::GetBounds(LayoutDeviceIntRect& aRect)
|
||||
{
|
||||
nsIntRect tmp;
|
||||
if (!mView) {
|
||||
tmp = mBounds;
|
||||
} else {
|
||||
tmp = CocoaPointsToDevPixels([mView frame]);
|
||||
}
|
||||
aRect = LayoutDeviceIntRect::FromUnknownRect(tmp);
|
||||
aRect = !mView
|
||||
? LayoutDeviceIntRect::FromUnknownRect(mBounds)
|
||||
: CocoaPointsToDevPixels([mView frame]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1006,7 +1006,7 @@ NS_IMETHODIMP nsChildView::Move(double aX, double aY)
|
||||
mBounds.y = y;
|
||||
|
||||
ManipulateViewWithoutNeedingDisplay(mView, ^{
|
||||
[mView setFrame:DevPixelsToCocoaPoints(mBounds)];
|
||||
[mView setFrame:UntypedDevPixelsToCocoaPoints(mBounds)];
|
||||
});
|
||||
|
||||
NotifyRollupGeometryChange();
|
||||
@ -1031,7 +1031,7 @@ NS_IMETHODIMP nsChildView::Resize(double aWidth, double aHeight, bool aRepaint)
|
||||
mBounds.height = height;
|
||||
|
||||
ManipulateViewWithoutNeedingDisplay(mView, ^{
|
||||
[mView setFrame:DevPixelsToCocoaPoints(mBounds)];
|
||||
[mView setFrame:UntypedDevPixelsToCocoaPoints(mBounds)];
|
||||
});
|
||||
|
||||
if (mVisible && aRepaint)
|
||||
@ -1070,7 +1070,7 @@ NS_IMETHODIMP nsChildView::Resize(double aX, double aY,
|
||||
}
|
||||
|
||||
ManipulateViewWithoutNeedingDisplay(mView, ^{
|
||||
[mView setFrame:DevPixelsToCocoaPoints(mBounds)];
|
||||
[mView setFrame:UntypedDevPixelsToCocoaPoints(mBounds)];
|
||||
});
|
||||
|
||||
if (mVisible && aRepaint)
|
||||
@ -1092,7 +1092,7 @@ NS_IMETHODIMP nsChildView::Resize(double aX, double aY,
|
||||
|
||||
static const int32_t resizeIndicatorWidth = 15;
|
||||
static const int32_t resizeIndicatorHeight = 15;
|
||||
bool nsChildView::ShowsResizeIndicator(nsIntRect* aResizerRect)
|
||||
bool nsChildView::ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect)
|
||||
{
|
||||
NSView *topLevelView = mView, *superView = nil;
|
||||
while ((superView = [topLevelView superview]))
|
||||
@ -1364,10 +1364,10 @@ NS_IMETHODIMP nsChildView::Invalidate(const nsIntRect &aRect)
|
||||
if ([NSView focusView]) {
|
||||
// if a view is focussed (i.e. being drawn), then postpone the invalidate so that we
|
||||
// don't lose it.
|
||||
[mView setNeedsPendingDisplayInRect:DevPixelsToCocoaPoints(aRect)];
|
||||
[mView setNeedsPendingDisplayInRect:UntypedDevPixelsToCocoaPoints(aRect)];
|
||||
}
|
||||
else {
|
||||
[mView setNeedsDisplayInRect:DevPixelsToCocoaPoints(aRect)];
|
||||
[mView setNeedsDisplayInRect:UntypedDevPixelsToCocoaPoints(aRect)];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1941,7 +1941,7 @@ nsChildView::ConfigureAPZControllerThread()
|
||||
}
|
||||
}
|
||||
|
||||
nsIntRect
|
||||
LayoutDeviceIntRect
|
||||
nsChildView::RectContainingTitlebarControls()
|
||||
{
|
||||
// Start with a thin strip at the top of the window for the highlight line.
|
||||
@ -2015,7 +2015,8 @@ nsChildView::PostRender(LayerManagerComposite* aManager)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect)
|
||||
nsChildView::DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
nsAutoPtr<GLManager> manager(GLManager::CreateGLManager(aManager));
|
||||
if (manager) {
|
||||
@ -2024,20 +2025,20 @@ nsChildView::DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::DrawWindowOverlay(GLManager* aManager, nsIntRect aRect)
|
||||
nsChildView::DrawWindowOverlay(GLManager* aManager, LayoutDeviceIntRect aRect)
|
||||
{
|
||||
GLContext* gl = aManager->gl();
|
||||
ScopedGLState scopedScissorTestState(gl, LOCAL_GL_SCISSOR_TEST, false);
|
||||
|
||||
MaybeDrawTitlebar(aManager, aRect);
|
||||
MaybeDrawResizeIndicator(aManager, aRect);
|
||||
MaybeDrawTitlebar(aManager);
|
||||
MaybeDrawResizeIndicator(aManager);
|
||||
MaybeDrawRoundedCorners(aManager, aRect);
|
||||
}
|
||||
|
||||
static void
|
||||
ClearRegion(gfx::DrawTarget *aDT, nsIntRegion aRegion)
|
||||
ClearRegion(gfx::DrawTarget *aDT, LayoutDeviceIntRegion aRegion)
|
||||
{
|
||||
gfxUtils::ClipToRegion(aDT, aRegion);
|
||||
gfxUtils::ClipToRegion(aDT, aRegion.ToUnknownRegion());
|
||||
aDT->ClearRect(gfx::Rect(0, 0, aDT->GetSize().width, aDT->GetSize().height));
|
||||
aDT->PopClip();
|
||||
}
|
||||
@ -2076,7 +2077,7 @@ DrawResizer(CGContextRef aCtx)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::MaybeDrawResizeIndicator(GLManager* aManager, const nsIntRect& aRect)
|
||||
nsChildView::MaybeDrawResizeIndicator(GLManager* aManager)
|
||||
{
|
||||
MutexAutoLock lock(mEffectsLock);
|
||||
if (!mShowsResizeIndicator) {
|
||||
@ -2087,8 +2088,8 @@ nsChildView::MaybeDrawResizeIndicator(GLManager* aManager, const nsIntRect& aRec
|
||||
mResizerImage = new RectTextureImage(aManager->gl());
|
||||
}
|
||||
|
||||
nsIntSize size = mResizeIndicatorRect.Size();
|
||||
mResizerImage->UpdateIfNeeded(size, nsIntRegion(), ^(gfx::DrawTarget* drawTarget, const nsIntRegion& updateRegion) {
|
||||
LayoutDeviceIntSize size = mResizeIndicatorRect.Size();
|
||||
mResizerImage->UpdateIfNeeded(size, LayoutDeviceIntRegion(), ^(gfx::DrawTarget* drawTarget, const LayoutDeviceIntRegion& updateRegion) {
|
||||
ClearRegion(drawTarget, updateRegion);
|
||||
gfx::BorrowedCGContext borrow(drawTarget);
|
||||
DrawResizer(borrow.cg);
|
||||
@ -2131,7 +2132,7 @@ DrawTitlebarHighlight(NSSize aWindowSize, CGFloat aRadius, CGFloat aDevicePixelW
|
||||
}
|
||||
|
||||
static CGContextRef
|
||||
CreateCGContext(const nsIntSize& aSize)
|
||||
CreateCGContext(const LayoutDeviceIntSize& aSize)
|
||||
{
|
||||
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
|
||||
CGContextRef ctx =
|
||||
@ -2164,7 +2165,8 @@ nsChildView::UpdateTitlebarCGContext()
|
||||
NSRect dirtyRect = [mView convertRect:[(BaseWindow*)[mView window] getAndResetNativeDirtyRect] fromView:nil];
|
||||
NSRect dirtyTitlebarRect = NSIntersectionRect(titlebarRect, dirtyRect);
|
||||
|
||||
nsIntSize texSize = RectTextureImage::TextureSizeForSize(mTitlebarRect.Size());
|
||||
LayoutDeviceIntSize texSize =
|
||||
RectTextureImage::TextureSizeForSize(mTitlebarRect.Size());
|
||||
if (!mTitlebarCGContext ||
|
||||
CGBitmapContextGetWidth(mTitlebarCGContext) != size_t(texSize.width) ||
|
||||
CGBitmapContextGetHeight(mTitlebarCGContext) != size_t(texSize.height)) {
|
||||
@ -2285,14 +2287,14 @@ nsChildView::UpdateTitlebarCGContext()
|
||||
// GLContext surface. In order to make the titlebar controls visible, we have
|
||||
// to redraw them inside the OpenGL context surface.
|
||||
void
|
||||
nsChildView::MaybeDrawTitlebar(GLManager* aManager, const nsIntRect& aRect)
|
||||
nsChildView::MaybeDrawTitlebar(GLManager* aManager)
|
||||
{
|
||||
MutexAutoLock lock(mEffectsLock);
|
||||
if (!mIsCoveringTitlebar || mIsFullscreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIntRegion updatedTitlebarRegion;
|
||||
LayoutDeviceIntRegion updatedTitlebarRegion;
|
||||
updatedTitlebarRegion.And(mUpdatedTitlebarRegion, mTitlebarRect);
|
||||
mUpdatedTitlebarRegion.SetEmpty();
|
||||
|
||||
@ -2315,7 +2317,8 @@ DrawTopLeftCornerMask(CGContextRef aCtx, int aRadius)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::MaybeDrawRoundedCorners(GLManager* aManager, const nsIntRect& aRect)
|
||||
nsChildView::MaybeDrawRoundedCorners(GLManager* aManager,
|
||||
const LayoutDeviceIntRect& aRect)
|
||||
{
|
||||
MutexAutoLock lock(mEffectsLock);
|
||||
|
||||
@ -2323,8 +2326,8 @@ nsChildView::MaybeDrawRoundedCorners(GLManager* aManager, const nsIntRect& aRect
|
||||
mCornerMaskImage = new RectTextureImage(aManager->gl());
|
||||
}
|
||||
|
||||
nsIntSize size(mDevPixelCornerRadius, mDevPixelCornerRadius);
|
||||
mCornerMaskImage->UpdateIfNeeded(size, nsIntRegion(), ^(gfx::DrawTarget* drawTarget, const nsIntRegion& updateRegion) {
|
||||
LayoutDeviceIntSize size(mDevPixelCornerRadius, mDevPixelCornerRadius);
|
||||
mCornerMaskImage->UpdateIfNeeded(size, LayoutDeviceIntRegion(), ^(gfx::DrawTarget* drawTarget, const LayoutDeviceIntRegion& updateRegion) {
|
||||
ClearRegion(drawTarget, updateRegion);
|
||||
RefPtr<gfx::PathBuilder> builder = drawTarget->CreatePathBuilder();
|
||||
builder->Arc(gfx::Point(mDevPixelCornerRadius, mDevPixelCornerRadius), mDevPixelCornerRadius, 0, 2.0f * M_PI);
|
||||
@ -2392,17 +2395,17 @@ FindUnifiedToolbarBottom(const nsTArray<nsIWidget::ThemeGeometry>& aThemeGeometr
|
||||
return unifiedToolbarBottom;
|
||||
}
|
||||
|
||||
static nsIntRect
|
||||
static LayoutDeviceIntRect
|
||||
FindFirstRectOfType(const nsTArray<nsIWidget::ThemeGeometry>& aThemeGeometries,
|
||||
nsITheme::ThemeGeometryType aThemeGeometryType)
|
||||
{
|
||||
for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) {
|
||||
const nsIWidget::ThemeGeometry& g = aThemeGeometries[i];
|
||||
if (g.mType == aThemeGeometryType) {
|
||||
return g.mRect;
|
||||
return LayoutDeviceIntRect::FromUnknownRect(g.mRect);
|
||||
}
|
||||
}
|
||||
return nsIntRect();
|
||||
return LayoutDeviceIntRect();
|
||||
}
|
||||
|
||||
void
|
||||
@ -2434,9 +2437,9 @@ nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometri
|
||||
[win setSheetAttachmentPosition:DevPixelsToCocoaPoints(devSheetPosition)];
|
||||
|
||||
// Update titlebar control offsets.
|
||||
nsIntRect windowButtonRect = FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeWindowButtons);
|
||||
LayoutDeviceIntRect windowButtonRect = FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeWindowButtons);
|
||||
[win placeWindowButtons:[mView convertRect:DevPixelsToCocoaPoints(windowButtonRect) toView:nil]];
|
||||
nsIntRect fullScreenButtonRect = FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeFullscreenButton);
|
||||
LayoutDeviceIntRect fullScreenButtonRect = FindFirstRectOfType(aThemeGeometries, nsNativeThemeCocoa::eThemeGeometryTypeFullscreenButton);
|
||||
[win placeFullScreenButton:[mView convertRect:DevPixelsToCocoaPoints(fullScreenButtonRect) toView:nil]];
|
||||
}
|
||||
|
||||
@ -2632,8 +2635,9 @@ nsChildView::StartRemoteDrawing()
|
||||
}
|
||||
}
|
||||
|
||||
nsIntRegion dirtyRegion = mBounds;
|
||||
nsIntSize renderSize = mBounds.Size();
|
||||
LayoutDeviceIntRegion dirtyRegion(LayoutDeviceIntRect::FromUnknownRect(mBounds));
|
||||
LayoutDeviceIntSize renderSize =
|
||||
LayoutDeviceIntSize::FromUnknownSize(mBounds.Size());
|
||||
|
||||
if (!mBasicCompositorImage) {
|
||||
mBasicCompositorImage = new RectTextureImage(mGLPresenter->gl());
|
||||
@ -2644,7 +2648,7 @@ nsChildView::StartRemoteDrawing()
|
||||
|
||||
if (!drawTarget) {
|
||||
// Composite unchanged textures.
|
||||
DoRemoteComposition(mBounds);
|
||||
DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2655,7 +2659,7 @@ void
|
||||
nsChildView::EndRemoteDrawing()
|
||||
{
|
||||
mBasicCompositorImage->EndUpdate(true);
|
||||
DoRemoteComposition(mBounds);
|
||||
DoRemoteComposition(LayoutDeviceIntRect::FromUnknownRect(mBounds));
|
||||
}
|
||||
|
||||
void
|
||||
@ -2682,7 +2686,7 @@ nsChildView::InitCompositor(Compositor* aCompositor)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::DoRemoteComposition(const nsIntRect& aRenderRect)
|
||||
nsChildView::DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect)
|
||||
{
|
||||
if (![(ChildView*)mView preRender:mGLPresenter->GetNSOpenGLContext()]) {
|
||||
return;
|
||||
@ -2690,7 +2694,7 @@ nsChildView::DoRemoteComposition(const nsIntRect& aRenderRect)
|
||||
mGLPresenter->BeginFrame(aRenderRect.Size());
|
||||
|
||||
// Draw the result from the basic compositor.
|
||||
mBasicCompositorImage->Draw(mGLPresenter, nsIntPoint(0, 0));
|
||||
mBasicCompositorImage->Draw(mGLPresenter, LayoutDeviceIntPoint(0, 0));
|
||||
|
||||
// DrawWindowOverlay doesn't do anything for non-GL, so it didn't paint
|
||||
// anything during the basic compositor transaction. Draw the overlay now.
|
||||
@ -2704,8 +2708,10 @@ nsChildView::DoRemoteComposition(const nsIntRect& aRenderRect)
|
||||
void
|
||||
nsChildView::UpdateWindowDraggingRegion(const nsIntRegion& aRegion)
|
||||
{
|
||||
if (mDraggableRegion != aRegion) {
|
||||
mDraggableRegion = aRegion;
|
||||
LayoutDeviceIntRegion region =
|
||||
LayoutDeviceIntRegion::FromUnknownRegion(aRegion);
|
||||
if (mDraggableRegion != region) {
|
||||
mDraggableRegion = region;
|
||||
[(ChildView*)mView updateWindowDraggableState];
|
||||
}
|
||||
}
|
||||
@ -2875,29 +2881,30 @@ RectTextureImage::~RectTextureImage()
|
||||
}
|
||||
}
|
||||
|
||||
nsIntSize
|
||||
RectTextureImage::TextureSizeForSize(const nsIntSize& aSize)
|
||||
LayoutDeviceIntSize
|
||||
RectTextureImage::TextureSizeForSize(const LayoutDeviceIntSize& aSize)
|
||||
{
|
||||
return nsIntSize(gfx::NextPowerOfTwo(aSize.width),
|
||||
gfx::NextPowerOfTwo(aSize.height));
|
||||
return LayoutDeviceIntSize(gfx::NextPowerOfTwo(aSize.width),
|
||||
gfx::NextPowerOfTwo(aSize.height));
|
||||
}
|
||||
|
||||
already_AddRefed<gfx::DrawTarget>
|
||||
RectTextureImage::BeginUpdate(const nsIntSize& aNewSize,
|
||||
const nsIntRegion& aDirtyRegion)
|
||||
RectTextureImage::BeginUpdate(const LayoutDeviceIntSize& aNewSize,
|
||||
const LayoutDeviceIntRegion& aDirtyRegion)
|
||||
{
|
||||
MOZ_ASSERT(!mInUpdate, "Beginning update during update!");
|
||||
mUpdateRegion = aDirtyRegion;
|
||||
if (aNewSize != mUsedSize) {
|
||||
mUsedSize = aNewSize;
|
||||
mUpdateRegion = gfx::IntRect(gfx::IntPoint(0, 0), aNewSize);
|
||||
mUpdateRegion =
|
||||
LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0), aNewSize);
|
||||
}
|
||||
|
||||
if (mUpdateRegion.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIntSize neededBufferSize = TextureSizeForSize(mUsedSize);
|
||||
LayoutDeviceIntSize neededBufferSize = TextureSizeForSize(mUsedSize);
|
||||
if (!mUpdateDrawTarget || mBufferSize != neededBufferSize) {
|
||||
gfx::IntSize size(neededBufferSize.width, neededBufferSize.height);
|
||||
mUpdateDrawTarget =
|
||||
@ -2926,14 +2933,15 @@ RectTextureImage::EndUpdate(bool aKeepSurface)
|
||||
MOZ_ASSERT(mInUpdate, "Ending update while not in update");
|
||||
|
||||
bool overwriteTexture = false;
|
||||
nsIntRegion updateRegion = mUpdateRegion;
|
||||
LayoutDeviceIntRegion updateRegion = mUpdateRegion;
|
||||
if (!mTexture || (mTextureSize != mBufferSize)) {
|
||||
overwriteTexture = true;
|
||||
mTextureSize = mBufferSize;
|
||||
}
|
||||
|
||||
if (overwriteTexture || !CanUploadSubtextures()) {
|
||||
updateRegion = gfx::IntRect(gfx::IntPoint(0, 0), mTextureSize);
|
||||
updateRegion =
|
||||
LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0), mTextureSize);
|
||||
}
|
||||
|
||||
RefPtr<gfx::SourceSurface> snapshot = mUpdateDrawTarget->Snapshot();
|
||||
@ -2941,10 +2949,10 @@ RectTextureImage::EndUpdate(bool aKeepSurface)
|
||||
|
||||
UploadSurfaceToTexture(mGLContext,
|
||||
dataSnapshot,
|
||||
updateRegion,
|
||||
updateRegion.ToUnknownRegion(),
|
||||
mTexture,
|
||||
overwriteTexture,
|
||||
updateRegion.GetBounds().TopLeft(),
|
||||
updateRegion.GetBounds().TopLeft().ToUnknownPoint(),
|
||||
false,
|
||||
LOCAL_GL_TEXTURE0,
|
||||
LOCAL_GL_TEXTURE_RECTANGLE_ARB);
|
||||
@ -2957,8 +2965,8 @@ RectTextureImage::EndUpdate(bool aKeepSurface)
|
||||
}
|
||||
|
||||
void
|
||||
RectTextureImage::UpdateFromCGContext(const nsIntSize& aNewSize,
|
||||
const nsIntRegion& aDirtyRegion,
|
||||
RectTextureImage::UpdateFromCGContext(const LayoutDeviceIntSize& aNewSize,
|
||||
const LayoutDeviceIntRegion& aDirtyRegion,
|
||||
CGContextRef aCGContext)
|
||||
{
|
||||
gfx::IntSize size = gfx::IntSize(CGBitmapContextGetWidth(aCGContext),
|
||||
@ -2967,7 +2975,7 @@ RectTextureImage::UpdateFromCGContext(const nsIntSize& aNewSize,
|
||||
RefPtr<gfx::DrawTarget> dt = BeginUpdate(aNewSize, aDirtyRegion);
|
||||
if (dt) {
|
||||
gfx::Rect rect(0, 0, size.width, size.height);
|
||||
gfxUtils::ClipToRegion(dt, GetUpdateRegion());
|
||||
gfxUtils::ClipToRegion(dt, GetUpdateRegion().ToUnknownRegion());
|
||||
RefPtr<gfx::SourceSurface> sourceSurface =
|
||||
dt->CreateSourceSurfaceFromData(static_cast<uint8_t *>(CGBitmapContextGetData(aCGContext)),
|
||||
size,
|
||||
@ -2983,7 +2991,7 @@ RectTextureImage::UpdateFromCGContext(const nsIntSize& aNewSize,
|
||||
|
||||
void
|
||||
RectTextureImage::Draw(GLManager* aManager,
|
||||
const nsIntPoint& aLocation,
|
||||
const LayoutDeviceIntPoint& aLocation,
|
||||
const Matrix4x4& aTransform)
|
||||
{
|
||||
ShaderProgramOGL* program = aManager->GetProgram(LOCAL_GL_TEXTURE_RECTANGLE_ARB,
|
||||
@ -3076,7 +3084,7 @@ GLPresenter::BindAndDrawQuad(ShaderProgramOGL *aProgram,
|
||||
}
|
||||
|
||||
void
|
||||
GLPresenter::BeginFrame(nsIntSize aRenderSize)
|
||||
GLPresenter::BeginFrame(LayoutDeviceIntSize aRenderSize)
|
||||
{
|
||||
mGLContext->MakeCurrent();
|
||||
|
||||
@ -3610,9 +3618,9 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
return mGeckoChild->VibrancyFontSmoothingBackgroundColorForThemeGeometryType(aThemeGeometryType);
|
||||
}
|
||||
|
||||
- (nsIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect
|
||||
- (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect
|
||||
{
|
||||
nsIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
|
||||
LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
|
||||
const NSRect *rects;
|
||||
NSInteger count;
|
||||
[self getRectsBeingDrawn:&rects count:&count];
|
||||
@ -3621,7 +3629,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
return boundingRect;
|
||||
}
|
||||
|
||||
nsIntRegion region;
|
||||
LayoutDeviceIntRegion region;
|
||||
for (NSInteger i = 0; i < count; ++i) {
|
||||
region.Or(region, mGeckoChild->CocoaPointsToDevPixels(rects[i]));
|
||||
}
|
||||
@ -3698,7 +3706,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
|
||||
CGContextSaveGState(aContext);
|
||||
|
||||
nsIntRegion region = [self nativeDirtyRegionWithBoundingRect:aRect];
|
||||
LayoutDeviceIntRegion region = [self nativeDirtyRegionWithBoundingRect:aRect];
|
||||
|
||||
// Create Cairo objects.
|
||||
RefPtr<gfxQuartzSurface> targetSurface;
|
||||
@ -3712,7 +3720,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
RefPtr<gfxContext> targetContext = new gfxContext(dt);
|
||||
|
||||
// Set up the clip region.
|
||||
nsIntRegionRectIterator iter(region);
|
||||
nsIntRegionRectIterator iter(region.ToUnknownRegion());
|
||||
targetContext->NewPath();
|
||||
for (;;) {
|
||||
const nsIntRect* r = iter.Next();
|
||||
@ -3727,10 +3735,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
if (mGeckoChild->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {
|
||||
nsBaseWidget::AutoLayerManagerSetup
|
||||
setupLayerManager(mGeckoChild, targetContext, BufferMode::BUFFER_NONE);
|
||||
painted = mGeckoChild->PaintWindow(region);
|
||||
painted = mGeckoChild->PaintWindow(region.ToUnknownRegion());
|
||||
} else if (mGeckoChild->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
|
||||
// We only need this so that we actually get DidPaintWindow fired
|
||||
painted = mGeckoChild->PaintWindow(region);
|
||||
painted = mGeckoChild->PaintWindow(region.ToUnknownRegion());
|
||||
}
|
||||
|
||||
targetContext = nullptr;
|
||||
@ -4589,7 +4597,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
|
||||
static CGSRegionObj
|
||||
NewCGSRegionFromRegion(const nsIntRegion& aRegion,
|
||||
CGRect (^aRectConverter)(const nsIntRect&))
|
||||
CGRect (^aRectConverter)(const LayoutDeviceIntRect&))
|
||||
{
|
||||
nsTArray<CGRect> rects;
|
||||
nsIntRegionRectIterator iter(aRegion);
|
||||
@ -4597,7 +4605,7 @@ NewCGSRegionFromRegion(const nsIntRegion& aRegion,
|
||||
const nsIntRect* r = iter.Next();
|
||||
if (!r)
|
||||
break;
|
||||
rects.AppendElement(aRectConverter(*r));
|
||||
rects.AppendElement(aRectConverter(LayoutDeviceIntRect::FromUnknownRect(*r)));
|
||||
}
|
||||
|
||||
CGSRegionObj region;
|
||||
@ -4615,12 +4623,12 @@ NewCGSRegionFromRegion(const nsIntRegion& aRegion,
|
||||
return [super _regionForOpaqueDescendants:aRect forMove:aForMove];
|
||||
}
|
||||
|
||||
nsIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
|
||||
LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
|
||||
|
||||
nsIntRegion opaqueRegion;
|
||||
LayoutDeviceIntRegion opaqueRegion;
|
||||
opaqueRegion.Sub(boundingRect, mGeckoChild->GetDraggableRegion());
|
||||
|
||||
return NewCGSRegionFromRegion(opaqueRegion, ^(const nsIntRect& r) {
|
||||
return NewCGSRegionFromRegion(opaqueRegion.ToUnknownRegion(), ^(const LayoutDeviceIntRect& r) {
|
||||
return [self convertToFlippedWindowCoordinates:mGeckoChild->DevPixelsToCocoaPoints(r)];
|
||||
});
|
||||
}
|
||||
|
@ -129,6 +129,7 @@ struct KeyBindingsCommand
|
||||
class nsCocoaUtils
|
||||
{
|
||||
typedef mozilla::gfx::SourceSurface SourceSurface;
|
||||
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
|
||||
|
||||
public:
|
||||
|
||||
@ -159,13 +160,13 @@ public:
|
||||
NSToIntRound(aPt.y * aBackingScale));
|
||||
}
|
||||
|
||||
static nsIntRect
|
||||
static LayoutDeviceIntRect
|
||||
CocoaPointsToDevPixels(const NSRect& aRect, CGFloat aBackingScale)
|
||||
{
|
||||
return nsIntRect(NSToIntRound(aRect.origin.x * aBackingScale),
|
||||
NSToIntRound(aRect.origin.y * aBackingScale),
|
||||
NSToIntRound(aRect.size.width * aBackingScale),
|
||||
NSToIntRound(aRect.size.height * aBackingScale));
|
||||
return LayoutDeviceIntRect(NSToIntRound(aRect.origin.x * aBackingScale),
|
||||
NSToIntRound(aRect.origin.y * aBackingScale),
|
||||
NSToIntRound(aRect.size.width * aBackingScale),
|
||||
NSToIntRound(aRect.size.height * aBackingScale));
|
||||
}
|
||||
|
||||
static CGFloat
|
||||
@ -182,8 +183,20 @@ public:
|
||||
(CGFloat)aPt.y / aBackingScale);
|
||||
}
|
||||
|
||||
// XXX: all calls to this function should eventually be replaced with calls
|
||||
// to DevPixelsToCocoaPoints().
|
||||
static NSRect
|
||||
DevPixelsToCocoaPoints(const nsIntRect& aRect, CGFloat aBackingScale)
|
||||
UntypedDevPixelsToCocoaPoints(const nsIntRect& aRect, CGFloat aBackingScale)
|
||||
{
|
||||
return NSMakeRect((CGFloat)aRect.x / aBackingScale,
|
||||
(CGFloat)aRect.y / aBackingScale,
|
||||
(CGFloat)aRect.width / aBackingScale,
|
||||
(CGFloat)aRect.height / aBackingScale);
|
||||
}
|
||||
|
||||
static NSRect
|
||||
DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect,
|
||||
CGFloat aBackingScale)
|
||||
{
|
||||
return NSMakeRect((CGFloat)aRect.x / aBackingScale,
|
||||
(CGFloat)aRect.y / aBackingScale,
|
||||
@ -217,8 +230,8 @@ public:
|
||||
// See explanation for geckoRectToCocoaRect, guess what this does...
|
||||
static nsIntRect CocoaRectToGeckoRect(const NSRect &cocoaRect);
|
||||
|
||||
static nsIntRect CocoaRectToGeckoRectDevPix(const NSRect &aCocoaRect,
|
||||
CGFloat aBackingScale);
|
||||
static mozilla::LayoutDeviceIntRect CocoaRectToGeckoRectDevPix(
|
||||
const NSRect& aCocoaRect, CGFloat aBackingScale);
|
||||
|
||||
// Gives the location for the event in screen coordinates. Do not call this
|
||||
// unless the window the event was originally targeted at is still alive!
|
||||
|
@ -97,10 +97,10 @@ nsIntRect nsCocoaUtils::CocoaRectToGeckoRect(const NSRect &cocoaRect)
|
||||
return rect;
|
||||
}
|
||||
|
||||
nsIntRect nsCocoaUtils::CocoaRectToGeckoRectDevPix(const NSRect &aCocoaRect,
|
||||
CGFloat aBackingScale)
|
||||
LayoutDeviceIntRect nsCocoaUtils::CocoaRectToGeckoRectDevPix(
|
||||
const NSRect& aCocoaRect, CGFloat aBackingScale)
|
||||
{
|
||||
nsIntRect rect;
|
||||
LayoutDeviceIntRect rect;
|
||||
rect.x = NSToIntRound(aCocoaRect.origin.x * aBackingScale);
|
||||
rect.y = NSToIntRound(FlippedScreenY(aCocoaRect.origin.y + aCocoaRect.size.height) * aBackingScale);
|
||||
rect.width = NSToIntRound((aCocoaRect.origin.x + aCocoaRect.size.width) * aBackingScale) - rect.x;
|
||||
|
@ -1573,8 +1573,7 @@ NS_IMETHODIMP nsCocoaWindow::GetClientBounds(mozilla::LayoutDeviceIntRect& aRect
|
||||
|
||||
CGFloat scaleFactor = BackingScaleFactor();
|
||||
if (!mWindow) {
|
||||
aRect = LayoutDeviceIntRect::FromUnknownRect(
|
||||
nsCocoaUtils::CocoaRectToGeckoRectDevPix(NSZeroRect, scaleFactor));
|
||||
aRect = nsCocoaUtils::CocoaRectToGeckoRectDevPix(NSZeroRect, scaleFactor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1586,8 +1585,7 @@ NS_IMETHODIMP nsCocoaWindow::GetClientBounds(mozilla::LayoutDeviceIntRect& aRect
|
||||
r = [mWindow contentRectForFrameRect:[mWindow frame]];
|
||||
}
|
||||
|
||||
aRect = LayoutDeviceIntRect::FromUnknownRect(
|
||||
nsCocoaUtils::CocoaRectToGeckoRectDevPix(r, scaleFactor));
|
||||
aRect = nsCocoaUtils::CocoaRectToGeckoRectDevPix(r, scaleFactor);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@ -1601,7 +1599,8 @@ nsCocoaWindow::UpdateBounds()
|
||||
if (mWindow) {
|
||||
frame = [mWindow frame];
|
||||
}
|
||||
mBounds = nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
|
||||
mBounds = nsCocoaUtils::CocoaRectToGeckoRectDevPix(
|
||||
frame, BackingScaleFactor()).ToUnknownRect();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(LayoutDeviceIntRect &aRect)
|
||||
@ -1609,8 +1608,8 @@ NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(LayoutDeviceIntRect &aRect)
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
#ifdef DEBUG
|
||||
nsIntRect r = nsCocoaUtils::CocoaRectToGeckoRectDevPix([mWindow frame], BackingScaleFactor());
|
||||
NS_ASSERTION(mWindow && mBounds == r, "mBounds out of sync!");
|
||||
LayoutDeviceIntRect r = nsCocoaUtils::CocoaRectToGeckoRectDevPix([mWindow frame], BackingScaleFactor());
|
||||
NS_ASSERTION(mWindow && mBounds == r.ToUnknownRect(), "mBounds out of sync!");
|
||||
#endif
|
||||
|
||||
aRect = LayoutDeviceIntRect::FromUnknownRect(mBounds);
|
||||
@ -1986,13 +1985,13 @@ LayoutDeviceIntPoint nsCocoaWindow::WidgetToScreenOffset()
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
NSRect rect = NSZeroRect;
|
||||
nsIntRect r;
|
||||
LayoutDeviceIntRect r;
|
||||
if (mWindow) {
|
||||
rect = [mWindow contentRectForFrameRect:[mWindow frame]];
|
||||
}
|
||||
r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(rect, BackingScaleFactor());
|
||||
|
||||
return LayoutDeviceIntPoint::FromUnknownPoint(r.TopLeft());
|
||||
return r.TopLeft();
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0,0));
|
||||
}
|
||||
@ -2019,12 +2018,12 @@ nsCocoaWindow::ClientToWindowSize(const LayoutDeviceIntSize& aClientSize)
|
||||
return LayoutDeviceIntSize(0, 0);
|
||||
|
||||
CGFloat backingScale = BackingScaleFactor();
|
||||
nsIntRect r(0, 0, aClientSize.width, aClientSize.height);
|
||||
LayoutDeviceIntRect r(0, 0, aClientSize.width, aClientSize.height);
|
||||
NSRect rect = nsCocoaUtils::DevPixelsToCocoaPoints(r, backingScale);
|
||||
|
||||
NSRect inflatedRect = [mWindow frameRectForContentRect:rect];
|
||||
r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(inflatedRect, backingScale);
|
||||
return LayoutDeviceIntSize(r.width, r.height);
|
||||
return r.Size();
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntSize(0,0));
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ nsScreenCocoa::GetRect(int32_t *outX, int32_t *outY, int32_t *outWidth, int32_t
|
||||
{
|
||||
NSRect frame = [mScreen frame];
|
||||
|
||||
nsIntRect r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
|
||||
LayoutDeviceIntRect r =
|
||||
nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
|
||||
|
||||
*outX = r.x;
|
||||
*outY = r.y;
|
||||
@ -59,7 +60,8 @@ nsScreenCocoa::GetAvailRect(int32_t *outX, int32_t *outY, int32_t *outWidth, int
|
||||
{
|
||||
NSRect frame = [mScreen visibleFrame];
|
||||
|
||||
nsIntRect r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
|
||||
LayoutDeviceIntRect r =
|
||||
nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
|
||||
|
||||
*outX = r.x;
|
||||
*outY = r.y;
|
||||
|
@ -1479,7 +1479,7 @@ nsBaseWidget::SetWindowTitlebarColor(nscolor aColor, bool aActive)
|
||||
}
|
||||
|
||||
bool
|
||||
nsBaseWidget::ShowsResizeIndicator(nsIntRect* aResizerRect)
|
||||
nsBaseWidget::ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public:
|
||||
virtual bool PreRender(LayerManagerComposite* aManager) override { return true; }
|
||||
virtual void PostRender(LayerManagerComposite* aManager) override {}
|
||||
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) override {}
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) override {}
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override {}
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawing() override;
|
||||
virtual void EndRemoteDrawing() override { };
|
||||
virtual void CleanupRemoteDrawing() override { };
|
||||
@ -202,7 +202,7 @@ public:
|
||||
NS_IMETHOD SetIcon(const nsAString &anIconSpec) override;
|
||||
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) override;
|
||||
virtual void SetDrawsInTitlebar(bool aState) override {}
|
||||
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) override;
|
||||
virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
|
||||
virtual void FreeNativeData(void * data, uint32_t aDataType) override {}
|
||||
NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
|
||||
int32_t aHorizontal,
|
||||
|
@ -335,6 +335,7 @@ class nsIWidget : public nsISupports {
|
||||
typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
|
||||
typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
|
||||
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
|
||||
typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
|
||||
typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
|
||||
|
||||
// Used in UpdateThemeGeometries.
|
||||
@ -1258,7 +1259,8 @@ class nsIWidget : public nsISupports {
|
||||
*
|
||||
* Always called from the compositing thread.
|
||||
*/
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect) = 0;
|
||||
|
||||
/**
|
||||
* Return a DrawTarget for the window which can be composited into.
|
||||
@ -1500,7 +1502,7 @@ class nsIWidget : public nsISupports {
|
||||
* @param aResizerRect The resizer's rect in device pixels.
|
||||
* @return Whether a resize widget is shown.
|
||||
*/
|
||||
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) = 0;
|
||||
virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
|
||||
|
||||
/**
|
||||
* Return the popup that was last rolled up, or null if there isn't one.
|
||||
|
Loading…
Reference in New Issue
Block a user