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

Side by Side Diff: src/gpu/GrTextureParamsAdjuster.h

Issue 1410383008: Clarify subrect semantics for GrTextureAdjuster and handle mip maps correctly. (Closed) Base URL: https://skia.googlesource.com/skia.git@producer
Patch Set: Address comment Created 5 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
« no previous file with comments | « no previous file | src/gpu/GrTextureParamsAdjuster.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 GrTextureMaker_DEFINED 8 #ifndef GrTextureMaker_DEFINED
9 #define GrTextureMaker_DEFINED 9 #define GrTextureMaker_DEFINED
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 /** 62 /**
63 * If a stretched version of the texture is generated, it may be cached (ass uming that 63 * If a stretched version of the texture is generated, it may be cached (ass uming that
64 * makeCopyKey() returns true). In that case, the maker is notified in case it 64 * makeCopyKey() returns true). In that case, the maker is notified in case it
65 * wants to note that for when the maker is destroyed. 65 * wants to note that for when the maker is destroyed.
66 */ 66 */
67 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0; 67 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0;
68 68
69 typedef SkNoncopyable INHERITED; 69 typedef SkNoncopyable INHERITED;
70 }; 70 };
71 71
72 /** Base class for sources that start out as textures */ 72 /**
73 * Base class for sources that start out as textures. Optionally allows for a co ntent area subrect.
74 * The intent is not to use content area for subrect rendering. Rather, the pixe ls outside the
75 * content area have undefined values and shouldn't be read *regardless* of filt ering mode or
76 * the SkCanvas::SrcRectConstraint used for subrect draws.
77 */
73 class GrTextureAdjuster : public GrTextureProducer { 78 class GrTextureAdjuster : public GrTextureProducer {
74 public: 79 public:
75 /** Makes the subset of the texture safe to use with the given texture param eters. 80 /** Makes the subset of the texture safe to use with the given texture param eters.
76 outOffset will be the top-left corner of the subset if a copy is not mad e. Otherwise, 81 outOffset will be the top-left corner of the subset if a copy is not mad e. Otherwise,
77 the copy will be tight to the contents and outOffset will be (0, 0). If the copy's size 82 the copy will be tight to the contents and outOffset will be (0, 0). If the copy's size
78 does not match subset's dimensions then the contents are scaled to fit t he copy.*/ 83 does not match subset's dimensions then the contents are scaled to fit t he copy.*/
79 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs et); 84 GrTexture* refTextureSafeForParams(const GrTextureParams&, SkIPoint* outOffs et);
80 85
81 protected: 86 protected:
82 /** No subset, use the whole texture */ 87 /** The whole texture is content. */
83 explicit GrTextureAdjuster(GrTexture* original): fOriginal(original) {} 88 explicit GrTextureAdjuster(GrTexture* original): fOriginal(original) {}
84 89
85 GrTextureAdjuster(GrTexture* original, const SkIRect& subset); 90 GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea);
86 91
87 GrTexture* originalTexture() { return fOriginal; } 92 GrTexture* originalTexture() { return fOriginal; }
88 93
89 /** Returns the subset or null for the whole original texture */ 94 /** Returns the content area or null for the whole original texture */
90 const SkIRect* subset() { return fSubset.getMaybeNull(); } 95 const SkIRect* contentArea() { return fContentArea.getMaybeNull(); }
91 96
92 private: 97 private:
93 GrTexture* internalRefTextureSafeForParams(GrTexture*, const SkIRect* subset , 98 SkTLazy<SkIRect> fContentArea;
94 const GrTextureParams&, SkIPoint* outOffset);
95 SkTLazy<SkIRect> fSubset;
96 GrTexture* fOriginal; 99 GrTexture* fOriginal;
97 100
98 typedef GrTextureProducer INHERITED; 101 typedef GrTextureProducer INHERITED;
99 }; 102 };
100 103
101 /** 104 /**
102 * Base class for sources that start out as something other than a texture (enco ded image, 105 * Base class for sources that start out as something other than a texture (enco ded image,
103 * picture, ...). 106 * picture, ...).
104 */ 107 */
105 class GrTextureMaker : public GrTextureProducer { 108 class GrTextureMaker : public GrTextureProducer {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&); 147 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&);
145 148
146 private: 149 private:
147 const int fWidth; 150 const int fWidth;
148 const int fHeight; 151 const int fHeight;
149 152
150 typedef GrTextureProducer INHERITED; 153 typedef GrTextureProducer INHERITED;
151 }; 154 };
152 155
153 #endif 156 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrTextureParamsAdjuster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698