gfx/layers/ipc/CompositableForwarder.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef MOZILLA_LAYERS_COMPOSITABLEFORWARDER
michael@0 8 #define MOZILLA_LAYERS_COMPOSITABLEFORWARDER
michael@0 9
michael@0 10 #include <stdint.h> // for int32_t, uint64_t
michael@0 11 #include "gfxTypes.h"
michael@0 12 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
michael@0 13 #include "mozilla/layers/CompositorTypes.h"
michael@0 14 #include "mozilla/layers/ISurfaceAllocator.h" // for ISurfaceAllocator
michael@0 15 #include "mozilla/layers/LayersTypes.h" // for LayersBackend
michael@0 16 #include "mozilla/layers/TextureClient.h" // for TextureClient
michael@0 17 #include "nsRegion.h" // for nsIntRegion
michael@0 18
michael@0 19 struct nsIntPoint;
michael@0 20 struct nsIntRect;
michael@0 21
michael@0 22 namespace mozilla {
michael@0 23 namespace layers {
michael@0 24
michael@0 25 class CompositableClient;
michael@0 26 class TextureFactoryIdentifier;
michael@0 27 class SurfaceDescriptor;
michael@0 28 class SurfaceDescriptorTiles;
michael@0 29 class ThebesBufferData;
michael@0 30 class ClientTiledLayerBuffer;
michael@0 31 class PTextureChild;
michael@0 32
michael@0 33 /**
michael@0 34 * A transaction is a set of changes that happenned on the content side, that
michael@0 35 * should be sent to the compositor side.
michael@0 36 * CompositableForwarder is an interface to manage a transaction of
michael@0 37 * compositable objetcs.
michael@0 38 *
michael@0 39 * ShadowLayerForwarder is an example of a CompositableForwarder (that can
michael@0 40 * additionally forward modifications of the Layer tree).
michael@0 41 * ImageBridgeChild is another CompositableForwarder.
michael@0 42 */
michael@0 43 class CompositableForwarder : public ISurfaceAllocator
michael@0 44 {
michael@0 45 public:
michael@0 46
michael@0 47 CompositableForwarder()
michael@0 48 : mSerial(++sSerialCounter)
michael@0 49 {}
michael@0 50
michael@0 51 /**
michael@0 52 * Setup the IPDL actor for aCompositable to be part of layers
michael@0 53 * transactions.
michael@0 54 */
michael@0 55 virtual void Connect(CompositableClient* aCompositable) = 0;
michael@0 56
michael@0 57 /**
michael@0 58 * Notify the CompositableHost that it should create host-side-only
michael@0 59 * texture(s), that we will update incrementally using UpdateTextureIncremental.
michael@0 60 */
michael@0 61 virtual void CreatedIncrementalBuffer(CompositableClient* aCompositable,
michael@0 62 const TextureInfo& aTextureInfo,
michael@0 63 const nsIntRect& aBufferRect) = 0;
michael@0 64
michael@0 65 /**
michael@0 66 * Tell the CompositableHost on the compositor side what TiledLayerBuffer to
michael@0 67 * use for the next composition.
michael@0 68 */
michael@0 69 virtual void UseTiledLayerBuffer(CompositableClient* aCompositable,
michael@0 70 const SurfaceDescriptorTiles& aTiledDescriptor) = 0;
michael@0 71
michael@0 72 /**
michael@0 73 * Create a TextureChild/Parent pair as as well as the TextureHost on the parent side.
michael@0 74 */
michael@0 75 virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData, TextureFlags aFlags) = 0;
michael@0 76
michael@0 77 /**
michael@0 78 * Communicate to the compositor that aRegion in the texture identified by
michael@0 79 * aCompositable and aIdentifier has been updated to aThebesBuffer.
michael@0 80 */
michael@0 81 virtual void UpdateTextureRegion(CompositableClient* aCompositable,
michael@0 82 const ThebesBufferData& aThebesBufferData,
michael@0 83 const nsIntRegion& aUpdatedRegion) = 0;
michael@0 84
michael@0 85 /**
michael@0 86 * Notify the compositor to update aTextureId using aDescriptor, and take
michael@0 87 * ownership of aDescriptor.
michael@0 88 *
michael@0 89 * aDescriptor only contains the pixels for aUpdatedRegion, and is relative
michael@0 90 * to aUpdatedRegion.TopLeft().
michael@0 91 *
michael@0 92 * aBufferRect/aBufferRotation define the new valid region contained
michael@0 93 * within the texture after the update has been applied.
michael@0 94 */
michael@0 95 virtual void UpdateTextureIncremental(CompositableClient* aCompositable,
michael@0 96 TextureIdentifier aTextureId,
michael@0 97 SurfaceDescriptor& aDescriptor,
michael@0 98 const nsIntRegion& aUpdatedRegion,
michael@0 99 const nsIntRect& aBufferRect,
michael@0 100 const nsIntPoint& aBufferRotation) = 0;
michael@0 101
michael@0 102 /**
michael@0 103 * Communicate the picture rect of a YUV image in aLayer to the compositor
michael@0 104 */
michael@0 105 virtual void UpdatePictureRect(CompositableClient* aCompositable,
michael@0 106 const nsIntRect& aRect) = 0;
michael@0 107
michael@0 108 /**
michael@0 109 * Tell the CompositableHost on the compositor side to remove the texture.
michael@0 110 * This function does not delete the TextureHost corresponding to the
michael@0 111 * TextureClient passed in parameter.
michael@0 112 */
michael@0 113 virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
michael@0 114 TextureClient* aTexture) = 0;
michael@0 115
michael@0 116 /**
michael@0 117 * Tell the compositor side to delete the TextureHost corresponding to the
michael@0 118 * TextureClient passed in parameter.
michael@0 119 */
michael@0 120 virtual void RemoveTexture(TextureClient* aTexture) = 0;
michael@0 121
michael@0 122 /**
michael@0 123 * Holds a reference to a TextureClient until after the next
michael@0 124 * compositor transaction, and then drops it.
michael@0 125 */
michael@0 126 virtual void HoldUntilTransaction(TextureClient* aClient)
michael@0 127 {
michael@0 128 if (aClient) {
michael@0 129 mTexturesToRemove.AppendElement(aClient);
michael@0 130 }
michael@0 131 }
michael@0 132
michael@0 133 /**
michael@0 134 * Forcibly remove texture data from TextureClient
michael@0 135 * This function needs to be called after a tansaction with Compositor.
michael@0 136 */
michael@0 137 virtual void RemoveTexturesIfNecessary()
michael@0 138 {
michael@0 139 mTexturesToRemove.Clear();
michael@0 140 }
michael@0 141
michael@0 142 /**
michael@0 143 * Tell the CompositableHost on the compositor side what texture to use for
michael@0 144 * the next composition.
michael@0 145 */
michael@0 146 virtual void UseTexture(CompositableClient* aCompositable,
michael@0 147 TextureClient* aClient) = 0;
michael@0 148 virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
michael@0 149 TextureClient* aClientOnBlack,
michael@0 150 TextureClient* aClientOnWhite) = 0;
michael@0 151
michael@0 152 /**
michael@0 153 * Tell the compositor side that the shared data has been modified so that
michael@0 154 * it can react accordingly (upload textures, etc.).
michael@0 155 */
michael@0 156 virtual void UpdatedTexture(CompositableClient* aCompositable,
michael@0 157 TextureClient* aTexture,
michael@0 158 nsIntRegion* aRegion) = 0;
michael@0 159
michael@0 160 void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
michael@0 161
michael@0 162 virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE
michael@0 163 {
michael@0 164 return mTextureFactoryIdentifier.mMaxTextureSize;
michael@0 165 }
michael@0 166
michael@0 167 bool IsOnCompositorSide() const MOZ_OVERRIDE { return false; }
michael@0 168
michael@0 169 /**
michael@0 170 * Returns the type of backend that is used off the main thread.
michael@0 171 * We only don't allow changing the backend type at runtime so this value can
michael@0 172 * be queried once and will not change until Gecko is restarted.
michael@0 173 */
michael@0 174 virtual LayersBackend GetCompositorBackendType() const MOZ_OVERRIDE
michael@0 175 {
michael@0 176 return mTextureFactoryIdentifier.mParentBackend;
michael@0 177 }
michael@0 178
michael@0 179 bool SupportsTextureBlitting() const
michael@0 180 {
michael@0 181 return mTextureFactoryIdentifier.mSupportsTextureBlitting;
michael@0 182 }
michael@0 183
michael@0 184 bool SupportsPartialUploads() const
michael@0 185 {
michael@0 186 return mTextureFactoryIdentifier.mSupportsPartialUploads;
michael@0 187 }
michael@0 188
michael@0 189 const TextureFactoryIdentifier& GetTextureFactoryIdentifier() const
michael@0 190 {
michael@0 191 return mTextureFactoryIdentifier;
michael@0 192 }
michael@0 193
michael@0 194 int32_t GetSerial() { return mSerial; }
michael@0 195
michael@0 196 protected:
michael@0 197 TextureFactoryIdentifier mTextureFactoryIdentifier;
michael@0 198 nsTArray<RefPtr<TextureClient> > mTexturesToRemove;
michael@0 199 const int32_t mSerial;
michael@0 200 static mozilla::Atomic<int32_t> sSerialCounter;
michael@0 201 };
michael@0 202
michael@0 203 } // namespace
michael@0 204 } // namespace
michael@0 205
michael@0 206 #endif

mercurial