Skip to content

Commit

Permalink
Merge pull request mozilla#20 from tworaz/for_nemo/fix_and_enable_pro…
Browse files Browse the repository at this point in the history
…gressive_painting

For nemo/fix and enable progressive painting
  • Loading branch information
rojkov committed Jun 8, 2015
2 parents 94fe2da + dfed483 commit 32f76d2
Show file tree
Hide file tree
Showing 25 changed files with 654 additions and 572 deletions.
1 change: 0 additions & 1 deletion content/base/src/nsGkAtomList.h
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,6 @@ GK_ATOM(RemoteId, "_remote_id")
GK_ATOM(DisplayPort, "_displayport")
GK_ATOM(DisplayPortMargins, "_displayportmargins")
GK_ATOM(DisplayPortBase, "_displayportbase")
GK_ATOM(CriticalDisplayPort, "_critical_displayport")

// Names for system metrics
GK_ATOM(color_picker_available, "color-picker-available")
Expand Down
48 changes: 0 additions & 48 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,54 +482,6 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX,
return NS_OK;
}

NS_IMETHODIMP
nsDOMWindowUtils::SetCriticalDisplayPortForElement(float aXPx, float aYPx,
float aWidthPx, float aHeightPx,
nsIDOMElement* aElement)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}

nsIPresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}

if (!aElement) {
return NS_ERROR_INVALID_ARG;
}

nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);

if (!content) {
return NS_ERROR_INVALID_ARG;
}

if (content->GetCurrentDoc() != presShell->GetDocument()) {
return NS_ERROR_INVALID_ARG;
}

nsRect displayport;
if (!nsLayoutUtils::GetDisplayPort(content, &displayport)) {
return NS_ERROR_INVALID_ARG;
}

nsRect criticalDisplayport(nsPresContext::CSSPixelsToAppUnits(aXPx),
nsPresContext::CSSPixelsToAppUnits(aYPx),
nsPresContext::CSSPixelsToAppUnits(aWidthPx),
nsPresContext::CSSPixelsToAppUnits(aHeightPx));
content->SetProperty(nsGkAtoms::CriticalDisplayPort, new nsRect(criticalDisplayport),
nsINode::DeleteProperty<nsRect>);

nsIFrame* rootFrame = presShell->GetRootFrame();
if (rootFrame) {
rootFrame->InvalidateFrame();
}

return NS_OK;
}

