Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: src/gpu/effects/GrTextureStripAtlas.h

Issue 655913003: Use texture strip atlas for color table filter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix include order Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrTextureStripAtlas_DEFINED 8 #ifndef GrTextureStripAtlas_DEFINED
9 #define GrTextureStripAtlas_DEFINED 9 #define GrTextureStripAtlas_DEFINED
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * 54 *
55 * If a regular texture access without using the atlas looks like: 55 * If a regular texture access without using the atlas looks like:
56 * 56 *
57 * texture2D(sampler, vec2(x, y)) 57 * texture2D(sampler, vec2(x, y))
58 * 58 *
59 * Then when using the atlas we'd replace it with: 59 * Then when using the atlas we'd replace it with:
60 * 60 *
61 * texture2D(sampler, vec2(x, yOffset + y * scaleFactor)) 61 * texture2D(sampler, vec2(x, yOffset + y * scaleFactor))
62 * 62 *
63 * Where yOffset, returned by getYOffset(), is the offset to the start of th e row within the 63 * Where yOffset, returned by getYOffset(), is the offset to the start of th e row within the
64 * atlas and scaleFactor, returned by getVerticalScaleFactor(), is the y-sca le of the row, 64 * atlas and scaleFactor, returned by getNormalizedTexelHeight, is the norma lized height of
65 * relative to the height of the overall atlas texture. 65 * one texel row.
66 */ 66 */
67 SkScalar getYOffset(int row) const { return SkIntToScalar(row) / fNumRows; } 67 SkScalar getYOffset(int row) const { return SkIntToScalar(row) / fNumRows; }
68 SkScalar getVerticalScaleFactor() const { return SkIntToScalar(fDesc.fRowHei ght) / fDesc.fHeight; } 68 SkScalar getNormalizedTexelHeight() const { return fNormalizedYHeight; }
69 69
70 GrContext* getContext() const { return fDesc.fContext; } 70 GrContext* getContext() const { return fDesc.fContext; }
71 GrTexture* getTexture() const { return fTexture; } 71 GrTexture* getTexture() const { return fTexture; }
72 72
73 private: 73 private:
74 74
75 // Key to indicate an atlas row without any meaningful data stored in it 75 // Key to indicate an atlas row without any meaningful data stored in it
76 const static uint32_t kEmptyAtlasRowKey = 0xffffffff; 76 const static uint32_t kEmptyAtlasRowKey = 0xffffffff;
77 77
78 /** 78 /**
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // get a texture back from the texture cache, that it's the same one we last used. 161 // get a texture back from the texture cache, that it's the same one we last used.
162 const int32_t fCacheKey; 162 const int32_t fCacheKey;
163 163
164 // Total locks on all rows (when this reaches zero, we can unlock our textur e) 164 // Total locks on all rows (when this reaches zero, we can unlock our textur e)
165 int32_t fLockedRows; 165 int32_t fLockedRows;
166 166
167 const Desc fDesc; 167 const Desc fDesc;
168 const uint16_t fNumRows; 168 const uint16_t fNumRows;
169 GrTexture* fTexture; 169 GrTexture* fTexture;
170 170
171 SkScalar fNormalizedYHeight;
172
171 // Array of AtlasRows which store the state of all our rows. Stored in a con tiguous array, in 173 // Array of AtlasRows which store the state of all our rows. Stored in a con tiguous array, in
172 // order that they appear in our texture, this means we can subtract this po inter from a row 174 // order that they appear in our texture, this means we can subtract this po inter from a row
173 // pointer to get its index in the texture, and can save storing a row numbe r in AtlasRow. 175 // pointer to get its index in the texture, and can save storing a row numbe r in AtlasRow.
174 AtlasRow* fRows; 176 AtlasRow* fRows;
175 177
176 // Head and tail for linked list of least-recently-used rows (front = least recently used). 178 // Head and tail for linked list of least-recently-used rows (front = least recently used).
177 // Note that when a texture is locked, it gets removed from this list until it is unlocked. 179 // Note that when a texture is locked, it gets removed from this list until it is unlocked.
178 AtlasRow* fLRUFront; 180 AtlasRow* fLRUFront;
179 AtlasRow* fLRUBack; 181 AtlasRow* fLRUBack;
180 182
181 // A list of pointers to AtlasRows that currently contain cached images, sor ted by key 183 // A list of pointers to AtlasRows that currently contain cached images, sor ted by key
182 SkTDArray<AtlasRow*> fKeyTable; 184 SkTDArray<AtlasRow*> fKeyTable;
183 }; 185 };
184 186
185 #endif 187 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698