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

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

Issue 1421493003: tunnel down texture-size-constraint to imagefilters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix formating 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/SkImageFilter.h ('k') | src/core/SkCanvas.cpp » ('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 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
11 #include "GrTexture.h" 11 #include "GrTexture.h"
12 #include "SkImageFilter.h"
12 13
13 class SK_API GrTextureProvider { 14 class SK_API GrTextureProvider {
14 public: 15 public:
15 /////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////
16 // Textures 17 // Textures
17 18
18 /** 19 /**
19 * Creates a new texture in the resource cache and returns it. The caller ow ns a 20 * Creates a new texture in the resource cache and returns it. The caller ow ns a
20 * ref on the returned texture which must be balanced by a call to unref. 21 * ref on the returned texture which must be balanced by a call to unref.
21 * 22 *
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 /** 64 /**
64 * 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
65 * 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
66 * 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.
67 * 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
68 * must balance with a call to unref. 69 * must balance with a call to unref.
69 */ 70 */
70 GrTexture* createApproxTexture(const GrSurfaceDesc&); 71 GrTexture* createApproxTexture(const GrSurfaceDesc&);
71 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
72 /** Legacy function that no longer should be used. */ 98 /** Legacy function that no longer should be used. */
73 enum ScratchTexMatch { 99 enum ScratchTexMatch {
74 kExact_ScratchTexMatch, 100 kExact_ScratchTexMatch,
75 kApprox_ScratchTexMatch 101 kApprox_ScratchTexMatch
76 }; 102 };
77 GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch matc h) { 103 GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch matc h) {
78 if (kApprox_ScratchTexMatch == match) { 104 if (kApprox_ScratchTexMatch == match) {
79 return this->createApproxTexture(desc); 105 return this->createApproxTexture(desc);
80 } else { 106 } else {
81 return this->createTexture(desc, true); 107 return this->createTexture(desc, true);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); 182 SkASSERT(SkToBool(fGpu) == SkToBool(fCache));
157 return !SkToBool(fCache); 183 return !SkToBool(fCache);
158 } 184 }
159 185
160 private: 186 private:
161 GrResourceCache* fCache; 187 GrResourceCache* fCache;
162 GrGpu* fGpu; 188 GrGpu* fGpu;
163 }; 189 };
164 190
165 #endif 191 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698