gfx/layers/client/TextureClientPool.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.

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_GFX_TEXTURECLIENTPOOL_H
michael@0 7 #define MOZILLA_GFX_TEXTURECLIENTPOOL_H
michael@0 8
michael@0 9 #include "mozilla/gfx/Types.h"
michael@0 10 #include "mozilla/gfx/Point.h"
michael@0 11 #include "mozilla/RefPtr.h"
michael@0 12 #include "TextureClient.h"
michael@0 13 #include "nsITimer.h"
michael@0 14 #include <stack>
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace layers {
michael@0 18
michael@0 19 class ISurfaceAllocator;
michael@0 20
michael@0 21 class TextureClientPool MOZ_FINAL
michael@0 22 {
michael@0 23 ~TextureClientPool();
michael@0 24
michael@0 25 public:
michael@0 26 NS_INLINE_DECL_REFCOUNTING(TextureClientPool)
michael@0 27
michael@0 28 TextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
michael@0 29 ISurfaceAllocator *aAllocator);
michael@0 30
michael@0 31 /**
michael@0 32 * Gets an allocated TextureClient of size and format that are determined
michael@0 33 * by the initialisation parameters given to the pool. This will either be
michael@0 34 * a cached client that was returned to the pool, or a newly allocated
michael@0 35 * client if one isn't available.
michael@0 36 *
michael@0 37 * All clients retrieved by this method should be returned using the return
michael@0 38 * functions, or reported lost so that the pool can manage its size correctly.
michael@0 39 */
michael@0 40 TemporaryRef<TextureClient> GetTextureClient();
michael@0 41
michael@0 42 /**
michael@0 43 * Return a TextureClient that is no longer being used and is ready for
michael@0 44 * immediate re-use or destruction.
michael@0 45 */
michael@0 46 void ReturnTextureClient(TextureClient *aClient);
michael@0 47
michael@0 48 /**
michael@0 49 * Return a TextureClient that is not yet ready to be reused, but will be
michael@0 50 * imminently.
michael@0 51 */
michael@0 52 void ReturnTextureClientDeferred(TextureClient *aClient);
michael@0 53
michael@0 54 /**
michael@0 55 * Attempt to shrink the pool so that there are no more than
michael@0 56 * sMaxTextureClients clients outstanding.
michael@0 57 */
michael@0 58 void ShrinkToMaximumSize();
michael@0 59
michael@0 60 /**
michael@0 61 * Attempt to shrink the pool so that there are no more than sMinCacheSize
michael@0 62 * unused clients.
michael@0 63 */
michael@0 64 void ShrinkToMinimumSize();
michael@0 65
michael@0 66 /**
michael@0 67 * Return any clients to the pool that were previously returned in
michael@0 68 * ReturnTextureClientDeferred.
michael@0 69 */
michael@0 70 void ReturnDeferredClients();
michael@0 71
michael@0 72 /**
michael@0 73 * Report that a client retrieved via GetTextureClient() has become
michael@0 74 * unusable, so that it will no longer be tracked.
michael@0 75 */
michael@0 76 void ReportClientLost() { mOutstandingClients--; }
michael@0 77
michael@0 78 /**
michael@0 79 * Calling this will cause the pool to attempt to relinquish any unused
michael@0 80 * clients.
michael@0 81 */
michael@0 82 void Clear();
michael@0 83
michael@0 84 gfx::SurfaceFormat GetFormat() { return mFormat; }
michael@0 85
michael@0 86 private:
michael@0 87 // The time in milliseconds before the pool will be shrunk to the minimum
michael@0 88 // size after returning a client.
michael@0 89 static const uint32_t sShrinkTimeout = 1000;
michael@0 90
michael@0 91 // The minimum size of the pool (the number of tiles that will be kept after
michael@0 92 // shrinking).
michael@0 93 static const uint32_t sMinCacheSize = 0;
michael@0 94
michael@0 95 // The maximum number of texture clients managed by this pool that we want
michael@0 96 // to remain active.
michael@0 97 static const uint32_t sMaxTextureClients = 50;
michael@0 98
michael@0 99 gfx::SurfaceFormat mFormat;
michael@0 100 gfx::IntSize mSize;
michael@0 101
michael@0 102 uint32_t mOutstandingClients;
michael@0 103
michael@0 104 // On b2g gonk, std::queue might be a better choice.
michael@0 105 // On ICS, fence wait happens implicitly before drawing.
michael@0 106 // Since JB, fence wait happens explicitly when fetching a client from the pool.
michael@0 107 std::stack<RefPtr<TextureClient> > mTextureClients;
michael@0 108 std::stack<RefPtr<TextureClient> > mTextureClientsDeferred;
michael@0 109 nsRefPtr<nsITimer> mTimer;
michael@0 110 RefPtr<ISurfaceAllocator> mSurfaceAllocator;
michael@0 111 };
michael@0 112
michael@0 113 }
michael@0 114 }
michael@0 115 #endif /* MOZILLA_GFX_TEXTURECLIENTPOOL_H */

mercurial