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.
2 /*
3 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
9 #ifndef GrAtlas_DEFINED
10 #define GrAtlas_DEFINED
13 #include "GrPoint.h"
14 #include "GrTexture.h"
15 #include "GrDrawTarget.h"
17 class GrGpu;
18 class GrRectanizer;
19 class GrAtlasMgr;
20 class GrAtlas;
22 // The backing GrTexture for a set of GrAtlases is broken into a spatial grid of GrPlots. When
23 // a GrAtlas needs space on the texture, it requests a GrPlot. Each GrAtlas can claim one
24 // or more GrPlots. The GrPlots keep track of subimage placement via their GrRectanizer. Once a
25 // GrPlot is "full" (i.e. there is no room for the new subimage according to the GrRectanizer), the
26 // GrAtlas can request a new GrPlot via GrAtlasMgr::addToAtlas().
27 //
28 // If all GrPlots are allocated, the replacement strategy is up to the client. The drawToken is
29 // available to ensure that all draw calls are finished for that particular GrPlot.
30 // GrAtlasMgr::removeUnusedPlots() will free up any finished plots for a given GrAtlas.
32 class GrPlot {
33 public:
34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot);
36 int getOffsetX() const { return fOffset.fX; }
37 int getOffsetY() const { return fOffset.fY; }
39 GrTexture* texture() const { return fTexture; }
41 bool addSubImage(int width, int height, const void*, GrIPoint16*);
43 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
44 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
46 void resetRects();
48 private:
49 GrPlot();
50 ~GrPlot(); // does not try to delete the fNext field
52 // for recycling
53 GrDrawTarget::DrawToken fDrawToken;
55 GrTexture* fTexture;
56 GrRectanizer* fRects;
57 GrAtlasMgr* fAtlasMgr;
58 GrIPoint16 fOffset;
59 size_t fBytesPerPixel;
61 friend class GrAtlasMgr;
62 };
64 typedef SkTInternalLList<GrPlot> GrPlotList;
66 class GrAtlasMgr {
67 public:
68 GrAtlasMgr(GrGpu*, GrPixelConfig);
69 ~GrAtlasMgr();
71 // add subimage of width, height dimensions to atlas
72 // returns the containing GrPlot and location relative to the backing texture
73 GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16*);
75 // remove reference to this plot
76 bool removePlot(GrAtlas* atlas, const GrPlot* plot);
78 // get a plot that's not being used by the current draw
79 // this allows us to overwrite this plot without flushing
80 GrPlot* getUnusedPlot();
82 GrTexture* getTexture() const {
83 return fTexture;
84 }
86 private:
87 void moveToHead(GrPlot* plot);
89 GrGpu* fGpu;
90 GrPixelConfig fPixelConfig;
91 GrTexture* fTexture;
93 // allocated array of GrPlots
94 GrPlot* fPlotArray;
95 // LRU list of GrPlots
96 GrPlotList fPlotList;
97 };
99 class GrAtlas {
100 public:
101 GrAtlas() { }
102 ~GrAtlas() { }
104 bool isEmpty() { return 0 == fPlots.count(); }
106 SkISize getSize() const;
108 private:
109 SkTDArray<GrPlot*> fPlots;
111 friend class GrAtlasMgr;
112 };
114 #endif