Bug 1128934 - Avoid calling GetClientBounds from BasicComposior. r=roc, karlt

This commit is contained in:
Nicolas Silva 2015-02-14 12:37:32 +01:00
parent ebc0b4e8e0
commit b4be8e1bd4
4 changed files with 27 additions and 8 deletions

View File

@ -398,18 +398,13 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
gfx::Rect *aClipRectOut /* = nullptr */,
gfx::Rect *aRenderBoundsOut /* = nullptr */)
{
nsIntRect intRect;
mWidget->GetClientBounds(intRect);
mWidgetSize = gfx::ToIntSize(intRect.Size());
// The result of GetClientBounds is shifted over by the size of the window
// manager styling. We want to ignore that.
intRect.MoveTo(0, 0);
mWidgetSize = mWidget->GetClientSize();
IntRect intRect = gfx::IntRect(IntPoint(), mWidgetSize);
Rect rect = Rect(0, 0, intRect.width, intRect.height);
// Sometimes the invalid region is larger than we want to draw.
nsIntRegion invalidRegionSafe;
invalidRegionSafe.And(aInvalidRegion, intRect);
invalidRegionSafe.And(aInvalidRegion, gfx::ThebesIntRect(intRect));
nsIntRect invalidRect = invalidRegionSafe.GetBounds();
mInvalidRect = IntRect(invalidRect.x, invalidRect.y, invalidRect.width, invalidRect.height);

View File

@ -11,6 +11,8 @@
#include "mozilla/TextEvents.h"
#include <algorithm>
#include "GeckoProfiler.h"
#include "prlink.h"
#include "nsGTKToolkit.h"
#include "nsIRollupListener.h"
@ -1523,6 +1525,12 @@ nsWindow::GetScreenBounds(nsIntRect &aRect)
return NS_OK;
}
gfx::IntSize
nsWindow::GetClientSize()
{
return gfx::IntSize(mBounds.width, mBounds.height);
}
NS_IMETHODIMP
nsWindow::GetClientBounds(nsIntRect &aRect)
{
@ -1538,6 +1546,8 @@ nsWindow::GetClientBounds(nsIntRect &aRect)
nsIntPoint
nsWindow::GetClientOffset()
{
PROFILER_LABEL("nsWindow", "GetClientOffset", js::ProfileEntry::Category::GRAPHICS);
if (!mIsTopLevel) {
return nsIntPoint(0, 0);
}

View File

@ -126,6 +126,7 @@ public:
NS_IMETHOD SetFocus(bool aRaise = false) MOZ_OVERRIDE;
NS_IMETHOD GetScreenBounds(nsIntRect &aRect) MOZ_OVERRIDE;
NS_IMETHOD GetClientBounds(nsIntRect &aRect) MOZ_OVERRIDE;
virtual gfx::IntSize GetClientSize() MOZ_OVERRIDE;
virtual nsIntPoint GetClientOffset() MOZ_OVERRIDE;
NS_IMETHOD SetCursor(nsCursor aCursor) MOZ_OVERRIDE;
NS_IMETHOD SetCursor(imgIContainer* aCursor,

View File

@ -23,6 +23,7 @@
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
#include "Units.h"
#include "mozilla/gfx/Point.h"
// forward declarations
class nsFontMetrics;
@ -1276,6 +1277,18 @@ class nsIWidget : public nsISupports {
*/
virtual nsIntPoint GetClientOffset() = 0;
/**
* Equivalent to GetClientBounds but only returns the size.
*/
virtual mozilla::gfx::IntSize GetClientSize() {
// Dependeing on the backend, overloading this method may be useful if
// if requesting the client offset is expensive.
nsIntRect rect;
GetClientBounds(rect);
return mozilla::gfx::IntSize(rect.width, rect.height);
}
/**
* Set the background color for this widget
*