Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // |
michael@0 | 2 | // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | // RenderStateCache.h: Defines rx::RenderStateCache, a cache of Direct3D render |
michael@0 | 8 | // state objects. |
michael@0 | 9 | |
michael@0 | 10 | #ifndef LIBGLESV2_RENDERER_RENDERSTATECACHE_H_ |
michael@0 | 11 | #define LIBGLESV2_RENDERER_RENDERSTATECACHE_H_ |
michael@0 | 12 | |
michael@0 | 13 | #include "libGLESv2/angletypes.h" |
michael@0 | 14 | #include "common/angleutils.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace rx |
michael@0 | 17 | { |
michael@0 | 18 | |
michael@0 | 19 | class RenderStateCache |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | RenderStateCache(); |
michael@0 | 23 | virtual ~RenderStateCache(); |
michael@0 | 24 | |
michael@0 | 25 | void initialize(ID3D11Device *device); |
michael@0 | 26 | void clear(); |
michael@0 | 27 | |
michael@0 | 28 | // Increments refcount on the returned blend state, Release() must be called. |
michael@0 | 29 | ID3D11BlendState *getBlendState(const gl::BlendState &blendState); |
michael@0 | 30 | ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState, |
michael@0 | 31 | bool scissorEnabled, unsigned int depthSize); |
michael@0 | 32 | ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &dsState); |
michael@0 | 33 | ID3D11SamplerState *getSamplerState(const gl::SamplerState &samplerState); |
michael@0 | 34 | |
michael@0 | 35 | private: |
michael@0 | 36 | DISALLOW_COPY_AND_ASSIGN(RenderStateCache); |
michael@0 | 37 | |
michael@0 | 38 | unsigned long long mCounter; |
michael@0 | 39 | |
michael@0 | 40 | // Blend state cache |
michael@0 | 41 | static std::size_t hashBlendState(const gl::BlendState &blendState); |
michael@0 | 42 | static bool compareBlendStates(const gl::BlendState &a, const gl::BlendState &b); |
michael@0 | 43 | static const unsigned int kMaxBlendStates; |
michael@0 | 44 | |
michael@0 | 45 | typedef std::size_t (*BlendStateHashFunction)(const gl::BlendState &); |
michael@0 | 46 | typedef bool (*BlendStateEqualityFunction)(const gl::BlendState &, const gl::BlendState &); |
michael@0 | 47 | typedef std::pair<ID3D11BlendState*, unsigned long long> BlendStateCounterPair; |
michael@0 | 48 | typedef std::unordered_map<gl::BlendState, BlendStateCounterPair, BlendStateHashFunction, BlendStateEqualityFunction> BlendStateMap; |
michael@0 | 49 | BlendStateMap mBlendStateCache; |
michael@0 | 50 | |
michael@0 | 51 | // Rasterizer state cache |
michael@0 | 52 | struct RasterizerStateKey |
michael@0 | 53 | { |
michael@0 | 54 | gl::RasterizerState rasterizerState; |
michael@0 | 55 | bool scissorEnabled; |
michael@0 | 56 | unsigned int depthSize; |
michael@0 | 57 | }; |
michael@0 | 58 | static std::size_t hashRasterizerState(const RasterizerStateKey &rasterState); |
michael@0 | 59 | static bool compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b); |
michael@0 | 60 | static const unsigned int kMaxRasterizerStates; |
michael@0 | 61 | |
michael@0 | 62 | typedef std::size_t (*RasterizerStateHashFunction)(const RasterizerStateKey &); |
michael@0 | 63 | typedef bool (*RasterizerStateEqualityFunction)(const RasterizerStateKey &, const RasterizerStateKey &); |
michael@0 | 64 | typedef std::pair<ID3D11RasterizerState*, unsigned long long> RasterizerStateCounterPair; |
michael@0 | 65 | typedef std::unordered_map<RasterizerStateKey, RasterizerStateCounterPair, RasterizerStateHashFunction, RasterizerStateEqualityFunction> RasterizerStateMap; |
michael@0 | 66 | RasterizerStateMap mRasterizerStateCache; |
michael@0 | 67 | |
michael@0 | 68 | // Depth stencil state cache |
michael@0 | 69 | static std::size_t hashDepthStencilState(const gl::DepthStencilState &dsState); |
michael@0 | 70 | static bool compareDepthStencilStates(const gl::DepthStencilState &a, const gl::DepthStencilState &b); |
michael@0 | 71 | static const unsigned int kMaxDepthStencilStates; |
michael@0 | 72 | |
michael@0 | 73 | typedef std::size_t (*DepthStencilStateHashFunction)(const gl::DepthStencilState &); |
michael@0 | 74 | typedef bool (*DepthStencilStateEqualityFunction)(const gl::DepthStencilState &, const gl::DepthStencilState &); |
michael@0 | 75 | typedef std::pair<ID3D11DepthStencilState*, unsigned long long> DepthStencilStateCounterPair; |
michael@0 | 76 | typedef std::unordered_map<gl::DepthStencilState, |
michael@0 | 77 | DepthStencilStateCounterPair, |
michael@0 | 78 | DepthStencilStateHashFunction, |
michael@0 | 79 | DepthStencilStateEqualityFunction> DepthStencilStateMap; |
michael@0 | 80 | DepthStencilStateMap mDepthStencilStateCache; |
michael@0 | 81 | |
michael@0 | 82 | // Sample state cache |
michael@0 | 83 | static std::size_t hashSamplerState(const gl::SamplerState &samplerState); |
michael@0 | 84 | static bool compareSamplerStates(const gl::SamplerState &a, const gl::SamplerState &b); |
michael@0 | 85 | static const unsigned int kMaxSamplerStates; |
michael@0 | 86 | |
michael@0 | 87 | typedef std::size_t (*SamplerStateHashFunction)(const gl::SamplerState &); |
michael@0 | 88 | typedef bool (*SamplerStateEqualityFunction)(const gl::SamplerState &, const gl::SamplerState &); |
michael@0 | 89 | typedef std::pair<ID3D11SamplerState*, unsigned long long> SamplerStateCounterPair; |
michael@0 | 90 | typedef std::unordered_map<gl::SamplerState, |
michael@0 | 91 | SamplerStateCounterPair, |
michael@0 | 92 | SamplerStateHashFunction, |
michael@0 | 93 | SamplerStateEqualityFunction> SamplerStateMap; |
michael@0 | 94 | SamplerStateMap mSamplerStateCache; |
michael@0 | 95 | |
michael@0 | 96 | ID3D11Device *mDevice; |
michael@0 | 97 | }; |
michael@0 | 98 | |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | #endif // LIBGLESV2_RENDERER_RENDERSTATECACHE_H_ |