mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
c8732098b3
- Bug 1246851 (Part 1) - Add a new SurfacePipe API for writing to image surfaces in a safe and composable manner. r=njn (2e3353a6a7) - Bug 1246851 (Part 2) - Add SurfaceFilter implementations for basic surface output operations. r=njn (fa30948a3f) - Bug 1246851 (Part 3) - Add a factory for constructing SurfacePipes. r=njn (7a746d3ec8) - Bug 1191347 - Explicitly release surfaces on the main thread in TestDecodeToSurface. r=me (fa1a68dc9a) - Bug 1246851 (Part 4) - Add a test suite for SurfacePipes and SurfaceFilters. r=njn (380dc94c08) - Bug 1247152 (Part 1) - Use SurfacePipe in the GIF decoder. r=njn (8b3d76f017) - Bug 1247152 (Part 2) - Remove even more code from the GIF decoder. r=edwin (80c8cc5e1c) - side effects Bug 1247152 (Part 1) (5b6cbf0ad5) - Bug 1237232 - Properly check the result of Vector append() calls in security/. r=keeler (b06dce061f) - Bug 1235308 - Fix -Wimplicit-fallthrough warnings in security/. r=keeler (ac5c3bf540) - Bug 1235188 - Fix -Wformat warnings in security/certverifier/. r=keeler (25ee7ee77c) - Bug 1004149 - Remove some dead code. r=keeler (59fedcb6a6) - Bug 1004149 - Return mozilla::pkix::Result values in nsNSSHttpInterface functions. r=keeler (76933c7d94) - Bug 1187173 - Disable warning C4623 on security/certverifier. r=briansmith (c1353b0577) - Bug 1256484 - Disable C4456 and C4458 to unblock compilation on VS2015; r=keeler (b51ac368ba) - Bug 1251009 - Remove unused nsICertificateDialogs.notifyCACertExists() method. r=keeler, r=mfinkle (9ca9aee3d0) - Bug 1249224 - window.open() should open a new window in the same container, r=bz (c57c76ec2f) - Bug 1245451 - add default nullptr value to mChrome. r=bsmedberg (3236ea34df) - Bug 1255849. Add some documentation for AutoJSAPI instances that seem to be used just for cxpushing. r=bholley (60a81652de) - Bug 1189554 - Make Saved Passwords dialog resizable on Windows again. r=smaug (a367796251) - Bug 1252974 - Convert screen's available dimensions to CSS-pixel units in nsWindowWatcher. r=emk (5524055ab0) - Bug 1233328 - Part 1: Ignore SHA-1 pins in PublicKeyPinningService.cpp. r=keeler (e5fe732a4b) - Bug 1233328 - Part 2: Use SHA-256 StaticFingerprints directly instead창 of StaticPinset since the SHA-1 StaticFingerprints entry will always be null. r=keeler (50f88c76da) - Bug 1256089 - Fix Mutex support for tier-3 platforms; r=froydnj (76ab483843) - Bug 1257019 - Add move construction to js::Mutex<T>. r=terrence (383ad474ba) - No bug, Automated HPKP preload list update from host bld-linux64-spot-309 - a=hpkp-update (0a6d3b9c40) - No bug, Automated HPKP preload list update from host bld-linux64-spot-223 - a=hpkp-update (7b3dbac6f8) - Bug 1255655 - Const-ify kPinset_* arrays. r=cykesiopka. (ddbaad40a0) - No bug, Automated HPKP preload list update from host bld-linux64-spot-543 - a=hpkp-update (f5c37e366a) - bug 1233853 - make nsSyncJPAKE aware of NSS shutdown r=jcj (9f74b5a46f) - Bug 1215734 - Expand GeckoMediaPlugin sandbox policy for Clang 3.7 ASan. r=kang (a96e0429e5) - part Bug 1154738 - Fixed WMFUtils.cpp compilation on mingw (9ba8bd1481) - Bug 1256498. Explicitly convert to float. r=bas (ce97ef100e) - Bug 1223736 - Part 1: Set correct effective transform on mask layers. r=thinker (a87514ac4f) - Bug 1249813 - part 1 - revise nsShmImage to allow draw targets anywhere inside its bounds. r=jrmuizel (cba4cdf8c9) - Bug 1249813 - part 2 - make Cairo mark a surface as clear if clip covers entire surface. r=jrmuizel (45ccfcfc15) - Bug 1249813 - part 3 - tell the compositor if the root layer has opaque content so it can skip clears. r=mattwoodrow (2abaa0cf8b) - Bug 1255303 - Use SurfaceFormat::B8G8R8X8 as back buffer if possible r=jrmuizel (5f81a83123) - Bug 1253860 - Don't update the scrollbar unless we're actually painting. r=mstange (d3a2482408) - Bug 1253860 - Add a flag on scroll frames indicating if they have an APZ counterpart. r=mstange (2aef746ee1) - Bug 1253860 - Skip paints for main thread scrolls if we can ask APZ to handle the scrolling for us. r=mstange (4483da1f16) - Bug 1244116 - Telemetry for mixed content requests by plugins. r=smaug, p=ally (fd5f87f666) - Bug 1252829 - CSP Telemetry. r=ckerschb, p=bsmedberg (8d340fa824) - Bug 1246464: Add 'const' to some stylesheet args in nsDocument methods. r=heycam (4e744d81d2) - Bug 1255705 - Add some useful logging that can be enabled at compile time. r=botond (80f0202160) - Bug 1255856 - Don't allow paint-skipping if there are windowed plugins on the page. r=mstange,jimm (25e6d8ed22) - Bug 1256727 - Don't allow paint-skipping on pages with scroll-linked effects. r=mstange (a8bace52ff) - Bug 1247098 - Take document resolution into account when computing root composition bounds for displayport base. r=tnikkel (1b7b61c82e) - Bug 1250550 - Ensure a scroll event posted during a refresh driver tick fires during that same tick. r=mats (d5bfc24524) - Bug 1253739 - Fix incorrect namespace on forward declaration. r=botond (dfc7aac51e) - Bug 1253489 - Update SendFenceHandleIfPresent() r=nical (798c209dff) - Bug 1253860 - Stop APZC from reprocessing stale metrics on unrelated layer tree updates. r=botond (1013df0068) - Bug 1253860 - Add machinery to update APZ's scroll offset without a main-thread paint. r=botond (cb95baf9c6) - Bug 1239564 - Post translate maskSurface to renderTarget. r=roc (66c56d227d) - Bug 1223736 - Part 2: Draw masks in the correct coordinate space when doing 3d transforms in BasicCompositor. r=lsalzman (2d62616534) - Bug 1223736 - Part 3: Remove the distinction between 2d and 3d masks since it only adds complexity. r=Bas (61c2306875) - Bug 1137561 - Follow up VS2015 build error. r=masayuki (f12716a1ab) - Bug 1217275 Fix missing \n in IMMHandler::HandleDocumentFeed(), it was replaced to empty string accidentally r=m_kato (3315b1c270) - Bug 1243268 - Adjust ATOK workaround. r=masayuki (13af7184d1) - Bug 1242690 - If a drag block is interrupted by something else, have it create a new drag block when it resumes. r=rbarker (fe3dc8deac) - Bug 1242690 - Add untransforming of mouse events not in a drag block. r=rbarker (a39e715efe) - Bug 1241991 - Switch mTreeLock from a Monitor to a Mutex. r=kats (0eca284591) - Bug 1242690 - Further refine the mouse event untransformation code to only apply to events directed at a scrollbar. r=rbarker (5c92ca2807) - Bug 1251608 - Add a root-content annotation to the APZ test data structure. r=botond (a1ee8e496a) - Bug 1249748 - Ensure the mHandledByAPZ flag is set on WidgetTouchEvents that are handled by APZ. r=botond (11bdfae896) - Bug 1242690 - Don't apply the main-thread callback transform for events in a drag block. r=rbarker (3db1405b68) - Bug 1243589 - Use SingleTiledContentClient even for scrollable layers if the layer is smaller than a single tile. r=mattwoodrow (56bb664de1) - Bug 1250517 - Differentiate between no critical display port and empty critical display port in ClientTiledPaintedLayer; r=kats (1b809fac8e) - Bug 1255448 - Call ClientMultiTiledLayerBuffer::PaintThebes even when region to paint is empty. r=mattwoodrow (31ac878dc0) - Bug 1255907 - Fix unification build issues in APZ & Layers. r=kats (9829525402) - Bug 1256344 - If a long-press is interrupted by a non-touch block, don't dispatch the long-press event. r=botond (b3bdd0e58e) - Bug 1256341 - Guard against scenarios where GenerateSingleTap is called without an active touch block. r=botond (d4ec208407) - Bug 1230552 - Minor follow-up to add an assertion. rs=kats (6f9eec7bd4) - Bug 1247964 - Allow InputBlockState::SetScrolledApzc to accept new APZC when it is an ancestor of the current APZC r=kats # Please enter the commit message for your changes. Lines starting (08ce9cfa98) - Bug 1257264 - When apz.allow_immediate_handoff=false, APZ handoff should not occur when panning changes direction r=botond (6ec9ec22e6) - Bug 1250213 - Ensure the scroll offset does not go outside the page bounds when going full screen r=kats (ace8e8a80c) - Bug 1241332 - part 1, Request content repaint at end of APZ animation r=kats (74f7e249f2) - Bug 1255705 - Generalize the NotifyLayersUpdated short-circuit codepath to trigger on empty transactions as well. r=botond (0344d44844) - Bug 1250614 - Repeated zooming in bug on mobile Wikipedia site r=botond (459f02b8d3) - Bug 1251001 - Input fields at the bottom of a page do not pan into view when gaining focus. r=botond (770102bf9f) - Bug 1190093 (Comment Tweak) - Add better comments for nsIDocument::mIsShowing and mVisible. r=me DONTBUILD (e3822ef086) - Bug 1217226: P1. Use VideoInfo display size data rather than attempt to detect value in stream. r=cpearce (a4a7e9b19a) - Bug 1217226: P2. Implement WMFMediaDataDecoder::ConfigurationChanged. r=cpearce (52177525c5) - fix misspatch (61a694fe3d) - Bug 1249706: Added telemetry for the proportion of frames dropped keyed by several details. r=jya (cb459d971c) - Bug 1202296 - Recreate the MFTDecoder when we want to disable DXVA. r=cpearce (d82999e94f) - Bug 1176071 - Handle WMF MFTDecoder returning success but no output, with telemetry. r=mattwoodrow,r=vladan (da8017c92b) - align, cleanup (9a86d51dfd) - no bug - fix case of nsIDocShell.h in WindowsUIUtils.cpp (0ccabaa445) - Bug 1187724 Don't dispatch KeyboardEvents when the target of WM_APPCOMMAND is a windowed plug-in for preventing deadlock r=jimm (7b6d83559c) - Bug 1187178 - Use MOZ_WINSDK_MAXVER instead of #ifndef. r=jimm (06c949ddb9) - bits of Bug 1165515 - Part 13-2: Replace usage of PRLogModuleLevel (7beaa2dcc4) - Bug 1257791: Return correct DPI and printing scale from nsDeviceContextSpecWin when printing to PDF. r=jimm (87360301ea) - Bug 1242295 - Fix compile error in nsDeviceContextSpecWin. r=jimm (d1d4680319) - Bug 1229881 - fix off-by-one error in nsPrinterEnumeratorWin::GetPrinterNameList; r=dbaron; a=KWierso (439061ba50) - Bug 1239683 - Replace NS_UNCONSTRAINEDSIZE with NS_MAXSIZE in windows/nsWindow.cpp. r=mats (4135189bec) - Bug 1033488 - Send RTL information to child process by WM_INPUTLANGCHANGE. r=masayuki (eaf8f70d34) - Bug 1238137 - Telemetry pings for main thread touch scrolling (Windows only). r=kats (f2194a2965) - Bug 1156182 - Ensure nsWindow::Destroy() is called before destroying mPresentLock to avoid a race with the compositor thread. r=Bas (0452ffc641) - Bug 1173617. Don't cache titlebar caption sizes unless the widget has a titlebar. r=jimm (b29e190504) - Bug 580165 - Clean up dead code related to missing screen managers in widget. r=jimm (bf83f21ddc) - Bug 1256501: Fix warning C4312 with 64-bit VS2015 in widget/windows/nsWindow.cpp; r=jimm (635151964e) - Bug 1242690 - Squash together DispatchAPZAwareEvent and DispatchInputEvent. r=dvander (d7b4fea361) - Bug 1242616: Add break in nsWindow.cpp WM_GETOBJECT handling. r=tbsaunde (eb516d4119) - Bug 1239353 - Don't try to change DPI on the fly for popup windows, they remain connected to their parent's presShell and therefore need to share its resolution. r=emk (1491b84fd1) - Bug 1246389 - Resize window appropriately on WM_DPICHANGED messages for dynamic resolution changes. r=emk (f3dbfcdbb1) - Bug 1254019 - Don't attempt to resize a maximized window on DPI change; and when handling a DPI change, constrain the resized window to the screen bounds. r=emk (2047c2dcb5) - Bug 1252191 - use UniquePtr instead of ScopedFreePtr in PoisonIOInterposerMac.cpp; r=aklotz (7c26e55b76) - Bug 1233208: Disable IOInterposer on Beta and Release; r=froydnj (04a6f8b07c) - crashreporter (377572bbb1) - Bug 1055322 - The realloc for libnestegg should free with size 0. r=froydnj (ea624646ca) - Bug 1236789. Avoid creating an unnecessary thread pool thread for tail-dispatch in TaskQueue. r=bholley (e7fb9e4373) - Bug 1255655 - Const-ify named CIDs. r=froydnj. (03b414d92b) - Bug 1250396 (part 1) - Document a subtle contraint on nsIAtom. r=froydnj. (ff279149ac) - Bug 1250396 (part 2) - Remove nsStaticAtomStringType. r=froydnj. (5520507680) - Bug 1255343 - Stop returning nsresult from NS_RegisterStaticAtoms; r=ehsan (de1d387937) - Bug 1251495 - remove unnecessary Logging.h include from nsStaticAtom.h; r=erahm (5226a840fa)
610 lines
25 KiB
C++
610 lines
25 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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 "ClientTiledPaintedLayer.h"
|
|
#include "FrameMetrics.h" // for FrameMetrics
|
|
#include "Units.h" // for ScreenIntRect, CSSPoint, etc
|
|
#include "UnitTransforms.h" // for TransformTo
|
|
#include "ClientLayerManager.h" // for ClientLayerManager, etc
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
|
#include "gfxRect.h" // for gfxRect
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
#include "mozilla/gfx/Rect.h" // for Rect, RectTyped
|
|
#include "mozilla/layers/CompositorBridgeChild.h"
|
|
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
|
#include "mozilla/layers/LayersMessages.h"
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
|
#include "LayersLogging.h"
|
|
#include "mozilla/layers/SingleTiledContentClient.h"
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
using gfx::Rect;
|
|
using gfx::IntRect;
|
|
using gfx::IntSize;
|
|
|
|
ClientTiledPaintedLayer::ClientTiledPaintedLayer(ClientLayerManager* const aManager,
|
|
ClientLayerManager::PaintedLayerCreationHint aCreationHint)
|
|
: PaintedLayer(aManager, static_cast<ClientLayer*>(this), aCreationHint)
|
|
, mContentClient()
|
|
, mHaveSingleTiledContentClient(false)
|
|
{
|
|
MOZ_COUNT_CTOR(ClientTiledPaintedLayer);
|
|
mPaintData.mLastScrollOffset = ParentLayerPoint(0, 0);
|
|
mPaintData.mFirstPaint = true;
|
|
}
|
|
|
|
ClientTiledPaintedLayer::~ClientTiledPaintedLayer()
|
|
{
|
|
MOZ_COUNT_DTOR(ClientTiledPaintedLayer);
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::ClearCachedResources()
|
|
{
|
|
if (mContentClient) {
|
|
mContentClient->ClearCachedResources();
|
|
}
|
|
mValidRegion.SetEmpty();
|
|
mContentClient = nullptr;
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
|
|
{
|
|
aAttrs = PaintedLayerAttributes(GetValidRegion());
|
|
}
|
|
|
|
static Maybe<LayerRect>
|
|
ApplyParentLayerToLayerTransform(const ParentLayerToLayerMatrix4x4& aTransform,
|
|
const ParentLayerRect& aParentLayerRect,
|
|
const LayerRect& aClip)
|
|
{
|
|
return UntransformBy(aTransform, aParentLayerRect, aClip);
|
|
}
|
|
|
|
static LayerToParentLayerMatrix4x4
|
|
GetTransformToAncestorsParentLayer(Layer* aStart, const LayerMetricsWrapper& aAncestor)
|
|
{
|
|
gfx::Matrix4x4 transform;
|
|
const LayerMetricsWrapper& ancestorParent = aAncestor.GetParent();
|
|
for (LayerMetricsWrapper iter(aStart, LayerMetricsWrapper::StartAt::BOTTOM);
|
|
ancestorParent ? iter != ancestorParent : iter.IsValid();
|
|
iter = iter.GetParent()) {
|
|
transform = transform * iter.GetTransform();
|
|
|
|
if (gfxPrefs::LayoutUseContainersForRootFrames()) {
|
|
// When scrolling containers, layout adds a post-scale into the transform
|
|
// of the displayport-ancestor (which we pick up in GetTransform() above)
|
|
// to cancel out the pres shell resolution (for historical reasons). The
|
|
// compositor in turn cancels out this post-scale (i.e., scales by the
|
|
// pres shell resolution), and to get correct calculations, we need to do
|
|
// so here, too.
|
|
//
|
|
// With containerless scrolling, the offending post-scale is on the
|
|
// parent layer of the displayport-ancestor, which we don't reach in this
|
|
// loop, so we don't need to worry about it.
|
|
float presShellResolution = iter.GetPresShellResolution();
|
|
transform.PostScale(presShellResolution, presShellResolution, 1.0f);
|
|
}
|
|
}
|
|
return ViewAs<LayerToParentLayerMatrix4x4>(transform);
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncestor,
|
|
LayerMetricsWrapper* aOutDisplayPortAncestor,
|
|
bool* aOutHasTransformAnimation)
|
|
{
|
|
LayerMetricsWrapper scrollAncestor;
|
|
LayerMetricsWrapper displayPortAncestor;
|
|
bool hasTransformAnimation = false;
|
|
for (LayerMetricsWrapper ancestor(this, LayerMetricsWrapper::StartAt::BOTTOM); ancestor; ancestor = ancestor.GetParent()) {
|
|
hasTransformAnimation |= ancestor.HasTransformAnimation();
|
|
const FrameMetrics& metrics = ancestor.Metrics();
|
|
if (!scrollAncestor && metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
|
|
scrollAncestor = ancestor;
|
|
}
|
|
if (!metrics.GetDisplayPort().IsEmpty()) {
|
|
displayPortAncestor = ancestor;
|
|
// Any layer that has a displayport must be scrollable, so we can break
|
|
// here.
|
|
break;
|
|
}
|
|
}
|
|
if (aOutScrollAncestor) {
|
|
*aOutScrollAncestor = scrollAncestor;
|
|
}
|
|
if (aOutDisplayPortAncestor) {
|
|
*aOutDisplayPortAncestor = displayPortAncestor;
|
|
}
|
|
if (aOutHasTransformAnimation) {
|
|
*aOutHasTransformAnimation = hasTransformAnimation;
|
|
}
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::BeginPaint()
|
|
{
|
|
mPaintData.ResetPaintData();
|
|
|
|
if (!GetBaseTransform().Is2D()) {
|
|
// Give up if there is a complex CSS transform on the layer. We might
|
|
// eventually support these but for now it's too complicated to handle
|
|
// given that it's a pretty rare scenario.
|
|
return;
|
|
}
|
|
|
|
// Get the metrics of the nearest scrollable layer and the nearest layer
|
|
// with a displayport.
|
|
LayerMetricsWrapper scrollAncestor;
|
|
LayerMetricsWrapper displayPortAncestor;
|
|
bool hasTransformAnimation;
|
|
GetAncestorLayers(&scrollAncestor, &displayPortAncestor, &hasTransformAnimation);
|
|
|
|
if (!displayPortAncestor || !scrollAncestor) {
|
|
// No displayport or scroll ancestor, so we can't do progressive rendering.
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
|
|
// Both Android and b2g on phones are guaranteed to have a displayport set, so this
|
|
// should never happen.
|
|
NS_WARNING("Tiled PaintedLayer with no scrollable container ancestor");
|
|
#endif
|
|
return;
|
|
}
|
|
|
|
TILING_LOG("TILING %p: Found scrollAncestor %p, displayPortAncestor %p, transform %d\n", this,
|
|
scrollAncestor.GetLayer(), displayPortAncestor.GetLayer(), hasTransformAnimation);
|
|
|
|
const FrameMetrics& scrollMetrics = scrollAncestor.Metrics();
|
|
const FrameMetrics& displayportMetrics = displayPortAncestor.Metrics();
|
|
|
|
// Calculate the transform required to convert ParentLayer space of our
|
|
// display port ancestor to the Layer space of this layer.
|
|
ParentLayerToLayerMatrix4x4 transformDisplayPortToLayer =
|
|
GetTransformToAncestorsParentLayer(this, displayPortAncestor).Inverse();
|
|
|
|
LayerRect layerBounds = ViewAs<LayerPixel>(Rect(GetLayerBounds()));
|
|
|
|
// Compute the critical display port that applies to this layer in the
|
|
// LayoutDevice space of this layer, but only if there is no OMT animation
|
|
// on this layer. If there is an OMT animation then we need to draw the whole
|
|
// visible region of this layer as determined by layout, because we don't know
|
|
// what parts of it might move into view in the compositor.
|
|
if (!hasTransformAnimation &&
|
|
mContentClient->GetLowPrecisionTiledBuffer()) {
|
|
ParentLayerRect criticalDisplayPort =
|
|
(displayportMetrics.GetCriticalDisplayPort() * displayportMetrics.GetZoom())
|
|
+ displayportMetrics.GetCompositionBounds().TopLeft();
|
|
Maybe<LayerRect> criticalDisplayPortTransformed =
|
|
ApplyParentLayerToLayerTransform(transformDisplayPortToLayer, criticalDisplayPort, layerBounds);
|
|
if (criticalDisplayPortTransformed) {
|
|
mPaintData.mCriticalDisplayPort = Some(RoundedToInt(*criticalDisplayPortTransformed));
|
|
} else {
|
|
mPaintData.mCriticalDisplayPort = Some(LayerIntRect(0, 0, 0, 0));
|
|
}
|
|
}
|
|
TILING_LOG("TILING %p: Critical displayport %s\n", this,
|
|
mPaintData.mCriticalDisplayPort ?
|
|
Stringify(*mPaintData.mCriticalDisplayPort).c_str() : "not set");
|
|
|
|
// Store the resolution from the displayport ancestor layer. Because this is Gecko-side,
|
|
// before any async transforms have occurred, we can use the zoom for this.
|
|
mPaintData.mResolution = displayportMetrics.GetZoom();
|
|
TILING_LOG("TILING %p: Resolution %s\n", this, Stringify(mPaintData.mResolution).c_str());
|
|
|
|
// Store the applicable composition bounds in this layer's Layer units.
|
|
mPaintData.mTransformToCompBounds =
|
|
GetTransformToAncestorsParentLayer(this, scrollAncestor);
|
|
ParentLayerToLayerMatrix4x4 transformToBounds = mPaintData.mTransformToCompBounds.Inverse();
|
|
Maybe<LayerRect> compositionBoundsTransformed = ApplyParentLayerToLayerTransform(
|
|
transformToBounds, scrollMetrics.GetCompositionBounds(), layerBounds);
|
|
if (compositionBoundsTransformed) {
|
|
mPaintData.mCompositionBounds = *compositionBoundsTransformed;
|
|
} else {
|
|
mPaintData.mCompositionBounds.SetEmpty();
|
|
}
|
|
TILING_LOG("TILING %p: Composition bounds %s\n", this, Stringify(mPaintData.mCompositionBounds).c_str());
|
|
|
|
// Calculate the scroll offset since the last transaction
|
|
mPaintData.mScrollOffset = displayportMetrics.GetScrollOffset() * displayportMetrics.GetZoom();
|
|
TILING_LOG("TILING %p: Scroll offset %s\n", this, Stringify(mPaintData.mScrollOffset).c_str());
|
|
}
|
|
|
|
bool
|
|
ClientTiledPaintedLayer::IsScrollingOnCompositor(const FrameMetrics& aParentMetrics)
|
|
{
|
|
CompositorBridgeChild* compositor = nullptr;
|
|
if (Manager() && Manager()->AsClientLayerManager()) {
|
|
compositor = Manager()->AsClientLayerManager()->GetCompositorBridgeChild();
|
|
}
|
|
|
|
if (!compositor) {
|
|
return false;
|
|
}
|
|
|
|
FrameMetrics compositorMetrics;
|
|
if (!compositor->LookupCompositorFrameMetrics(aParentMetrics.GetScrollId(),
|
|
compositorMetrics)) {
|
|
return false;
|
|
}
|
|
|
|
// 1 is a tad high for a fuzzy equals epsilon however if our scroll delta
|
|
// is so small then we have nothing to gain from using paint heuristics.
|
|
float COORDINATE_EPSILON = 1.f;
|
|
|
|
return !FuzzyEqualsAdditive(compositorMetrics.GetScrollOffset().x,
|
|
aParentMetrics.GetScrollOffset().x,
|
|
COORDINATE_EPSILON) ||
|
|
!FuzzyEqualsAdditive(compositorMetrics.GetScrollOffset().y,
|
|
aParentMetrics.GetScrollOffset().y,
|
|
COORDINATE_EPSILON);
|
|
}
|
|
|
|
bool
|
|
ClientTiledPaintedLayer::UseProgressiveDraw() {
|
|
if (!gfxPlatform::GetPlatform()->UseProgressivePaint()) {
|
|
// pref is disabled, so never do progressive
|
|
return false;
|
|
}
|
|
|
|
if (!mContentClient->GetTiledBuffer()->SupportsProgressiveUpdate()) {
|
|
return false;
|
|
}
|
|
|
|
if (ClientManager()->HasShadowTarget()) {
|
|
// This condition is true when we are in a reftest scenario. We don't want
|
|
// to draw progressively here because it can cause intermittent reftest
|
|
// failures because the harness won't wait for all the tiles to be drawn.
|
|
return false;
|
|
}
|
|
|
|
if (!mPaintData.mCriticalDisplayPort) {
|
|
// This catches three scenarios:
|
|
// 1) This layer doesn't have a scrolling ancestor
|
|
// 2) This layer is subject to OMTA transforms
|
|
// 3) Low-precision painting is disabled
|
|
// In all of these cases, we don't want to draw this layer progressively.
|
|
return false;
|
|
}
|
|
|
|
if (GetIsFixedPosition() || GetParent()->GetIsFixedPosition()) {
|
|
// This layer is fixed-position and so even if it does have a scrolling
|
|
// ancestor it will likely be entirely on-screen all the time, so we
|
|
// should draw it all at once
|
|
return false;
|
|
}
|
|
|
|
if (ClientManager()->AsyncPanZoomEnabled()) {
|
|
LayerMetricsWrapper scrollAncestor;
|
|
GetAncestorLayers(&scrollAncestor, nullptr, nullptr);
|
|
MOZ_ASSERT(scrollAncestor); // because mPaintData.mCriticalDisplayPort is set
|
|
const FrameMetrics& parentMetrics = scrollAncestor.Metrics();
|
|
if (!IsScrollingOnCompositor(parentMetrics)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
ClientTiledPaintedLayer::RenderHighPrecision(nsIntRegion& aInvalidRegion,
|
|
const nsIntRegion& aVisibleRegion,
|
|
LayerManager::DrawPaintedLayerCallback aCallback,
|
|
void* aCallbackData)
|
|
{
|
|
// If we have started drawing low-precision already, then we
|
|
// shouldn't do anything there.
|
|
if (mPaintData.mLowPrecisionPaintCount != 0) {
|
|
return false;
|
|
}
|
|
|
|
// Only draw progressively when there is something to paint and the
|
|
// resolution is unchanged
|
|
if (!aInvalidRegion.IsEmpty() &&
|
|
UseProgressiveDraw() &&
|
|
mContentClient->GetTiledBuffer()->GetFrameResolution() == mPaintData.mResolution) {
|
|
// Store the old valid region, then clear it before painting.
|
|
// We clip the old valid region to the visible region, as it only gets
|
|
// used to decide stale content (currently valid and previously visible)
|
|
nsIntRegion oldValidRegion = mContentClient->GetTiledBuffer()->GetValidRegion();
|
|
oldValidRegion.And(oldValidRegion, aVisibleRegion);
|
|
if (mPaintData.mCriticalDisplayPort) {
|
|
oldValidRegion.And(oldValidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
|
|
}
|
|
|
|
TILING_LOG("TILING %p: Progressive update with old valid region %s\n", this, Stringify(oldValidRegion).c_str());
|
|
|
|
return mContentClient->GetTiledBuffer()->ProgressiveUpdate(mValidRegion, aInvalidRegion,
|
|
oldValidRegion, &mPaintData, aCallback, aCallbackData);
|
|
}
|
|
|
|
// Otherwise do a non-progressive paint. We must do this even when
|
|
// the region to paint is empty as the valid region may have shrunk.
|
|
|
|
mValidRegion = aVisibleRegion;
|
|
if (mPaintData.mCriticalDisplayPort) {
|
|
mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
|
|
}
|
|
|
|
TILING_LOG("TILING %p: Non-progressive paint invalid region %s\n", this, Stringify(aInvalidRegion).c_str());
|
|
TILING_LOG("TILING %p: Non-progressive paint new valid region %s\n", this, Stringify(mValidRegion).c_str());
|
|
|
|
mContentClient->GetTiledBuffer()->SetFrameResolution(mPaintData.mResolution);
|
|
mContentClient->GetTiledBuffer()->PaintThebes(mValidRegion, aInvalidRegion, aInvalidRegion,
|
|
aCallback, aCallbackData);
|
|
mPaintData.mPaintFinished = true;
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
ClientTiledPaintedLayer::RenderLowPrecision(nsIntRegion& aInvalidRegion,
|
|
const nsIntRegion& aVisibleRegion,
|
|
LayerManager::DrawPaintedLayerCallback aCallback,
|
|
void* aCallbackData)
|
|
{
|
|
// Render the low precision buffer, if the visible region is larger than the
|
|
// critical display port.
|
|
if (!mPaintData.mCriticalDisplayPort ||
|
|
!nsIntRegion(mPaintData.mCriticalDisplayPort->ToUnknownRect()).Contains(aVisibleRegion)) {
|
|
nsIntRegion oldValidRegion = mContentClient->GetLowPrecisionTiledBuffer()->GetValidRegion();
|
|
oldValidRegion.And(oldValidRegion, aVisibleRegion);
|
|
|
|
bool updatedBuffer = false;
|
|
|
|
// If the frame resolution or format have changed, invalidate the buffer
|
|
if (mContentClient->GetLowPrecisionTiledBuffer()->GetFrameResolution() != mPaintData.mResolution ||
|
|
mContentClient->GetLowPrecisionTiledBuffer()->HasFormatChanged()) {
|
|
if (!mLowPrecisionValidRegion.IsEmpty()) {
|
|
updatedBuffer = true;
|
|
}
|
|
oldValidRegion.SetEmpty();
|
|
mLowPrecisionValidRegion.SetEmpty();
|
|
mContentClient->GetLowPrecisionTiledBuffer()->ResetPaintedAndValidState();
|
|
mContentClient->GetLowPrecisionTiledBuffer()->SetFrameResolution(mPaintData.mResolution);
|
|
aInvalidRegion = aVisibleRegion;
|
|
}
|
|
|
|
// Invalidate previously valid content that is no longer visible
|
|
if (mPaintData.mLowPrecisionPaintCount == 1) {
|
|
mLowPrecisionValidRegion.And(mLowPrecisionValidRegion, aVisibleRegion);
|
|
}
|
|
mPaintData.mLowPrecisionPaintCount++;
|
|
|
|
// Remove the valid high-precision region from the invalid low-precision
|
|
// region. We don't want to spend time drawing things twice.
|
|
aInvalidRegion.Sub(aInvalidRegion, mValidRegion);
|
|
|
|
TILING_LOG("TILING %p: Progressive paint: low-precision invalid region is %s\n", this, Stringify(aInvalidRegion).c_str());
|
|
TILING_LOG("TILING %p: Progressive paint: low-precision old valid region is %s\n", this, Stringify(oldValidRegion).c_str());
|
|
|
|
if (!aInvalidRegion.IsEmpty()) {
|
|
updatedBuffer = mContentClient->GetLowPrecisionTiledBuffer()->ProgressiveUpdate(
|
|
mLowPrecisionValidRegion, aInvalidRegion, oldValidRegion,
|
|
&mPaintData, aCallback, aCallbackData);
|
|
}
|
|
|
|
TILING_LOG("TILING %p: Progressive paint: low-precision new valid region is %s\n", this, Stringify(mLowPrecisionValidRegion).c_str());
|
|
return updatedBuffer;
|
|
}
|
|
if (!mLowPrecisionValidRegion.IsEmpty()) {
|
|
TILING_LOG("TILING %p: Clearing low-precision buffer\n", this);
|
|
// Clear the low precision tiled buffer.
|
|
mLowPrecisionValidRegion.SetEmpty();
|
|
mContentClient->GetLowPrecisionTiledBuffer()->ResetPaintedAndValidState();
|
|
// Return true here so we send a Painted callback after clearing the valid
|
|
// region of the low precision buffer. This allows the shadow buffer's valid
|
|
// region to be updated and the associated resources to be freed.
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::EndPaint()
|
|
{
|
|
mPaintData.mLastScrollOffset = mPaintData.mScrollOffset;
|
|
mPaintData.mPaintFinished = true;
|
|
mPaintData.mFirstPaint = false;
|
|
TILING_LOG("TILING %p: Paint finished\n", this);
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::RenderLayer()
|
|
{
|
|
LayerManager::DrawPaintedLayerCallback callback =
|
|
ClientManager()->GetPaintedLayerCallback();
|
|
void *data = ClientManager()->GetPaintedLayerCallbackData();
|
|
|
|
IntSize layerSize = mVisibleRegion.ToUnknownRegion().GetBounds().Size();
|
|
IntSize tileSize(gfxPlatform::GetPlatform()->GetTileWidth(),
|
|
gfxPlatform::GetPlatform()->GetTileHeight());
|
|
|
|
bool wantSingleTiledContentClient =
|
|
(mCreationHint == LayerManager::NONE || layerSize <= tileSize) &&
|
|
SingleTiledContentClient::ClientSupportsLayerSize(layerSize, ClientManager()) &&
|
|
gfxPrefs::LayersSingleTileEnabled();
|
|
|
|
if (mContentClient && mHaveSingleTiledContentClient && !wantSingleTiledContentClient) {
|
|
mContentClient = nullptr;
|
|
mValidRegion.SetEmpty();
|
|
}
|
|
|
|
if (!mContentClient) {
|
|
if (wantSingleTiledContentClient) {
|
|
mContentClient = new SingleTiledContentClient(this, ClientManager());
|
|
mHaveSingleTiledContentClient = true;
|
|
} else {
|
|
mContentClient = new MultiTiledContentClient(this, ClientManager());
|
|
mHaveSingleTiledContentClient = false;
|
|
}
|
|
|
|
mContentClient->Connect();
|
|
ClientManager()->AsShadowForwarder()->Attach(mContentClient, this);
|
|
MOZ_ASSERT(mContentClient->GetForwarder());
|
|
}
|
|
|
|
if (mContentClient->GetTiledBuffer()->HasFormatChanged()) {
|
|
mValidRegion = nsIntRegion();
|
|
mContentClient->GetTiledBuffer()->ResetPaintedAndValidState();
|
|
}
|
|
|
|
TILING_LOG("TILING %p: Initial visible region %s\n", this, Stringify(mVisibleRegion).c_str());
|
|
TILING_LOG("TILING %p: Initial valid region %s\n", this, Stringify(mValidRegion).c_str());
|
|
TILING_LOG("TILING %p: Initial low-precision valid region %s\n", this, Stringify(mLowPrecisionValidRegion).c_str());
|
|
|
|
nsIntRegion neededRegion = mVisibleRegion.ToUnknownRegion();
|
|
#ifndef MOZ_IGNORE_PAINT_WILL_RESAMPLE
|
|
// This is handled by PadDrawTargetOutFromRegion in TiledContentClient for mobile
|
|
if (MayResample()) {
|
|
// If we're resampling then bilinear filtering can read up to 1 pixel
|
|
// outside of our texture coords. Make the visible region a single rect,
|
|
// and pad it out by 1 pixel (restricted to tile boundaries) so that
|
|
// we always have valid content or transparent pixels to sample from.
|
|
IntRect bounds = neededRegion.GetBounds();
|
|
IntRect wholeTiles = bounds;
|
|
wholeTiles.InflateToMultiple(IntSize(
|
|
gfxPlatform::GetPlatform()->GetTileWidth(),
|
|
gfxPlatform::GetPlatform()->GetTileHeight()));
|
|
IntRect padded = bounds;
|
|
padded.Inflate(1);
|
|
padded.IntersectRect(padded, wholeTiles);
|
|
neededRegion = padded;
|
|
}
|
|
#endif
|
|
|
|
nsIntRegion invalidRegion;
|
|
invalidRegion.Sub(neededRegion, mValidRegion);
|
|
if (invalidRegion.IsEmpty()) {
|
|
EndPaint();
|
|
return;
|
|
}
|
|
|
|
if (!callback) {
|
|
ClientManager()->SetTransactionIncomplete();
|
|
return;
|
|
}
|
|
|
|
if (!ClientManager()->IsRepeatTransaction()) {
|
|
// Only paint the mask layers on the first transaction.
|
|
RenderMaskLayers(this);
|
|
|
|
// For more complex cases we need to calculate a bunch of metrics before we
|
|
// can do the paint.
|
|
BeginPaint();
|
|
if (mPaintData.mPaintFinished) {
|
|
return;
|
|
}
|
|
|
|
// Make sure that tiles that fall outside of the visible region or outside of the
|
|
// critical displayport are discarded on the first update. Also make sure that we
|
|
// only draw stuff inside the critical displayport on the first update.
|
|
mValidRegion.And(mValidRegion, neededRegion);
|
|
if (mPaintData.mCriticalDisplayPort) {
|
|
mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
|
|
invalidRegion.And(invalidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
|
|
}
|
|
|
|
TILING_LOG("TILING %p: First-transaction valid region %s\n", this, Stringify(mValidRegion).c_str());
|
|
TILING_LOG("TILING %p: First-transaction invalid region %s\n", this, Stringify(invalidRegion).c_str());
|
|
} else {
|
|
if (mPaintData.mCriticalDisplayPort) {
|
|
invalidRegion.And(invalidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
|
|
}
|
|
TILING_LOG("TILING %p: Repeat-transaction invalid region %s\n", this, Stringify(invalidRegion).c_str());
|
|
}
|
|
|
|
nsIntRegion lowPrecisionInvalidRegion;
|
|
if (mContentClient->GetLowPrecisionTiledBuffer()) {
|
|
// Calculate the invalid region for the low precision buffer. Make sure
|
|
// to remove the valid high-precision area so we don't double-paint it.
|
|
lowPrecisionInvalidRegion.Sub(neededRegion, mLowPrecisionValidRegion);
|
|
lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion);
|
|
}
|
|
TILING_LOG("TILING %p: Low-precision invalid region %s\n", this, Stringify(lowPrecisionInvalidRegion).c_str());
|
|
|
|
bool updatedHighPrecision = RenderHighPrecision(invalidRegion,
|
|
neededRegion,
|
|
callback, data);
|
|
if (updatedHighPrecision) {
|
|
ClientManager()->Hold(this);
|
|
mContentClient->UpdatedBuffer(TiledContentClient::TILED_BUFFER);
|
|
|
|
if (!mPaintData.mPaintFinished) {
|
|
// There is still more high-res stuff to paint, so we're not
|
|
// done yet. A subsequent transaction will take care of this.
|
|
ClientManager()->SetRepeatTransaction();
|
|
return;
|
|
}
|
|
}
|
|
|
|
// If there is nothing to draw in low-precision, then we're done.
|
|
if (lowPrecisionInvalidRegion.IsEmpty()) {
|
|
EndPaint();
|
|
return;
|
|
}
|
|
|
|
if (updatedHighPrecision) {
|
|
// If there are low precision updates, but we just did some high-precision
|
|
// updates, then mark the paint as unfinished and request a repeat transaction.
|
|
// This is so that we don't perform low-precision updates in the same transaction
|
|
// as high-precision updates.
|
|
TILING_LOG("TILING %p: Scheduling repeat transaction for low-precision painting\n", this);
|
|
ClientManager()->SetRepeatTransaction();
|
|
mPaintData.mLowPrecisionPaintCount = 1;
|
|
mPaintData.mPaintFinished = false;
|
|
return;
|
|
}
|
|
|
|
bool updatedLowPrecision = RenderLowPrecision(lowPrecisionInvalidRegion,
|
|
neededRegion,
|
|
callback, data);
|
|
if (updatedLowPrecision) {
|
|
ClientManager()->Hold(this);
|
|
mContentClient->UpdatedBuffer(TiledContentClient::LOW_PRECISION_TILED_BUFFER);
|
|
|
|
if (!mPaintData.mPaintFinished) {
|
|
// There is still more low-res stuff to paint, so we're not
|
|
// done yet. A subsequent transaction will take care of this.
|
|
ClientManager()->SetRepeatTransaction();
|
|
return;
|
|
}
|
|
}
|
|
|
|
// If we get here, we've done all the high- and low-precision
|
|
// paints we wanted to do, so we can finish the paint and chill.
|
|
EndPaint();
|
|
}
|
|
|
|
bool
|
|
ClientTiledPaintedLayer::IsOptimizedFor(LayerManager::PaintedLayerCreationHint aHint)
|
|
{
|
|
// The only creation hint is whether the layer is scrollable or not, and this
|
|
// is only respected on B2G and OSX, where it's used to determine whether to
|
|
// use a tiled content client or not.
|
|
// There are pretty nasty performance consequences for not using tiles on
|
|
// large, scrollable layers, so we want the layer to be recreated in this
|
|
// situation.
|
|
return aHint == GetCreationHint();
|
|
}
|
|
|
|
void
|
|
ClientTiledPaintedLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
|
{
|
|
PaintedLayer::PrintInfo(aStream, aPrefix);
|
|
if (mContentClient) {
|
|
aStream << "\n";
|
|
nsAutoCString pfx(aPrefix);
|
|
pfx += " ";
|
|
mContentClient->PrintInfo(aStream, pfx.get());
|
|
}
|
|
}
|
|
|
|
} // namespace layers
|
|
} // namespace mozilla
|