| OLD | NEW |
| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 void initWithProps(const SkSurfaceProps& props) { | 30 void initWithProps(const SkSurfaceProps& props) { |
| 31 SkASSERT(this->unique()); // only viewed by one thread | 31 SkASSERT(this->unique()); // only viewed by one thread |
| 32 SkSurfaceProps* mutableProps = const_cast<SkSurfaceProps*>(&fProps); | 32 SkSurfaceProps* mutableProps = const_cast<SkSurfaceProps*>(&fProps); |
| 33 SkASSERT(mutableProps != &props); // check for self-assignment | 33 SkASSERT(mutableProps != &props); // check for self-assignment |
| 34 mutableProps->~SkSurfaceProps(); | 34 mutableProps->~SkSurfaceProps(); |
| 35 new (mutableProps) SkSurfaceProps(props); | 35 new (mutableProps) SkSurfaceProps(props); |
| 36 } | 36 } |
| 37 | 37 |
| 38 const SkSurfaceProps& props() const { return fProps; } | 38 const SkSurfaceProps& props() const { return fProps; } |
| 39 | 39 |
| 40 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) c
onst = 0; | |
| 41 | |
| 42 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { | 40 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { |
| 43 return nullptr; | 41 return nullptr; |
| 44 } | 42 } |
| 45 | 43 |
| 46 // Default impl calls onDraw | 44 // Default impl calls onDraw |
| 47 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, | 45 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, |
| 48 int srcX, int srcY) const; | 46 int srcX, int srcY) const; |
| 49 | 47 |
| 50 virtual GrTexture* peekTexture() const { return nullptr; } | 48 virtual GrTexture* peekTexture() const { return nullptr; } |
| 51 | 49 |
| 52 // return a read-only copy of the pixels. We promise to not modify them, | 50 // return a read-only copy of the pixels. We promise to not modify them, |
| 53 // but only inspect them (or encode them). | 51 // but only inspect them (or encode them). |
| 54 virtual bool getROPixels(SkBitmap*) const = 0; | 52 virtual bool getROPixels(SkBitmap*) const = 0; |
| 55 | 53 |
| 56 // Caller must call unref when they are done. | 54 // Caller must call unref when they are done. |
| 57 virtual GrTexture* asTextureRef(GrContext*, SkImageUsageType) const = 0; | 55 virtual GrTexture* asTextureRef(GrContext*, SkImageUsageType) const = 0; |
| 58 | 56 |
| 59 virtual SkShader* onNewShader(SkShader::TileMode, | 57 virtual SkShader* onNewShader(SkShader::TileMode, |
| 60 SkShader::TileMode, | 58 SkShader::TileMode, |
| 61 const SkMatrix* localMatrix) const { return nu
llptr; } | 59 const SkMatrix* localMatrix) const { return nu
llptr; } |
| 62 | 60 |
| 63 // newWidth > 0, newHeight > 0, subset either nullptr or a proper subset of
this bounds | 61 virtual SkImage* onNewSubset(const SkIRect&) const = 0; |
| 64 virtual SkImage* onNewImage(int newWidth, int newHeight, const SkIRect* subs
et, | |
| 65 SkFilterQuality) const; | |
| 66 virtual SkData* onRefEncoded() const { return nullptr; } | 62 virtual SkData* onRefEncoded() const { return nullptr; } |
| 67 | 63 |
| 68 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; | 64 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; |
| 69 | 65 |
| 70 virtual bool onIsLazyGenerated() const { return false; } | 66 virtual bool onIsLazyGenerated() const { return false; } |
| 71 | 67 |
| 72 // 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 |
| 73 // 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. |
| 74 void notifyAddedToCache() const { | 70 void notifyAddedToCache() const { |
| 75 fAddedToCache.store(true); | 71 fAddedToCache.store(true); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 | 82 |
| 87 static inline SkImage_Base* as_IB(SkImage* image) { | 83 static inline SkImage_Base* as_IB(SkImage* image) { |
| 88 return static_cast<SkImage_Base*>(image); | 84 return static_cast<SkImage_Base*>(image); |
| 89 } | 85 } |
| 90 | 86 |
| 91 static inline const SkImage_Base* as_IB(const SkImage* image) { | 87 static inline const SkImage_Base* as_IB(const SkImage* image) { |
| 92 return static_cast<const SkImage_Base*>(image); | 88 return static_cast<const SkImage_Base*>(image); |
| 93 } | 89 } |
| 94 | 90 |
| 95 #endif | 91 #endif |
| OLD | NEW |