NS_IMETHODIMP
nsDOMWindowUtils::SetResolution(float aXResolution, float aYResolution)
{
Expand Down
14 changes: 1 addition & 13 deletions dom/interfaces/base/nsIDOMWindowUtils.idl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface nsIRunnable;
interface nsICompositionStringSynthesizer;
interface nsITranslationNodeList;

[scriptable, uuid(d4ed34fc-9c07-4cef-b9e1-623794558db3)]
[scriptable, uuid(8435ca79-517f-40ba-acd9-55201a2a119d)]
interface nsIDOMWindowUtils : nsISupports {

/**
Expand Down Expand Up @@ -186,18 +186,6 @@ interface nsIDOMWindowUtils : nsISupports {
in int32_t aHeight,
in nsIDOMElement aElement);

/**
* When a display port is set, this allows a sub-section of that
* display port to be marked as 'critical'. In this scenario, the
* area outside of this rectangle may be rendered at a lower
* detail (for example, by reducing its resolution), or not rendered
* at all under some circumstances.
* This call will have no effect if a display port has not been set.
*/
void setCriticalDisplayPortForElement(in float aXPx, in float aYPx,
in float aWidthPx, in float aHeightPx,
in nsIDOMElement aElement);

/**
* Get/set the resolution at which rescalable web content is drawn.
* Currently this is only (some) thebes content.
Expand Down
29 changes: 24 additions & 5 deletions gfx/layers/FrameMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#define GFX_FRAMEMETRICS_H

#include <stdint.h> // for uint32_t, uint64_t
#include <string> // for std::string
#include "Units.h" // for CSSRect, CSSPixel, etc
#include "mozilla/gfx/BasePoint.h" // for BasePoint
#include "mozilla/gfx/Rect.h" // for RoundedIn
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
#include "mozilla/gfx/Logging.h" // for Log
#include "nsStringGlue.h"

namespace IPC {
template <typename T> struct ParamTraits;
Expand Down Expand Up @@ -205,6 +205,14 @@ struct FrameMetrics {
return mCompositionBounds / GetZoomToParent();
}

CSSSize CalculateBoundedCompositedSizeInCssPixels() const
{
CSSSize size = CalculateCompositedSizeInCssPixels();
size.width = std::min(size.width, mRootCompositionSize.width);
size.height = std::min(size.height, mRootCompositionSize.height);
return size;
}

void ScrollBy(const CSSPoint& aPoint)
{
mScrollOffset += aPoint;
Expand All @@ -221,6 +229,16 @@ struct FrameMetrics {
mScrollGeneration = aOther.mScrollGeneration;
}

// Make a copy of this FrameMetrics object which does not have any pointers
// to heap-allocated memory (i.e. is Plain Old Data, or 'POD'), and is
// therefore safe to be placed into shared memory.
FrameMetrics MakePODObject() const
{
FrameMetrics copy = *this;
copy.mContentDescription.Truncate();
return copy;
}

// ---------------------------------------------------------------------------
// The following metrics are all in widget space/device pixels.
//
Expand Down Expand Up @@ -374,12 +392,12 @@ struct FrameMetrics {
return mScrollGeneration;
}

const std::string& GetContentDescription() const
const nsCString& GetContentDescription() const
{
return mContentDescription;
}

void SetContentDescription(const std::string& aContentDescription)
void SetContentDescription(const nsCString& aContentDescription)
{
mContentDescription = aContentDescription;
}
Expand Down Expand Up @@ -476,8 +494,9 @@ struct FrameMetrics {
uint32_t mScrollGeneration;

// A description of the content element corresponding to this frame.
// This is empty unless the apz.printtree pref is turned on.
std::string mContentDescription;
// This is empty unless this is a scrollable layer and the
// apz.printtree pref is turned on.
nsCString mContentDescription;

// The size of the root scrollable's composition bounds, but in local CSS pixels.
CSSSize mRootCompositionSize;
Expand Down
2 changes: 2 additions & 0 deletions gfx/layers/LayersLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ AppendToString(nsACString& s, const FrameMetrics& m,
{
s += pfx;
AppendToString(s, m.mViewport, "{ viewport=");
AppendToString(s, m.mCompositionBounds, " cb=");
AppendToString(s, m.GetScrollOffset(), " viewportScroll=");
AppendToString(s, m.mDisplayPort, " displayport=");
AppendToString(s, m.mCriticalDisplayPort, " critdp=");
AppendToString(s, m.mScrollableRect, " scrollableRect=");
AppendToString(s, m.GetScrollId(), " scrollId=", " }");
return s += sfx;
Expand Down
12 changes: 12 additions & 0 deletions gfx/layers/LayersLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ AppendToString(nsACString& s, const mozilla::gfx::RectTyped<T>& r,
return s += sfx;
}

template<class T>
nsACString&
AppendToString(nsACString& s, const mozilla::gfx::IntRectTyped<T>& r,
const char* pfx="", const char* sfx="")
{
s += pfx;
s.AppendPrintf(
"(x=%d, y=%d, w=%d, h=%d)",
r.x, r.y, r.width, r.height);
return s += sfx;
}

nsACString&
AppendToString(nsACString& s, const nsIntRegion& r,
const char* pfx="", const char* sfx="");
Expand Down
19 changes: 19 additions & 0 deletions gfx/layers/TiledLayerBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "nsRect.h" // for nsIntRect
#include "nsRegion.h" // for nsIntRegion
#include "nsTArray.h" // for nsTArray
#include "prlog.h" // for PR_LOG

#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
#include <ui/Fence.h>
Expand All @@ -25,6 +26,24 @@
namespace mozilla {
namespace layers {

// To get this logging, you need PR logging enabled (either by
// doing a debug build, or #define'ing FORCE_PR_LOG at the top
// of a .cpp file), and then run with NSPR_LOG_MODULES=tiling:5
// in your environment at runtime.
#ifdef PR_LOGGING
# define TILING_PRLOG(_args) PR_LOG(gTilingLog, PR_LOG_DEBUG, _args)
# define TILING_PRLOG_OBJ(_args, obj) \
{ \
nsAutoCString tmpstr; \
AppendToString(tmpstr, obj); \
PR_LOG(gTilingLog, PR_LOG_DEBUG, _args); \
}
extern PRLogModuleInfo* gTilingLog;
#else
# define TILING_PRLOG(_args)
# define TILING_PRLOG_OBJ(_args, obj)
#endif

// An abstract implementation of a tile buffer. This code covers the logic of
// moving and reusing tiles and leaves the validation up to the implementor. To
// avoid the overhead of virtual dispatch, we employ the curiously recurring
Expand Down
16 changes: 7 additions & 9 deletions gfx/layers/apz/src/APZCTreeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ APZCTreeManager::SetAllowedTouchBehavior(const ScrollableLayerGuid& aGuid,
}
}

void
APZCTreeManager::AssertOnCompositorThread()
{
Compositor::AssertOnCompositorThread();
}

/* Flatten the tree of APZC instances into the given nsTArray */
static void
Collect(AsyncPanZoomController* aApzc, nsTArray< nsRefPtr<AsyncPanZoomController> >* aCollection)
Expand All @@ -104,7 +98,9 @@ void
APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor, Layer* aRoot,
bool aIsFirstPaint, uint64_t aFirstPaintLayersId)
{
AssertOnCompositorThread();
if (AsyncPanZoomController::GetThreadAssertionsEnabled()) {
Compositor::AssertOnCompositorThread();
}

MonitorAutoLock lock(mTreeLock);

Expand Down Expand Up @@ -200,7 +196,9 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
apzc = new AsyncPanZoomController(aLayersId, this, state->mController,
AsyncPanZoomController::USE_GESTURE_DETECTOR);
apzc->SetCompositorParent(aCompositor);
apzc->SetCrossProcessCompositorParent(state->mCrossProcessParent);
if (state->mCrossProcessParent != nullptr) {
apzc->ShareFrameMetricsAcrossProcesses();
}
} else {
// If there was already an APZC for the layer clear the tree pointers
// so that it doesn't continue pointing to APZCs that should no longer
Expand Down Expand Up @@ -243,7 +241,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
<< "\tcb=" << visible
<< "\tsr=" << container->GetFrameMetrics().mScrollableRect
<< (aLayer->GetVisibleRegion().IsEmpty() ? "\tscrollinfo" : "")
<< "\t" << container->GetFrameMetrics().GetContentDescription();
<< "\t" << container->GetFrameMetrics().GetContentDescription().get();

// Bind the APZC instance into the tree of APZCs
if (aNextSibling) {
Expand Down
6 changes: 0 additions & 6 deletions gfx/layers/apz/src/APZCTreeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,6 @@ class APZCTreeManager {
// Protected destructor, to discourage deletion outside of Release():
virtual ~APZCTreeManager();

/**
* Debug-build assertion that can be called to ensure code is running on the
* compositor thread.
*/
virtual void AssertOnCompositorThread();

/*
* Build the chain of APZCs that will handle overscroll for a pan starting at |aInitialTarget|.
*/
Expand Down
Loading

0 comments on commit 32f76d2

Please sign in to comment.