michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_READBACKPROCESSOR_H michael@0: #define GFX_READBACKPROCESSOR_H michael@0: michael@0: #include // for uint64_t michael@0: #include "nsRect.h" // for nsIntRect michael@0: #include "nsTArray.h" // for nsTArray michael@0: michael@0: class nsIntRegion; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class ContainerLayer; michael@0: class ReadbackLayer; michael@0: class ThebesLayer; michael@0: michael@0: class ReadbackProcessor { michael@0: public: michael@0: /** michael@0: * Called by the container before processing any child layers. Call this michael@0: * if any child layer might have changed in any way (other than content-only michael@0: * changes to layers other than ColorLayers and ThebesLayers). michael@0: * michael@0: * This method recomputes the relationship between ReadbackLayers and michael@0: * sibling layers, and dispatches changes to ReadbackLayers. Except that michael@0: * if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll michael@0: * just record that internally and later the ThebesLayer should call michael@0: * GetThebesLayerUpdates when it paints, to find out which rectangle needs michael@0: * to be sent, and the ReadbackLayer it needs to be sent to. michael@0: */ michael@0: void BuildUpdates(ContainerLayer* aContainer); michael@0: michael@0: struct Update { michael@0: /** michael@0: * The layer a ThebesLayer should send its contents to. michael@0: */ michael@0: ReadbackLayer* mLayer; michael@0: /** michael@0: * The rectangle of content that it should send, in the ThebesLayer's michael@0: * coordinate system. This rectangle is guaranteed to be in the ThebesLayer's michael@0: * visible region. Translate it to mLayer's coordinate system michael@0: * by adding mLayer->GetBackgroundLayerOffset(). michael@0: */ michael@0: nsIntRect mUpdateRect; michael@0: /** michael@0: * The sequence counter value to use when calling DoUpdate michael@0: */ michael@0: uint64_t mSequenceCounter; michael@0: }; michael@0: /** michael@0: * Appends any ReadbackLayers that need to be updated, and the rects that michael@0: * need to be updated, to aUpdates. Only need to call this for ThebesLayers michael@0: * that have been marked UsedForReadback(). michael@0: * Each Update's mLayer's mBackgroundLayer will have been set to aLayer. michael@0: * If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the michael@0: * ReadbackLayers that needed data from that ThebesLayer will be marked michael@0: * as having unknown backgrounds. michael@0: * @param aUpdateRegion if non-null, this region is set to the union michael@0: * of the mUpdateRects. michael@0: */ michael@0: void GetThebesLayerUpdates(ThebesLayer* aLayer, michael@0: nsTArray* aUpdates, michael@0: nsIntRegion* aUpdateRegion = nullptr); michael@0: michael@0: ~ReadbackProcessor(); michael@0: michael@0: protected: michael@0: void BuildUpdatesForLayer(ReadbackLayer* aLayer); michael@0: michael@0: nsTArray mAllUpdates; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: #endif /* GFX_READBACKPROCESSOR_H */