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

Side by Side Diff: include/gpu/GrTextureAccess.h

Issue 1404433002: Remove image usage type enum. Use GrTextureParams instead. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no gpu build Created 5 years, 2 months 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
« no previous file with comments | « include/core/SkImageInfo.h ('k') | include/gpu/GrTextureParams.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GrTextureAccess_DEFINED 8 #ifndef GrTextureAccess_DEFINED
9 #define GrTextureAccess_DEFINED 9 #define GrTextureAccess_DEFINED
10 10
11 #include "GrGpuResourceRef.h" 11 #include "GrGpuResourceRef.h"
12 #include "GrTexture.h" 12 #include "GrTexture.h"
13 #include "GrTextureParams.h"
13 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
14 #include "SkShader.h" 15 #include "SkShader.h"
15 16
16 /**
17 * Represents the filtering and tile modes used to access a texture. It is mostl y used with
18 * GrTextureAccess (defined below). Also, some of the texture cache methods requ ire knowledge about
19 * filtering and tiling to perform a cache lookup. If it wasn't for this latter usage this would
20 * be folded into GrTextureAccess. The default is clamp tile modes and no filter ing.
21 */
22 class GrTextureParams {
23 public:
24 GrTextureParams() {
25 this->reset();
26 }
27
28 enum FilterMode {
29 kNone_FilterMode,
30 kBilerp_FilterMode,
31 kMipMap_FilterMode
32 };
33
34 GrTextureParams(SkShader::TileMode tileXAndY, FilterMode filterMode) {
35 this->reset(tileXAndY, filterMode);
36 }
37
38 GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode ) {
39 this->reset(tileModes, filterMode);
40 }
41
42 GrTextureParams(const GrTextureParams& params) {
43 *this = params;
44 }
45
46 GrTextureParams& operator= (const GrTextureParams& params) {
47 fTileModes[0] = params.fTileModes[0];
48 fTileModes[1] = params.fTileModes[1];
49 fFilterMode = params.fFilterMode;
50 return *this;
51 }
52
53 void reset() {
54 this->reset(SkShader::kClamp_TileMode, kNone_FilterMode);
55 }
56
57 void reset(SkShader::TileMode tileXAndY, FilterMode filterMode) {
58 fTileModes[0] = fTileModes[1] = tileXAndY;
59 fFilterMode = filterMode;
60 }
61
62 void reset(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
63 fTileModes[0] = tileModes[0];
64 fTileModes[1] = tileModes[1];
65 fFilterMode = filterMode;
66 }
67
68 void setClampNoFilter() {
69 fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
70 fFilterMode = kNone_FilterMode;
71 }
72
73 void setClamp() {
74 fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
75 }
76
77 void setFilterMode(FilterMode filterMode) { fFilterMode = filterMode; }
78
79 void setTileModeX(const SkShader::TileMode tm) { fTileModes[0] = tm; }
80 void setTileModeY(const SkShader::TileMode tm) { fTileModes[1] = tm; }
81 void setTileModeXAndY(const SkShader::TileMode tm) { fTileModes[0] = fTileMo des[1] = tm; }
82
83 SkShader::TileMode getTileModeX() const { return fTileModes[0]; }
84
85 SkShader::TileMode getTileModeY() const { return fTileModes[1]; }
86
87 bool isTiled() const {
88 return SkShader::kClamp_TileMode != fTileModes[0] ||
89 SkShader::kClamp_TileMode != fTileModes[1];
90 }
91
92 FilterMode filterMode() const { return fFilterMode; }
93
94 bool operator== (const GrTextureParams& other) const {
95 return fTileModes[0] == other.fTileModes[0] &&
96 fTileModes[1] == other.fTileModes[1] &&
97 fFilterMode == other.fFilterMode;
98 }
99
100 bool operator!= (const GrTextureParams& other) const { return !(*this == oth er); }
101
102 private:
103
104 SkShader::TileMode fTileModes[2];
105 FilterMode fFilterMode;
106 };
107
108 /** A class representing the swizzle access pattern for a texture. Note that if the texture is 17 /** A class representing the swizzle access pattern for a texture. Note that if the texture is
109 * an alpha-only texture then the alpha channel is substituted for other compon ents. Any mangling 18 * an alpha-only texture then the alpha channel is substituted for other compon ents. Any mangling
110 * to handle the r,g,b->a conversions for alpha textures is automatically inclu ded in the stage 19 * to handle the r,g,b->a conversions for alpha textures is automatically inclu ded in the stage
111 * key. However, if a GrProcessor uses different swizzles based on its input th en it must 20 * key. However, if a GrProcessor uses different swizzles based on its input th en it must
112 * consider that variation in its key-generation. 21 * consider that variation in its key-generation.
113 */ 22 */
114 class GrTextureAccess : public SkNoncopyable { 23 class GrTextureAccess : public SkNoncopyable {
115 public: 24 public:
116 /** 25 /**
117 * A default GrTextureAccess must have reset() called on it in a GrProcessor subclass's 26 * A default GrTextureAccess must have reset() called on it in a GrProcessor subclass's
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 94
186 ProgramTexture fTexture; 95 ProgramTexture fTexture;
187 GrTextureParams fParams; 96 GrTextureParams fParams;
188 uint32_t fSwizzleMask; 97 uint32_t fSwizzleMask;
189 char fSwizzle[5]; 98 char fSwizzle[5];
190 99
191 typedef SkNoncopyable INHERITED; 100 typedef SkNoncopyable INHERITED;
192 }; 101 };
193 102
194 #endif 103 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageInfo.h ('k') | include/gpu/GrTextureParams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698