Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "WebRenderDisplayItemLayer.h"
7 :
8 : #include "LayersLogging.h"
9 : #include "mozilla/webrender/webrender_ffi.h"
10 : #include "mozilla/webrender/WebRenderTypes.h"
11 : #include "mozilla/layers/ScrollingLayersHelper.h"
12 : #include "mozilla/layers/StackingContextHelper.h"
13 : #include "mozilla/layers/WebRenderBridgeChild.h"
14 : #include "nsDisplayList.h"
15 : #include "mozilla/gfx/Matrix.h"
16 : #include "UnitTransforms.h"
17 :
18 : namespace mozilla {
19 : namespace layers {
20 :
21 0 : WebRenderDisplayItemLayer::~WebRenderDisplayItemLayer()
22 : {
23 0 : MOZ_COUNT_DTOR(WebRenderDisplayItemLayer);
24 0 : }
25 :
26 : void
27 0 : WebRenderDisplayItemLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
28 : const StackingContextHelper& aSc)
29 : {
30 0 : if (mVisibleRegion.IsEmpty()) {
31 0 : return;
32 : }
33 :
34 0 : ScrollingLayersHelper scroller(this, aBuilder, aSc);
35 :
36 0 : if (mItem) {
37 : WrSize contentSize; // this won't actually be used by anything
38 0 : wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
39 : // We might have recycled this layer. Throw away the old commands.
40 0 : mParentCommands.Clear();
41 :
42 0 : mItem->CreateWebRenderCommands(builder, aSc, mParentCommands, WrManager(),
43 0 : GetDisplayListBuilder());
44 0 : builder.Finalize(contentSize, mBuiltDisplayList);
45 : } else {
46 : // else we have an empty transaction and just use the
47 : // old commands.
48 0 : WebRenderLayerManager* manager = WrManager();
49 0 : MOZ_ASSERT(manager);
50 :
51 : // Since our recording relies on our parent layer's transform and stacking context
52 : // If this layer or our parent changed, this empty transaction won't work.
53 0 : if (manager->IsMutatedLayer(this) || manager->IsMutatedLayer(GetParent())) {
54 0 : manager->SetTransactionIncomplete();
55 0 : return;
56 : }
57 : }
58 :
59 0 : aBuilder.PushBuiltDisplayList(mBuiltDisplayList);
60 0 : WrBridge()->AddWebRenderParentCommands(mParentCommands);
61 : }
62 :
63 : } // namespace layers
64 : } // namespace mozilla
|