Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; 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 GFX_LAYERSTYPES_H |
michael@0 | 7 | #define GFX_LAYERSTYPES_H |
michael@0 | 8 | |
michael@0 | 9 | #include <stdint.h> // for uint32_t |
michael@0 | 10 | #include "nsPoint.h" // for nsIntPoint |
michael@0 | 11 | #include "nsRegion.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "mozilla/TypedEnum.h" |
michael@0 | 14 | |
michael@0 | 15 | #ifdef MOZ_WIDGET_GONK |
michael@0 | 16 | #include <ui/GraphicBuffer.h> |
michael@0 | 17 | #endif |
michael@0 | 18 | #if defined(DEBUG) || defined(PR_LOGGING) |
michael@0 | 19 | # include <stdio.h> // FILE |
michael@0 | 20 | # include "prlog.h" // for PR_LOG |
michael@0 | 21 | # ifndef MOZ_LAYERS_HAVE_LOG |
michael@0 | 22 | # define MOZ_LAYERS_HAVE_LOG |
michael@0 | 23 | # endif |
michael@0 | 24 | # define MOZ_LAYERS_LOG(_args) \ |
michael@0 | 25 | PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args) |
michael@0 | 26 | # define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args) \ |
michael@0 | 27 | do { if (layer->AsShadowableLayer()) { PR_LOG(LayerManager::GetLog(), PR_LOG_DEBUG, _args); } } while (0) |
michael@0 | 28 | #else |
michael@0 | 29 | struct PRLogModuleInfo; |
michael@0 | 30 | # define MOZ_LAYERS_LOG(_args) |
michael@0 | 31 | # define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args) |
michael@0 | 32 | #endif // if defined(DEBUG) || defined(PR_LOGGING) |
michael@0 | 33 | |
michael@0 | 34 | namespace android { |
michael@0 | 35 | class GraphicBuffer; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | namespace mozilla { |
michael@0 | 39 | namespace layers { |
michael@0 | 40 | |
michael@0 | 41 | class TextureHost; |
michael@0 | 42 | |
michael@0 | 43 | typedef uint32_t TextureFlags; |
michael@0 | 44 | |
michael@0 | 45 | #undef NONE |
michael@0 | 46 | #undef OPAQUE |
michael@0 | 47 | |
michael@0 | 48 | MOZ_BEGIN_ENUM_CLASS(LayersBackend, int8_t) |
michael@0 | 49 | LAYERS_NONE = 0, |
michael@0 | 50 | LAYERS_BASIC, |
michael@0 | 51 | LAYERS_OPENGL, |
michael@0 | 52 | LAYERS_D3D9, |
michael@0 | 53 | LAYERS_D3D10, |
michael@0 | 54 | LAYERS_D3D11, |
michael@0 | 55 | LAYERS_CLIENT, |
michael@0 | 56 | LAYERS_LAST |
michael@0 | 57 | MOZ_END_ENUM_CLASS(LayersBackend) |
michael@0 | 58 | |
michael@0 | 59 | MOZ_BEGIN_ENUM_CLASS(BufferMode, int8_t) |
michael@0 | 60 | BUFFER_NONE, |
michael@0 | 61 | BUFFERED |
michael@0 | 62 | MOZ_END_ENUM_CLASS(BufferMode) |
michael@0 | 63 | |
michael@0 | 64 | MOZ_BEGIN_ENUM_CLASS(DrawRegionClip, int8_t) |
michael@0 | 65 | DRAW, |
michael@0 | 66 | DRAW_SNAPPED, |
michael@0 | 67 | CLIP_NONE |
michael@0 | 68 | MOZ_END_ENUM_CLASS(DrawRegionClip) |
michael@0 | 69 | |
michael@0 | 70 | MOZ_BEGIN_ENUM_CLASS(SurfaceMode, int8_t) |
michael@0 | 71 | SURFACE_NONE = 0, |
michael@0 | 72 | SURFACE_OPAQUE, |
michael@0 | 73 | SURFACE_SINGLE_CHANNEL_ALPHA, |
michael@0 | 74 | SURFACE_COMPONENT_ALPHA |
michael@0 | 75 | MOZ_END_ENUM_CLASS(SurfaceMode) |
michael@0 | 76 | |
michael@0 | 77 | // LayerRenderState for Composer2D |
michael@0 | 78 | // We currently only support Composer2D using gralloc. If we want to be backed |
michael@0 | 79 | // by other surfaces we will need a more generic LayerRenderState. |
michael@0 | 80 | enum LayerRenderStateFlags { |
michael@0 | 81 | LAYER_RENDER_STATE_Y_FLIPPED = 1 << 0, |
michael@0 | 82 | LAYER_RENDER_STATE_BUFFER_ROTATION = 1 << 1, |
michael@0 | 83 | // Notify Composer2D to swap the RB pixels of gralloc buffer |
michael@0 | 84 | LAYER_RENDER_STATE_FORMAT_RB_SWAP = 1 << 2 |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | // The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include |
michael@0 | 88 | // android::sp unless we have to. |
michael@0 | 89 | struct LayerRenderState { |
michael@0 | 90 | LayerRenderState() |
michael@0 | 91 | #ifdef MOZ_WIDGET_GONK |
michael@0 | 92 | : mSurface(nullptr), mTexture(nullptr), mFlags(0), mHasOwnOffset(false) |
michael@0 | 93 | #endif |
michael@0 | 94 | {} |
michael@0 | 95 | |
michael@0 | 96 | #ifdef MOZ_WIDGET_GONK |
michael@0 | 97 | LayerRenderState(android::GraphicBuffer* aSurface, |
michael@0 | 98 | const nsIntSize& aSize, |
michael@0 | 99 | uint32_t aFlags, |
michael@0 | 100 | TextureHost* aTexture) |
michael@0 | 101 | : mSurface(aSurface) |
michael@0 | 102 | , mSize(aSize) |
michael@0 | 103 | , mTexture(aTexture) |
michael@0 | 104 | , mFlags(aFlags) |
michael@0 | 105 | , mHasOwnOffset(false) |
michael@0 | 106 | {} |
michael@0 | 107 | |
michael@0 | 108 | bool YFlipped() const |
michael@0 | 109 | { return mFlags & LAYER_RENDER_STATE_Y_FLIPPED; } |
michael@0 | 110 | |
michael@0 | 111 | bool BufferRotated() const |
michael@0 | 112 | { return mFlags & LAYER_RENDER_STATE_BUFFER_ROTATION; } |
michael@0 | 113 | |
michael@0 | 114 | bool FormatRBSwapped() const |
michael@0 | 115 | { return mFlags & LAYER_RENDER_STATE_FORMAT_RB_SWAP; } |
michael@0 | 116 | #endif |
michael@0 | 117 | |
michael@0 | 118 | void SetOffset(const nsIntPoint& aOffset) |
michael@0 | 119 | { |
michael@0 | 120 | mOffset = aOffset; |
michael@0 | 121 | mHasOwnOffset = true; |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | #ifdef MOZ_WIDGET_GONK |
michael@0 | 125 | // surface to render |
michael@0 | 126 | android::sp<android::GraphicBuffer> mSurface; |
michael@0 | 127 | // size of mSurface |
michael@0 | 128 | nsIntSize mSize; |
michael@0 | 129 | TextureHost* mTexture; |
michael@0 | 130 | #endif |
michael@0 | 131 | // see LayerRenderStateFlags |
michael@0 | 132 | uint32_t mFlags; |
michael@0 | 133 | // the location of the layer's origin on mSurface |
michael@0 | 134 | nsIntPoint mOffset; |
michael@0 | 135 | // true if mOffset is applicable |
michael@0 | 136 | bool mHasOwnOffset; |
michael@0 | 137 | }; |
michael@0 | 138 | |
michael@0 | 139 | MOZ_BEGIN_ENUM_CLASS(ScaleMode, int8_t) |
michael@0 | 140 | SCALE_NONE, |
michael@0 | 141 | STRETCH, |
michael@0 | 142 | SENTINEL |
michael@0 | 143 | // Unimplemented - PRESERVE_ASPECT_RATIO_CONTAIN |
michael@0 | 144 | MOZ_END_ENUM_CLASS(ScaleMode) |
michael@0 | 145 | |
michael@0 | 146 | struct EventRegions { |
michael@0 | 147 | nsIntRegion mHitRegion; |
michael@0 | 148 | nsIntRegion mDispatchToContentHitRegion; |
michael@0 | 149 | |
michael@0 | 150 | bool operator==(const EventRegions& aRegions) const |
michael@0 | 151 | { |
michael@0 | 152 | return mHitRegion == aRegions.mHitRegion && |
michael@0 | 153 | mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion; |
michael@0 | 154 | } |
michael@0 | 155 | bool operator!=(const EventRegions& aRegions) const |
michael@0 | 156 | { |
michael@0 | 157 | return !(*this == aRegions); |
michael@0 | 158 | } |
michael@0 | 159 | |
michael@0 | 160 | nsCString ToString() const |
michael@0 | 161 | { |
michael@0 | 162 | nsCString result = mHitRegion.ToString(); |
michael@0 | 163 | result.AppendLiteral(";dispatchToContent="); |
michael@0 | 164 | result.Append(mDispatchToContentHitRegion.ToString()); |
michael@0 | 165 | return result; |
michael@0 | 166 | } |
michael@0 | 167 | }; |
michael@0 | 168 | |
michael@0 | 169 | } // namespace |
michael@0 | 170 | } // namespace |
michael@0 | 171 | |
michael@0 | 172 | #endif /* GFX_LAYERSTYPES_H */ |