1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/ReadbackProcessor.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_READBACKPROCESSOR_H 1.10 +#define GFX_READBACKPROCESSOR_H 1.11 + 1.12 +#include <stdint.h> // for uint64_t 1.13 +#include "nsRect.h" // for nsIntRect 1.14 +#include "nsTArray.h" // for nsTArray 1.15 + 1.16 +class nsIntRegion; 1.17 + 1.18 +namespace mozilla { 1.19 +namespace layers { 1.20 + 1.21 +class ContainerLayer; 1.22 +class ReadbackLayer; 1.23 +class ThebesLayer; 1.24 + 1.25 +class ReadbackProcessor { 1.26 +public: 1.27 + /** 1.28 + * Called by the container before processing any child layers. Call this 1.29 + * if any child layer might have changed in any way (other than content-only 1.30 + * changes to layers other than ColorLayers and ThebesLayers). 1.31 + * 1.32 + * This method recomputes the relationship between ReadbackLayers and 1.33 + * sibling layers, and dispatches changes to ReadbackLayers. Except that 1.34 + * if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll 1.35 + * just record that internally and later the ThebesLayer should call 1.36 + * GetThebesLayerUpdates when it paints, to find out which rectangle needs 1.37 + * to be sent, and the ReadbackLayer it needs to be sent to. 1.38 + */ 1.39 + void BuildUpdates(ContainerLayer* aContainer); 1.40 + 1.41 + struct Update { 1.42 + /** 1.43 + * The layer a ThebesLayer should send its contents to. 1.44 + */ 1.45 + ReadbackLayer* mLayer; 1.46 + /** 1.47 + * The rectangle of content that it should send, in the ThebesLayer's 1.48 + * coordinate system. This rectangle is guaranteed to be in the ThebesLayer's 1.49 + * visible region. Translate it to mLayer's coordinate system 1.50 + * by adding mLayer->GetBackgroundLayerOffset(). 1.51 + */ 1.52 + nsIntRect mUpdateRect; 1.53 + /** 1.54 + * The sequence counter value to use when calling DoUpdate 1.55 + */ 1.56 + uint64_t mSequenceCounter; 1.57 + }; 1.58 + /** 1.59 + * Appends any ReadbackLayers that need to be updated, and the rects that 1.60 + * need to be updated, to aUpdates. Only need to call this for ThebesLayers 1.61 + * that have been marked UsedForReadback(). 1.62 + * Each Update's mLayer's mBackgroundLayer will have been set to aLayer. 1.63 + * If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the 1.64 + * ReadbackLayers that needed data from that ThebesLayer will be marked 1.65 + * as having unknown backgrounds. 1.66 + * @param aUpdateRegion if non-null, this region is set to the union 1.67 + * of the mUpdateRects. 1.68 + */ 1.69 + void GetThebesLayerUpdates(ThebesLayer* aLayer, 1.70 + nsTArray<Update>* aUpdates, 1.71 + nsIntRegion* aUpdateRegion = nullptr); 1.72 + 1.73 + ~ReadbackProcessor(); 1.74 + 1.75 +protected: 1.76 + void BuildUpdatesForLayer(ReadbackLayer* aLayer); 1.77 + 1.78 + nsTArray<Update> mAllUpdates; 1.79 +}; 1.80 + 1.81 +} 1.82 +} 1.83 +#endif /* GFX_READBACKPROCESSOR_H */