Bug 793365: Make sure (again) that the entire buffer is valid when we might be asynchronously composited. r=roc

This commit is contained in:
Chris Jones
2012-09-24 21:15:18 -07:00
parent 152314f881
commit 30ee4bd1d9
5 changed files with 36 additions and 8 deletions

View File

@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/TabChild.h"
#include "mozilla/layers/PLayerChild.h"
#include "mozilla/layers/PLayersChild.h"
#include "mozilla/layers/PLayersParent.h"
@@ -25,6 +26,7 @@
#include "mozilla/Preferences.h"
#include "nsIWidget.h"
using namespace mozilla::dom;
using namespace mozilla::gfx;
namespace mozilla {
@@ -215,6 +217,7 @@ BasicLayerManager::BasicLayerManager(nsIWidget* aWidget) :
, mDoubleBuffering(BUFFER_NONE), mUsingDefaultTarget(false)
, mCachedSurfaceInUse(false)
, mTransactionIncomplete(false)
, mCompositorMightResample(false)
{
MOZ_COUNT_CTOR(BasicLayerManager);
NS_ASSERTION(aWidget, "Must provide a widget");
@@ -1090,6 +1093,17 @@ BasicShadowLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
if (HasShadowManager()) {
ShadowLayerForwarder::BeginTransaction(mTargetBounds, mTargetRotation);
// If we're drawing on behalf of a context with async pan/zoom
// enabled, then the entire buffer of thebes layers might be
// composited (including resampling) asynchronously before we get
// a chance to repaint, so we have to ensure that it's all valid
// and not rotated.
if (mWidget) {
if (TabChild* window = mWidget->GetOwningTabChild()) {
mCompositorMightResample = window->IsAsyncPanZoomEnabled();
}
}
// If we have a non-default target, we need to let our shadow manager draw
// to it. This will happen at the end of the transaction.
if (aTarget && (aTarget != mDefaultTarget) &&

View File

@@ -153,6 +153,7 @@ public:
virtual bool IsCompositingCheap() { return false; }
virtual int32_t GetMaxTextureSize() const { return PR_INT32_MAX; }
bool CompositorMightResample() { return mCompositorMightResample; }
protected:
enum TransactionPhase {
@@ -204,6 +205,7 @@ protected:
bool mUsingDefaultTarget;
bool mCachedSurfaceInUse;
bool mTransactionIncomplete;
bool mCompositorMightResample;
};

View File

@@ -4,11 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BasicThebesLayer.h"
#include "gfxUtils.h"
#include "nsIWidget.h"
#include "RenderTrace.h"
#include "sampler.h"
#include "gfxUtils.h"
#include "prprf.h"
@@ -156,12 +155,17 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
{
uint32_t flags = 0;
#ifndef MOZ_GFX_OPTIMIZE_MOBILE
#ifndef MOZ_WIDGET_ANDROID
if (BasicManager()->CompositorMightResample()) {
flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
}
if (!(flags & ThebesLayerBuffer::PAINT_WILL_RESAMPLE)) {
gfxMatrix transform;
if (!GetEffectiveTransform().CanDraw2D(&transform) ||
transform.HasNonIntegerTranslation()) {
flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
}
}
#endif
if (mDrawAtomically) {
flags |= ThebesLayerBuffer::PAINT_NO_ROTATION;

View File

@@ -1623,6 +1623,12 @@ class nsIWidget : public nsISupports {
*/
virtual const SizeConstraints& GetSizeConstraints() const = 0;
/**
* If this is owned by a TabChild, return that. Otherwise return
* null.
*/
virtual TabChild* GetOwningTabChild() { return nullptr; }
protected:
// keep the list of children. We also keep track of our siblings.

View File

@@ -172,6 +172,8 @@ public:
// later on.
virtual float GetDPI();
virtual TabChild* GetOwningTabChild() MOZ_OVERRIDE { return mTabChild; }
private:
nsresult Paint();