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

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

Issue 1411353002: Revert recent CLs around GrTextureMaker/GrTextureParamsAdjuster (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/gpu/GrTextureMaker.h ('k') | 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
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrTextureMaker_DEFINED
9 #define GrTextureMaker_DEFINED
10
11 #include "GrTextureParams.h"
12 #include "GrResourceKey.h"
13
14 class GrContext;
15 class GrTexture;
16 class GrTextureParams;
17 class GrUniqueKey;
18 class SkBitmap;
19
20 /**
21 * Different GPUs and API extensions have different requirements with respect to what texture
22 * sampling parameters may be used with textures of various types. This class fa cilitates making
23 * texture compatible with a given GrTextureParams. It abstracts the source of t he original data
24 * which may be an already existing texture, CPU pixels, a codec, ... so that va rious sources can
25 * be used with common code that scales or copies the data to make it compatible with a
26 * GrTextureParams.
27 */
28 class GrTextureParamsAdjuster {
29 public:
30 struct CopyParams {
31 GrTextureParams::FilterMode fFilter;
32 int fWidth;
33 int fHeight;
34 };
35
36 GrTextureParamsAdjuster(int width, int height) : fWidth(width), fHeight(heig ht) {}
37 virtual ~GrTextureParamsAdjuster() {}
38
39 int width() const { return fWidth; }
40 int height() const { return fHeight; }
41
42 /** Returns a texture that is safe for use with the params */
43 GrTexture* refTextureForParams(GrContext*, const GrTextureParams&);
44
45 protected:
46 /**
47 * Return the maker's "original" texture. It is the responsibility of the m aker
48 * to make this efficient ... if the texture is being generated, the maker must handle
49 * caching it (if desired).
50 */
51 virtual GrTexture* refOriginalTexture(GrContext*) = 0;
52
53 /**
54 * If we need to copy the maker's original texture, the maker is asked to r eturn a key
55 * that identifies its original + the CopyParms parameter. If the maker doe s not want to cache
56 * the stretched version (e.g. the maker is volatile), this should simply r eturn without
57 * initializing the copyKey.
58 */
59 virtual void makeCopyKey(const CopyParams&, GrUniqueKey* copyKey) = 0;
60
61 /**
62 * Return a new (uncached) texture that is the stretch of the maker's origi nal.
63 *
64 * The base-class handles general logic for this, and only needs access to the following
65 * methods:
66 * - onRefOriginalTexture()
67 * - onGetROBitmap()
68 *
69 * Subclass may override this if they can handle creating the texture more directly than
70 * by copying.
71 */
72 virtual GrTexture* generateTextureForParams(GrContext*, const CopyParams&);
73
74 /**
75 * If a stretched version of the texture is generated, it may be cached (as suming that
76 * onMakeParamsKey() returns true). In that case, the maker is notified in case it
77 * wants to note that for when the maker is destroyed.
78 */
79 virtual void didCacheCopy(const GrUniqueKey& copyKey) = 0;
80
81 /**
82 * Some GPUs are unreliable w/ very small texture sizes. If we run into tha t case, this
83 * method will be called (in service of onGenerateParamsTexture) to return a raster version
84 * of the original texture.
85 */
86 virtual bool getROBitmap(SkBitmap*) = 0;
87
88 /** Helper for creating a key for a copy from an original key. */
89 static void MakeCopyKeyFromOrigKey(const GrUniqueKey& origKey,
90 const CopyParams& copyParams,
91 GrUniqueKey* copyKey) {
92 SkASSERT(!copyKey->isValid());
93 if (origKey.isValid()) {
94 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDoma in();
95 GrUniqueKey::Builder builder(copyKey, origKey, kDomain, 3);
96 builder[0] = copyParams.fFilter;
97 builder[1] = copyParams.fWidth;
98 builder[2] = copyParams.fHeight;
99 }
100 }
101
102 private:
103 const int fWidth;
104 const int fHeight;
105 };
106
107 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextureMaker.h ('k') | src/gpu/GrTextureParamsAdjuster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698