gfx/angle/src/libGLESv2/renderer/RenderStateCache.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 //
     2 // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
     3 // Use of this source code is governed by a BSD-style license that can be
     4 // found in the LICENSE file.
     5 //
     7 // RenderStateCache.h: Defines rx::RenderStateCache, a cache of Direct3D render
     8 // state objects.
    10 #ifndef LIBGLESV2_RENDERER_RENDERSTATECACHE_H_
    11 #define LIBGLESV2_RENDERER_RENDERSTATECACHE_H_
    13 #include "libGLESv2/angletypes.h"
    14 #include "common/angleutils.h"
    16 namespace rx
    17 {
    19 class RenderStateCache
    20 {
    21   public:
    22     RenderStateCache();
    23     virtual ~RenderStateCache();
    25     void initialize(ID3D11Device *device);
    26     void clear();
    28     // Increments refcount on the returned blend state, Release() must be called.
    29     ID3D11BlendState *getBlendState(const gl::BlendState &blendState);
    30     ID3D11RasterizerState *getRasterizerState(const gl::RasterizerState &rasterState,
    31                                               bool scissorEnabled, unsigned int depthSize);
    32     ID3D11DepthStencilState *getDepthStencilState(const gl::DepthStencilState &dsState);
    33     ID3D11SamplerState *getSamplerState(const gl::SamplerState &samplerState);
    35   private:
    36     DISALLOW_COPY_AND_ASSIGN(RenderStateCache);
    38     unsigned long long mCounter;
    40     // Blend state cache
    41     static std::size_t hashBlendState(const gl::BlendState &blendState);
    42     static bool compareBlendStates(const gl::BlendState &a, const gl::BlendState &b);
    43     static const unsigned int kMaxBlendStates;
    45     typedef std::size_t (*BlendStateHashFunction)(const gl::BlendState &);
    46     typedef bool (*BlendStateEqualityFunction)(const gl::BlendState &, const gl::BlendState &);
    47     typedef std::pair<ID3D11BlendState*, unsigned long long> BlendStateCounterPair;
    48     typedef std::unordered_map<gl::BlendState, BlendStateCounterPair, BlendStateHashFunction, BlendStateEqualityFunction> BlendStateMap;
    49     BlendStateMap mBlendStateCache;
    51     // Rasterizer state cache
    52     struct RasterizerStateKey
    53     {
    54         gl::RasterizerState rasterizerState;
    55         bool scissorEnabled;
    56         unsigned int depthSize;
    57     };
    58     static std::size_t hashRasterizerState(const RasterizerStateKey &rasterState);
    59     static bool compareRasterizerStates(const RasterizerStateKey &a, const RasterizerStateKey &b);
    60     static const unsigned int kMaxRasterizerStates;
    62     typedef std::size_t (*RasterizerStateHashFunction)(const RasterizerStateKey &);
    63     typedef bool (*RasterizerStateEqualityFunction)(const RasterizerStateKey &, const RasterizerStateKey &);
    64     typedef std::pair<ID3D11RasterizerState*, unsigned long long> RasterizerStateCounterPair;
    65     typedef std::unordered_map<RasterizerStateKey, RasterizerStateCounterPair, RasterizerStateHashFunction, RasterizerStateEqualityFunction> RasterizerStateMap;
    66     RasterizerStateMap mRasterizerStateCache;
    68     // Depth stencil state cache
    69     static std::size_t hashDepthStencilState(const gl::DepthStencilState &dsState);
    70     static bool compareDepthStencilStates(const gl::DepthStencilState &a, const gl::DepthStencilState &b);
    71     static const unsigned int kMaxDepthStencilStates;
    73     typedef std::size_t (*DepthStencilStateHashFunction)(const gl::DepthStencilState &);
    74     typedef bool (*DepthStencilStateEqualityFunction)(const gl::DepthStencilState &, const gl::DepthStencilState &);
    75     typedef std::pair<ID3D11DepthStencilState*, unsigned long long> DepthStencilStateCounterPair;
    76     typedef std::unordered_map<gl::DepthStencilState,
    77                                DepthStencilStateCounterPair,
    78                                DepthStencilStateHashFunction,
    79                                DepthStencilStateEqualityFunction> DepthStencilStateMap;
    80     DepthStencilStateMap mDepthStencilStateCache;
    82     // Sample state cache
    83     static std::size_t hashSamplerState(const gl::SamplerState &samplerState);
    84     static bool compareSamplerStates(const gl::SamplerState &a, const gl::SamplerState &b);
    85     static const unsigned int kMaxSamplerStates;
    87     typedef std::size_t (*SamplerStateHashFunction)(const gl::SamplerState &);
    88     typedef bool (*SamplerStateEqualityFunction)(const gl::SamplerState &, const gl::SamplerState &);
    89     typedef std::pair<ID3D11SamplerState*, unsigned long long> SamplerStateCounterPair;
    90     typedef std::unordered_map<gl::SamplerState,
    91                                SamplerStateCounterPair,
    92                                SamplerStateHashFunction,
    93                                SamplerStateEqualityFunction> SamplerStateMap;
    94     SamplerStateMap mSamplerStateCache;
    96     ID3D11Device *mDevice;
    97 };
    99 }
   101 #endif // LIBGLESV2_RENDERER_RENDERSTATECACHE_H_

mercurial