| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrTextureProvider_DEFINED | 8 #ifndef GrTextureProvider_DEFINED |
| 9 #define GrTextureProvider_DEFINED | 9 #define GrTextureProvider_DEFINED |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Finds a texture that approximately matches the descriptor. Will be at lea
st as large in width | 65 * Finds a texture that approximately matches the descriptor. Will be at lea
st as large in width |
| 66 * and height as desc specifies. If desc specifies that the texture should b
e a render target | 66 * and height as desc specifies. If desc specifies that the texture should b
e a render target |
| 67 * then result will be a render target. Format and sample count will always
match the request. | 67 * then result will be a render target. Format and sample count will always
match the request. |
| 68 * The contents of the texture are undefined. The caller owns a ref on the r
eturned texture and | 68 * The contents of the texture are undefined. The caller owns a ref on the r
eturned texture and |
| 69 * must balance with a call to unref. | 69 * must balance with a call to unref. |
| 70 */ | 70 */ |
| 71 GrTexture* createApproxTexture(const GrSurfaceDesc&); | 71 GrTexture* createApproxTexture(const GrSurfaceDesc&); |
| 72 | 72 |
| 73 enum SizeConstraint { | |
| 74 kExact_SizeConstraint, | |
| 75 kApprox_SizeConstraint, | |
| 76 }; | |
| 77 | |
| 78 GrTexture* createTexture(const GrSurfaceDesc& desc, SizeConstraint constrain
t) { | |
| 79 switch (constraint) { | |
| 80 case kExact_SizeConstraint: | |
| 81 return this->createTexture(desc, true); | |
| 82 case kApprox_SizeConstraint: | |
| 83 return this->createApproxTexture(desc); | |
| 84 } | |
| 85 sk_throw(); | |
| 86 return nullptr; | |
| 87 } | |
| 88 | |
| 89 static SizeConstraint FromImageFilter(SkImageFilter::SizeConstraint constrai
nt) { | |
| 90 if (SkImageFilter::kExact_SizeConstraint == constraint) { | |
| 91 return kExact_SizeConstraint; | |
| 92 } else { | |
| 93 SkASSERT(SkImageFilter::kApprox_SizeConstraint == constraint); | |
| 94 return kApprox_SizeConstraint; | |
| 95 } | |
| 96 } | |
| 97 | |
| 98 /** Legacy function that no longer should be used. */ | 73 /** Legacy function that no longer should be used. */ |
| 99 enum ScratchTexMatch { | 74 enum ScratchTexMatch { |
| 100 kExact_ScratchTexMatch, | 75 kExact_ScratchTexMatch, |
| 101 kApprox_ScratchTexMatch | 76 kApprox_ScratchTexMatch |
| 102 }; | 77 }; |
| 103 GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch matc
h) { | 78 GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch matc
h) { |
| 104 if (kApprox_ScratchTexMatch == match) { | 79 if (kApprox_ScratchTexMatch == match) { |
| 105 return this->createApproxTexture(desc); | 80 return this->createApproxTexture(desc); |
| 106 } else { | 81 } else { |
| 107 return this->createTexture(desc, true); | 82 return this->createTexture(desc, true); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); | 157 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); |
| 183 return !SkToBool(fCache); | 158 return !SkToBool(fCache); |
| 184 } | 159 } |
| 185 | 160 |
| 186 private: | 161 private: |
| 187 GrResourceCache* fCache; | 162 GrResourceCache* fCache; |
| 188 GrGpu* fGpu; | 163 GrGpu* fGpu; |
| 189 }; | 164 }; |
| 190 | 165 |
| 191 #endif | 166 #endif |
| OLD | NEW |