Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef mozilla_HwcUtils |
michael@0 | 18 | #define mozilla_HwcUtils |
michael@0 | 19 | |
michael@0 | 20 | #include "Layers.h" |
michael@0 | 21 | #include <vector> |
michael@0 | 22 | #include "hardware/hwcomposer.h" |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | |
michael@0 | 26 | class HwcUtils { |
michael@0 | 27 | public: |
michael@0 | 28 | |
michael@0 | 29 | enum { |
michael@0 | 30 | HWC_USE_GPU = HWC_FRAMEBUFFER, |
michael@0 | 31 | HWC_USE_OVERLAY = HWC_OVERLAY, |
michael@0 | 32 | HWC_USE_COPYBIT |
michael@0 | 33 | }; |
michael@0 | 34 | |
michael@0 | 35 | // HWC layer flags |
michael@0 | 36 | enum { |
michael@0 | 37 | // Draw a solid color rectangle |
michael@0 | 38 | // The color should be set on the transform member of the hwc_layer_t struct |
michael@0 | 39 | // The expected format is a 32 bit ABGR with 8 bits per component |
michael@0 | 40 | HWC_COLOR_FILL = 0x8, |
michael@0 | 41 | // Swap the RB pixels of gralloc buffer, like RGBA<->BGRA or RGBX<->BGRX |
michael@0 | 42 | // The flag will be set inside LayerRenderState |
michael@0 | 43 | HWC_FORMAT_RB_SWAP = 0x40 |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | typedef std::vector<hwc_rect_t> RectVector; |
michael@0 | 47 | |
michael@0 | 48 | /* Utility functions - implemented in HwcUtils.cpp */ |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Calculates the layer's clipping rectangle |
michael@0 | 52 | * |
michael@0 | 53 | * @param aTransform Input. A transformation matrix |
michael@0 | 54 | * It transforms the clip rect to screen space |
michael@0 | 55 | * @param aLayerClip Input. The layer's internal clipping rectangle. |
michael@0 | 56 | * This may be NULL which means the layer has no internal clipping |
michael@0 | 57 | * The origin is the top-left corner of the layer |
michael@0 | 58 | * @param aParentClip Input. The parent layer's rendering clipping rectangle |
michael@0 | 59 | * The origin is the top-left corner of the screen |
michael@0 | 60 | * @param aRenderClip Output. The layer's rendering clipping rectangle |
michael@0 | 61 | * The origin is the top-left corner of the screen |
michael@0 | 62 | * @return true if the layer should be rendered. |
michael@0 | 63 | * false if the layer can be skipped |
michael@0 | 64 | */ |
michael@0 | 65 | static bool CalculateClipRect(const gfxMatrix& aTransform, |
michael@0 | 66 | const nsIntRect* aLayerClip, |
michael@0 | 67 | nsIntRect aParentClip, nsIntRect* aRenderClip); |
michael@0 | 68 | |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * Prepares hwc layer visible region required for hwc composition |
michael@0 | 72 | * |
michael@0 | 73 | * @param aVisible Input. Layer's unclipped visible region |
michael@0 | 74 | * The origin is the top-left corner of the layer |
michael@0 | 75 | * @param aTransform Input. Layer's transformation matrix |
michael@0 | 76 | * It transforms from layer space to screen space |
michael@0 | 77 | * @param aClip Input. A clipping rectangle. |
michael@0 | 78 | * The origin is the top-left corner of the screen |
michael@0 | 79 | * @param aBufferRect Input. The layer's buffer bounds |
michael@0 | 80 | * The origin is the top-left corner of the layer |
michael@0 | 81 | * @param aVisibleRegionScreen Output. Visible region in screen space. |
michael@0 | 82 | * The origin is the top-left corner of the screen |
michael@0 | 83 | * @return true if the layer should be rendered. |
michael@0 | 84 | * false if the layer can be skipped |
michael@0 | 85 | */ |
michael@0 | 86 | static bool PrepareVisibleRegion(const nsIntRegion& aVisible, |
michael@0 | 87 | const gfxMatrix& aTransform, |
michael@0 | 88 | nsIntRect aClip, nsIntRect aBufferRect, |
michael@0 | 89 | RectVector* aVisibleRegionScreen); |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Sets hwc layer rectangles required for hwc composition |
michael@0 | 94 | * |
michael@0 | 95 | * @param aVisible Input. Layer's unclipped visible rectangle |
michael@0 | 96 | * The origin is the top-left corner of the layer |
michael@0 | 97 | * @param aTransform Input. Layer's transformation matrix |
michael@0 | 98 | * It transforms from layer space to screen space |
michael@0 | 99 | * @param aClip Input. A clipping rectangle. |
michael@0 | 100 | * The origin is the top-left corner of the screen |
michael@0 | 101 | * @param aBufferRect Input. The layer's buffer bounds |
michael@0 | 102 | * The origin is the top-left corner of the layer |
michael@0 | 103 | * @param aYFlipped Input. true if the buffer is rendered as Y flipped |
michael@0 | 104 | * @param aSurceCrop Output. Area of the source to consider, |
michael@0 | 105 | * the origin is the top-left corner of the buffer |
michael@0 | 106 | * @param aVisibleRegionScreen Output. Visible region in screen space. |
michael@0 | 107 | * The origin is the top-left corner of the screen |
michael@0 | 108 | * @return true if the layer should be rendered. |
michael@0 | 109 | * false if the layer can be skipped |
michael@0 | 110 | */ |
michael@0 | 111 | static bool PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform, |
michael@0 | 112 | nsIntRect aClip, nsIntRect aBufferRect, |
michael@0 | 113 | bool aYFlipped, |
michael@0 | 114 | hwc_rect_t* aSourceCrop, |
michael@0 | 115 | hwc_rect_t* aVisibleRegionScreen); |
michael@0 | 116 | |
michael@0 | 117 | }; |
michael@0 | 118 | |
michael@0 | 119 | } // namespace mozilla |
michael@0 | 120 | |
michael@0 | 121 | #endif // mozilla_HwcUtils |