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

Side by Side Diff: src/image/SkImage_Base.h

Issue 2241353002: pin as texture api (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix comments Created 4 years, 4 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/image/SkImage.cpp ('k') | src/image/SkImage_Gpu.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 SkImage_Base_DEFINED 8 #ifndef SkImage_Base_DEFINED
9 #define SkImage_Base_DEFINED 9 #define SkImage_Base_DEFINED
10 10
11 #include "GrTexture.h"
11 #include "SkAtomics.h" 12 #include "SkAtomics.h"
12 #include "SkImage.h" 13 #include "SkImage.h"
13 #include "SkSurface.h" 14 #include "SkSurface.h"
14 15
15 #include <new> 16 #include <new>
16 17
17 class GrTextureParams; 18 class GrTextureParams;
18 class SkImageCacherator; 19 class SkImageCacherator;
19 20
20 enum { 21 enum {
(...skipping 12 matching lines...) Expand all
33 34
34 virtual bool onPeekPixels(SkPixmap*) const { return false; } 35 virtual bool onPeekPixels(SkPixmap*) const { return false; }
35 36
36 virtual const SkBitmap* onPeekBitmap() const { return nullptr; } 37 virtual const SkBitmap* onPeekBitmap() const { return nullptr; }
37 38
38 // Default impl calls onDraw 39 // Default impl calls onDraw
39 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_ t dstRowBytes, 40 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_ t dstRowBytes,
40 int srcX, int srcY, CachingHint) const; 41 int srcX, int srcY, CachingHint) const;
41 42
42 virtual GrTexture* peekTexture() const { return nullptr; } 43 virtual GrTexture* peekTexture() const { return nullptr; }
44 virtual sk_sp<GrTexture> refPinnedTexture(uint32_t* uniqueID) const { return nullptr; }
43 virtual SkImageCacherator* peekCacherator() const { return nullptr; } 45 virtual SkImageCacherator* peekCacherator() const { return nullptr; }
44 46
45 // return a read-only copy of the pixels. We promise to not modify them, 47 // return a read-only copy of the pixels. We promise to not modify them,
46 // but only inspect them (or encode them). 48 // but only inspect them (or encode them).
47 virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const = 0; 49 virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const = 0;
48 50
49 virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) const { 51 virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) const {
50 return SkSurface::MakeRaster(info); 52 return SkSurface::MakeRaster(info);
51 } 53 }
52 54
53 // Caller must call unref when they are done. 55 // Caller must call unref when they are done.
54 virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&, 56 virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
55 SkSourceGammaTreatment) const = 0; 57 SkSourceGammaTreatment) const = 0;
56 58
57 virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0; 59 virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0;
58 60
59 // If a ctx is specified, then only gpu-specific formats are requested. 61 // If a ctx is specified, then only gpu-specific formats are requested.
60 virtual SkData* onRefEncoded(GrContext*) const { return nullptr; } 62 virtual SkData* onRefEncoded(GrContext*) const { return nullptr; }
61 63
62 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; 64 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const;
63 65
64 virtual bool onIsLazyGenerated() const { return false; } 66 virtual bool onIsLazyGenerated() const { return false; }
65 67
66 // Call when this image is part of the key to a resourcecache entry. This al lows the cache 68 // Call when this image is part of the key to a resourcecache entry. This al lows the cache
67 // to know automatically those entries can be purged when this SkImage delet ed. 69 // to know automatically those entries can be purged when this SkImage delet ed.
68 void notifyAddedToCache() const { 70 void notifyAddedToCache() const {
69 fAddedToCache.store(true); 71 fAddedToCache.store(true);
70 } 72 }
71 73
74 virtual void onPinAsTexture(GrContext*) const {}
75 virtual void onUnpinAsTexture(GrContext*) const {}
76
72 private: 77 private:
73 // Set true by caches when they cache content that's derived from the curren t pixels. 78 // Set true by caches when they cache content that's derived from the curren t pixels.
74 mutable SkAtomic<bool> fAddedToCache; 79 mutable SkAtomic<bool> fAddedToCache;
75 80
76 typedef SkImage INHERITED; 81 typedef SkImage INHERITED;
77 }; 82 };
78 83
79 static inline SkImage_Base* as_IB(SkImage* image) { 84 static inline SkImage_Base* as_IB(SkImage* image) {
80 return static_cast<SkImage_Base*>(image); 85 return static_cast<SkImage_Base*>(image);
81 } 86 }
82 87
83 static inline SkImage_Base* as_IB(const sk_sp<SkImage>& image) { 88 static inline SkImage_Base* as_IB(const sk_sp<SkImage>& image) {
84 return static_cast<SkImage_Base*>(image.get()); 89 return static_cast<SkImage_Base*>(image.get());
85 } 90 }
86 91
87 static inline const SkImage_Base* as_IB(const SkImage* image) { 92 static inline const SkImage_Base* as_IB(const SkImage* image) {
88 return static_cast<const SkImage_Base*>(image); 93 return static_cast<const SkImage_Base*>(image);
89 } 94 }
90 95
91 #endif 96 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/image/SkImage_Gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698