Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef MOZILLA_LAYERS_COMPOSITORTYPES_H |
michael@0 | 7 | #define MOZILLA_LAYERS_COMPOSITORTYPES_H |
michael@0 | 8 | |
michael@0 | 9 | #include <stdint.h> // for uint32_t |
michael@0 | 10 | #include <sys/types.h> // for int32_t |
michael@0 | 11 | #include "LayersTypes.h" // for LayersBackend, etc |
michael@0 | 12 | #include "nsXULAppAPI.h" // for GeckoProcessType, etc |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace layers { |
michael@0 | 16 | |
michael@0 | 17 | typedef int32_t SurfaceDescriptorType; |
michael@0 | 18 | const SurfaceDescriptorType SURFACEDESCRIPTOR_UNKNOWN = 0; |
michael@0 | 19 | |
michael@0 | 20 | /** |
michael@0 | 21 | * Flags used by texture clients and texture hosts. These are passed from client |
michael@0 | 22 | * side to host side when textures and compositables are created. Usually set |
michael@0 | 23 | * by the compositableCient, they may be modified by either the compositable or |
michael@0 | 24 | * texture clients. |
michael@0 | 25 | * |
michael@0 | 26 | * XXX - switch to all caps constant names which seems to be the standard in gecko |
michael@0 | 27 | */ |
michael@0 | 28 | typedef uint32_t TextureFlags; |
michael@0 | 29 | // Use nearest-neighbour texture filtering (as opposed to linear filtering). |
michael@0 | 30 | const TextureFlags TEXTURE_USE_NEAREST_FILTER = 1 << 0; |
michael@0 | 31 | // The texture should be flipped around the y-axis when composited. |
michael@0 | 32 | const TextureFlags TEXTURE_NEEDS_Y_FLIP = 1 << 1; |
michael@0 | 33 | // Force the texture to be represented using a single tile (note that this means |
michael@0 | 34 | // tiled textures, not tiled layers). |
michael@0 | 35 | const TextureFlags TEXTURE_DISALLOW_BIGIMAGE = 1 << 2; |
michael@0 | 36 | // Allow using 'repeat' mode for wrapping. |
michael@0 | 37 | const TextureFlags TEXTURE_ALLOW_REPEAT = 1 << 3; |
michael@0 | 38 | // The texture represents a tile which is newly created. |
michael@0 | 39 | const TextureFlags TEXTURE_NEW_TILE = 1 << 4; |
michael@0 | 40 | // The texture is part of a component-alpha pair |
michael@0 | 41 | const TextureFlags TEXTURE_COMPONENT_ALPHA = 1 << 5; |
michael@0 | 42 | // The buffer will be treated as if the RB bytes are swapped. |
michael@0 | 43 | // This is useful for rendering using Cairo/Thebes, because there is no |
michael@0 | 44 | // BGRX Android pixel format, and so we have to do byte swapping. |
michael@0 | 45 | // |
michael@0 | 46 | // For example, if the GraphicBuffer has an Android pixel format of |
michael@0 | 47 | // PIXEL_FORMAT_RGBA_8888 and isRBSwapped is true, when it is sampled |
michael@0 | 48 | // (for example, with GL), a BGRA shader should be used. |
michael@0 | 49 | const TextureFlags TEXTURE_RB_SWAPPED = 1 << 6; |
michael@0 | 50 | |
michael@0 | 51 | const TextureFlags TEXTURE_FRONT = 1 << 12; |
michael@0 | 52 | // A texture host on white for component alpha |
michael@0 | 53 | const TextureFlags TEXTURE_ON_WHITE = 1 << 13; |
michael@0 | 54 | // A texture host on black for component alpha |
michael@0 | 55 | const TextureFlags TEXTURE_ON_BLACK = 1 << 14; |
michael@0 | 56 | // A texture host that supports tiling |
michael@0 | 57 | const TextureFlags TEXTURE_TILE = 1 << 15; |
michael@0 | 58 | // A texture should be recycled when no longer in used |
michael@0 | 59 | const TextureFlags TEXTURE_RECYCLE = 1 << 16; |
michael@0 | 60 | // Texture contents should be initialized |
michael@0 | 61 | // from the previous texture. |
michael@0 | 62 | const TextureFlags TEXTURE_COPY_PREVIOUS = 1 << 24; |
michael@0 | 63 | // Who is responsible for deallocating the shared data. |
michael@0 | 64 | // if TEXTURE_DEALLOCATE_CLIENT is set, the shared data is deallocated on the |
michael@0 | 65 | // client side and requires some extra synchronizaion to ensure race-free |
michael@0 | 66 | // deallocation. |
michael@0 | 67 | // The default behaviour is to deallocate on the host side. |
michael@0 | 68 | const TextureFlags TEXTURE_DEALLOCATE_CLIENT = 1 << 25; |
michael@0 | 69 | // After being shared ith the compositor side, an immutable texture is never |
michael@0 | 70 | // modified, it can only be read. It is safe to not Lock/Unlock immutable |
michael@0 | 71 | // textures. |
michael@0 | 72 | const TextureFlags TEXTURE_IMMUTABLE = 1 << 27; |
michael@0 | 73 | // The contents of the texture must be uploaded or copied immediately |
michael@0 | 74 | // during the transaction, because the producer may want to write |
michael@0 | 75 | // to it again. |
michael@0 | 76 | const TextureFlags TEXTURE_IMMEDIATE_UPLOAD = 1 << 28; |
michael@0 | 77 | // The texture is going to be used as part of a double |
michael@0 | 78 | // buffered pair, and so we can guarantee that the producer/consumer |
michael@0 | 79 | // won't be racing to access its contents. |
michael@0 | 80 | const TextureFlags TEXTURE_DOUBLE_BUFFERED = 1 << 29; |
michael@0 | 81 | // We've previously tried a texture and it didn't work for some reason. If there |
michael@0 | 82 | // is a fallback available, try that. |
michael@0 | 83 | const TextureFlags TEXTURE_ALLOC_FALLBACK = 1 << 31; |
michael@0 | 84 | |
michael@0 | 85 | // the default flags |
michael@0 | 86 | const TextureFlags TEXTURE_FLAGS_DEFAULT = TEXTURE_FRONT; |
michael@0 | 87 | |
michael@0 | 88 | static inline bool |
michael@0 | 89 | TextureRequiresLocking(TextureFlags aFlags) |
michael@0 | 90 | { |
michael@0 | 91 | // If we're not double buffered, or uploading |
michael@0 | 92 | // within a transaction, then we need to support |
michael@0 | 93 | // locking correctly. |
michael@0 | 94 | return !(aFlags & (TEXTURE_IMMEDIATE_UPLOAD | |
michael@0 | 95 | TEXTURE_DOUBLE_BUFFERED | |
michael@0 | 96 | TEXTURE_IMMUTABLE)); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | /** |
michael@0 | 100 | * The type of debug diagnostic to enable. |
michael@0 | 101 | */ |
michael@0 | 102 | typedef uint32_t DiagnosticTypes; |
michael@0 | 103 | const DiagnosticTypes DIAGNOSTIC_NONE = 0; |
michael@0 | 104 | const DiagnosticTypes DIAGNOSTIC_TILE_BORDERS = 1 << 0; |
michael@0 | 105 | const DiagnosticTypes DIAGNOSTIC_LAYER_BORDERS = 1 << 1; |
michael@0 | 106 | const DiagnosticTypes DIAGNOSTIC_BIGIMAGE_BORDERS = 1 << 2; |
michael@0 | 107 | const DiagnosticTypes DIAGNOSTIC_FLASH_BORDERS = 1 << 3; |
michael@0 | 108 | |
michael@0 | 109 | #define DIAGNOSTIC_FLASH_COUNTER_MAX 100 |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * Information about the object that is being diagnosed. |
michael@0 | 113 | */ |
michael@0 | 114 | typedef uint32_t DiagnosticFlags; |
michael@0 | 115 | const DiagnosticFlags DIAGNOSTIC_IMAGE = 1 << 0; |
michael@0 | 116 | const DiagnosticFlags DIAGNOSTIC_CONTENT = 1 << 1; |
michael@0 | 117 | const DiagnosticFlags DIAGNOSTIC_CANVAS = 1 << 2; |
michael@0 | 118 | const DiagnosticFlags DIAGNOSTIC_COLOR = 1 << 3; |
michael@0 | 119 | const DiagnosticFlags DIAGNOSTIC_CONTAINER = 1 << 4; |
michael@0 | 120 | const DiagnosticFlags DIAGNOSTIC_TILE = 1 << 5; |
michael@0 | 121 | const DiagnosticFlags DIAGNOSTIC_BIGIMAGE = 1 << 6; |
michael@0 | 122 | const DiagnosticFlags DIAGNOSTIC_COMPONENT_ALPHA = 1 << 7; |
michael@0 | 123 | const DiagnosticFlags DIAGNOSTIC_REGION_RECT = 1 << 8; |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * See gfx/layers/Effects.h |
michael@0 | 127 | */ |
michael@0 | 128 | enum EffectTypes |
michael@0 | 129 | { |
michael@0 | 130 | EFFECT_MASK, |
michael@0 | 131 | EFFECT_MAX_SECONDARY, // sentinel for the count of secondary effect types |
michael@0 | 132 | EFFECT_RGB, |
michael@0 | 133 | EFFECT_YCBCR, |
michael@0 | 134 | EFFECT_COMPONENT_ALPHA, |
michael@0 | 135 | EFFECT_SOLID_COLOR, |
michael@0 | 136 | EFFECT_RENDER_TARGET, |
michael@0 | 137 | EFFECT_MAX //sentinel for the count of all effect types |
michael@0 | 138 | }; |
michael@0 | 139 | |
michael@0 | 140 | /** |
michael@0 | 141 | * How the Compositable should manage textures. |
michael@0 | 142 | */ |
michael@0 | 143 | enum CompositableType |
michael@0 | 144 | { |
michael@0 | 145 | BUFFER_UNKNOWN, |
michael@0 | 146 | // the deprecated compositable types |
michael@0 | 147 | BUFFER_IMAGE_SINGLE, // image/canvas with a single texture, single buffered |
michael@0 | 148 | BUFFER_IMAGE_BUFFERED, // canvas, double buffered |
michael@0 | 149 | BUFFER_BRIDGE, // image bridge protocol |
michael@0 | 150 | BUFFER_CONTENT_INC, // thebes layer interface, only sends incremental |
michael@0 | 151 | // updates to a texture on the compositor side. |
michael@0 | 152 | // somewhere in the middle |
michael@0 | 153 | BUFFER_TILED, // tiled thebes layer |
michael@0 | 154 | BUFFER_SIMPLE_TILED, |
michael@0 | 155 | // the new compositable types |
michael@0 | 156 | COMPOSITABLE_IMAGE, // image with single buffering |
michael@0 | 157 | COMPOSITABLE_CONTENT_SINGLE, // thebes layer interface, single buffering |
michael@0 | 158 | COMPOSITABLE_CONTENT_DOUBLE, // thebes layer interface, double buffering |
michael@0 | 159 | BUFFER_COUNT |
michael@0 | 160 | }; |
michael@0 | 161 | |
michael@0 | 162 | /** |
michael@0 | 163 | * How the texture host is used for composition, |
michael@0 | 164 | */ |
michael@0 | 165 | enum DeprecatedTextureHostFlags |
michael@0 | 166 | { |
michael@0 | 167 | TEXTURE_HOST_DEFAULT = 0, // The default texture host for the given |
michael@0 | 168 | // SurfaceDescriptor |
michael@0 | 169 | TEXTURE_HOST_TILED = 1 << 0, // A texture host that supports tiling |
michael@0 | 170 | TEXTURE_HOST_COPY_PREVIOUS = 1 << 1 // Texture contents should be initialized |
michael@0 | 171 | // from the previous texture. |
michael@0 | 172 | }; |
michael@0 | 173 | |
michael@0 | 174 | /** |
michael@0 | 175 | * Sent from the compositor to the content-side LayerManager, includes properties |
michael@0 | 176 | * of the compositor and should (in the future) include information about what |
michael@0 | 177 | * kinds of buffer and texture clients to create. |
michael@0 | 178 | */ |
michael@0 | 179 | struct TextureFactoryIdentifier |
michael@0 | 180 | { |
michael@0 | 181 | LayersBackend mParentBackend; |
michael@0 | 182 | GeckoProcessType mParentProcessId; |
michael@0 | 183 | int32_t mMaxTextureSize; |
michael@0 | 184 | bool mSupportsTextureBlitting; |
michael@0 | 185 | bool mSupportsPartialUploads; |
michael@0 | 186 | |
michael@0 | 187 | TextureFactoryIdentifier(LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE, |
michael@0 | 188 | GeckoProcessType aParentProcessId = GeckoProcessType_Default, |
michael@0 | 189 | int32_t aMaxTextureSize = 0, |
michael@0 | 190 | bool aSupportsTextureBlitting = false, |
michael@0 | 191 | bool aSupportsPartialUploads = false) |
michael@0 | 192 | : mParentBackend(aLayersBackend) |
michael@0 | 193 | , mParentProcessId(aParentProcessId) |
michael@0 | 194 | , mMaxTextureSize(aMaxTextureSize) |
michael@0 | 195 | , mSupportsTextureBlitting(aSupportsTextureBlitting) |
michael@0 | 196 | , mSupportsPartialUploads(aSupportsPartialUploads) |
michael@0 | 197 | {} |
michael@0 | 198 | }; |
michael@0 | 199 | |
michael@0 | 200 | /** |
michael@0 | 201 | * Identify a texture to a compositable. Many textures can have the same id, but |
michael@0 | 202 | * the id is unique for any texture owned by a particular compositable. |
michael@0 | 203 | * XXX - This is now redundant with TextureFlags. it ill be removed along with |
michael@0 | 204 | * deprecated texture classes. |
michael@0 | 205 | */ |
michael@0 | 206 | typedef uint32_t TextureIdentifier; |
michael@0 | 207 | const TextureIdentifier TextureFront = 1; |
michael@0 | 208 | const TextureIdentifier TextureBack = 2; |
michael@0 | 209 | const TextureIdentifier TextureOnWhiteFront = 3; |
michael@0 | 210 | const TextureIdentifier TextureOnWhiteBack = 4; |
michael@0 | 211 | |
michael@0 | 212 | /** |
michael@0 | 213 | * Information required by the compositor from the content-side for creating or |
michael@0 | 214 | * using compositables and textures. |
michael@0 | 215 | * XXX - TextureInfo is a bad name: this information is useful for the compositable, |
michael@0 | 216 | * not the Texture. And ith new Textures, only the compositable type is really |
michael@0 | 217 | * useful. This may (should) be removed in the near future. |
michael@0 | 218 | */ |
michael@0 | 219 | struct TextureInfo |
michael@0 | 220 | { |
michael@0 | 221 | CompositableType mCompositableType; |
michael@0 | 222 | uint32_t mDeprecatedTextureHostFlags; |
michael@0 | 223 | uint32_t mTextureFlags; |
michael@0 | 224 | |
michael@0 | 225 | TextureInfo() |
michael@0 | 226 | : mCompositableType(BUFFER_UNKNOWN) |
michael@0 | 227 | , mDeprecatedTextureHostFlags(0) |
michael@0 | 228 | , mTextureFlags(0) |
michael@0 | 229 | {} |
michael@0 | 230 | |
michael@0 | 231 | TextureInfo(CompositableType aType) |
michael@0 | 232 | : mCompositableType(aType) |
michael@0 | 233 | , mDeprecatedTextureHostFlags(0) |
michael@0 | 234 | , mTextureFlags(0) |
michael@0 | 235 | {} |
michael@0 | 236 | |
michael@0 | 237 | bool operator==(const TextureInfo& aOther) const |
michael@0 | 238 | { |
michael@0 | 239 | return mCompositableType == aOther.mCompositableType && |
michael@0 | 240 | mDeprecatedTextureHostFlags == aOther.mDeprecatedTextureHostFlags && |
michael@0 | 241 | mTextureFlags == aOther.mTextureFlags; |
michael@0 | 242 | } |
michael@0 | 243 | }; |
michael@0 | 244 | |
michael@0 | 245 | /** |
michael@0 | 246 | * How a SurfaceDescriptor will be opened. |
michael@0 | 247 | * |
michael@0 | 248 | * See ShadowLayerForwarder::OpenDescriptor for example. |
michael@0 | 249 | */ |
michael@0 | 250 | typedef uint32_t OpenMode; |
michael@0 | 251 | const OpenMode OPEN_READ = 0x1; |
michael@0 | 252 | const OpenMode OPEN_WRITE = 0x2; |
michael@0 | 253 | const OpenMode OPEN_READ_WRITE = OPEN_READ|OPEN_WRITE; |
michael@0 | 254 | const OpenMode OPEN_READ_ONLY = OPEN_READ; |
michael@0 | 255 | const OpenMode OPEN_WRITE_ONLY = OPEN_WRITE; |
michael@0 | 256 | |
michael@0 | 257 | // The kinds of mask texture a shader can support |
michael@0 | 258 | // We rely on the items in this enum being sequential |
michael@0 | 259 | enum MaskType { |
michael@0 | 260 | MaskNone = 0, // no mask layer |
michael@0 | 261 | Mask2d, // mask layer for layers with 2D transforms |
michael@0 | 262 | Mask3d, // mask layer for layers with 3D transforms |
michael@0 | 263 | NumMaskTypes |
michael@0 | 264 | }; |
michael@0 | 265 | |
michael@0 | 266 | } // namespace layers |
michael@0 | 267 | } // namespace mozilla |
michael@0 | 268 | |
michael@0 | 269 | #endif |