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

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

Issue 1409163002: Rewrite GrTextureMaker to disentangle bitmap case from base class and give GPU object a say in what… (Closed) Base URL: https://skia.googlesource.com/skia.git@move
Patch Set: tidy 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/GrGpu.cpp ('k') | src/gpu/GrTextureParamsAdjuster.h » ('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 "SkGrPriv.h"
12
13 class GrContext;
14 class GrTexture;
15 class GrTextureParams;
16 class GrUniqueKey;
17 class SkBitmap;
18
19 class GrTextureMaker {
20 public:
21 GrTextureMaker(int width, int height) : fWidth(width), fHeight(height) {}
22 virtual ~GrTextureMaker() {}
23
24 int width() const { return fWidth; }
25 int height() const { return fHeight; }
26
27 GrTexture* refCachedTexture(GrContext*, const GrTextureParams&);
28
29 protected:
30 /**
31 * Return the maker's "original" unstretched texture. It is the responsibil ity of the maker
32 * to make this efficient ... if the texture is being generated, the maker must handle
33 * caching it.
34 */
35 virtual GrTexture* onRefUnstretchedTexture(GrContext*) = 0;
36
37 /**
38 * If we need to stretch the maker's original texture, the maker is asked t o return a key
39 * that identifies its origianl + the stretch parameter. If the maker does not want to cache
40 * the stretched version (e.g. the maker is volatile), this should ignore t he key parameter
41 * and return false.
42 */
43 virtual bool onMakeStretchedKey(const SkGrStretch&, GrUniqueKey* stretchedKe y) = 0;
44
45 /**
46 * Return a new (uncached) texture that is the stretch of the maker's origi nal.
47 *
48 * The base-class handles general logic for this, and only needs access to the following
49 * methods:
50 * - onRefUnstretchedTexture()
51 * - onGetROBitmap()
52 *
53 * Subclass may override this if they can handle stretching more efficientl y.
54 */
55 virtual GrTexture* onGenerateStretchedTexture(GrContext*, const SkGrStretch& );
56
57 /**
58 * If a stretched version of the texture is generated, it may be cached (as suming that
59 * onMakeStretchedKey() returns true). In that case, the maker is notified in case it
60 * wants to note that for when the maker is destroyed.
61 */
62 virtual void onNotifyStretchCached(const GrUniqueKey& stretchedKey) = 0;
63
64 /**
65 * Some GPUs are unreliable w/ very small texture sizes. If we run into tha t case, this
66 * method will be called (in service of onGenerateStretchedTexture) to retu rn a raster version
67 * of the original texture.
68 */
69 virtual bool onGetROBitmap(SkBitmap*) = 0;
70
71 private:
72 const int fWidth;
73 const int fHeight;
74 };
75
76 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrTextureParamsAdjuster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698