| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 SkSpecialImage_DEFINED | 8 #ifndef SkSpecialImage_DEFINED |
| 9 #define SkSpecialImage_DEFINED | 9 #define SkSpecialImage_DEFINED |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 const SkIRect& subset, | 56 const SkIRect& subset, |
| 57 const SkImage*); | 57 const SkImage*); |
| 58 static SkSpecialImage* NewFromRaster(SkImageFilter::Proxy*, | 58 static SkSpecialImage* NewFromRaster(SkImageFilter::Proxy*, |
| 59 const SkIRect& subset, | 59 const SkIRect& subset, |
| 60 const SkBitmap&); | 60 const SkBitmap&); |
| 61 static SkSpecialImage* NewFromGpu(SkImageFilter::Proxy*, | 61 static SkSpecialImage* NewFromGpu(SkImageFilter::Proxy*, |
| 62 const SkIRect& subset, | 62 const SkIRect& subset, |
| 63 uint32_t uniqueID, | 63 uint32_t uniqueID, |
| 64 GrTexture*, | 64 GrTexture*, |
| 65 SkAlphaType at = kPremul_SkAlphaType); | 65 SkAlphaType at = kPremul_SkAlphaType); |
| 66 static SkSpecialImage* NewFromPixmap(SkImageFilter::Proxy*, | |
| 67 const SkIRect& subset, | |
| 68 const SkPixmap&, | |
| 69 void (*releaseProc)(void* addr, void* c
ontext), | |
| 70 void* context); | |
| 71 | 66 |
| 72 /** | 67 /** |
| 73 * Create a new surface with a backend that is compatible with this image. | 68 * Create a new surface with a backend that is compatible with this image. |
| 74 */ | 69 */ |
| 75 SkSpecialSurface* newSurface(const SkImageInfo&) const; | 70 SkSpecialSurface* newSurface(const SkImageInfo&) const; |
| 76 | 71 |
| 77 /** | |
| 78 * Extract a subset of this special image and return it as a special image. | |
| 79 * It may or may not point to the same backing memory. | |
| 80 */ | |
| 81 SkSpecialImage* extractSubset(const SkIRect& subset) const; | |
| 82 | |
| 83 // These three internal methods will go away (see skbug.com/4965) | 72 // These three internal methods will go away (see skbug.com/4965) |
| 84 bool internal_getBM(SkBitmap* result); | 73 bool internal_getBM(SkBitmap* result); |
| 85 static SkSpecialImage* internal_fromBM(SkImageFilter::Proxy*, const SkBitmap
&); | 74 static SkSpecialImage* internal_fromBM(SkImageFilter::Proxy*, const SkBitmap
&); |
| 86 SkImageFilter::Proxy* internal_getProxy() const; | 75 SkImageFilter::Proxy* internal_getProxy(); |
| 87 | 76 |
| 88 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see
skbug.com/5063) | 77 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see
skbug.com/5063) |
| 89 /** | 78 /** |
| 90 * If the SpecialImage is backed by a gpu texture, return that texture. | 79 * If the SpecialImage is backed by a gpu texture, return that texture. |
| 91 * The active portion of the texture can be retrieved via 'subset'. | 80 * The active portion of the texture can be retrieved via 'subset'. |
| 92 */ | 81 */ |
| 93 GrTexture* peekTexture() const; | 82 GrTexture* peekTexture() const; |
| 94 | 83 |
| 95 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) | |
| 96 /** | |
| 97 * If the SpecialImage is backed by cpu pixels, return the const address | |
| 98 * of those pixels and, if not null, the ImageInfo, rowBytes, and, if prese
nt, | |
| 99 * the color table. The returned address(es) is/are only valid while the im
age object | |
| 100 * is in scope. | |
| 101 * | |
| 102 * The returned ImageInfo represents the backing memory. Use 'subset' | |
| 103 * to get the active portion's dimensions. | |
| 104 * | |
| 105 * On failure, return false and ignore the pixmap parameter. | |
| 106 */ | |
| 107 bool peekPixels(SkPixmap*) const; | |
| 108 | |
| 109 protected: | 84 protected: |
| 110 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t
uniqueID) | 85 SkSpecialImage(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint32_t
uniqueID) |
| 111 : fSubset(subset) | 86 : fSubset(subset) |
| 112 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I
mageID() | 87 , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::I
mageID() |
| 113 : uniqueID) | 88 : uniqueID) |
| 114 , fProxy(proxy) { | 89 , fProxy(proxy) { |
| 115 } | 90 } |
| 116 | 91 |
| 117 // The following 2 are for testing and shouldn't be used. | 92 // The following 2 are for testing and shouldn't be used. |
| 118 friend class TestingSpecialImageAccess; | 93 friend class TestingSpecialImageAccess; |
| 119 friend class TestingSpecialSurfaceAccess; | 94 friend class TestingSpecialSurfaceAccess; |
| 120 | 95 |
| 96 /** |
| 97 * If the SpecialImage is backed by cpu pixels, return the const address |
| 98 * of those pixels and, if not null, return the ImageInfo and rowBytes. |
| 99 * The returned address is only valid while the image object is in scope. |
| 100 * |
| 101 * The returned ImageInfo represents the backing memory. Use 'subset' |
| 102 * to get the active portion's dimensions. |
| 103 * |
| 104 * On failure, return false and ignore the pixmap parameter. |
| 105 */ |
| 106 bool testingOnlyPeekPixels(SkPixmap*) const; |
| 107 |
| 121 // This entry point is for testing only. It does a readback from VRAM for | 108 // This entry point is for testing only. It does a readback from VRAM for |
| 122 // GPU-backed special images. | 109 // GPU-backed special images. |
| 123 bool testingOnlyGetROPixels(SkBitmap*) const; | 110 bool testingOnlyGetROPixels(SkBitmap*) const; |
| 124 | 111 |
| 125 // TODO: remove this ASAP (see skbug.com/4965) | 112 // TODO: remove this ASAP (see skbug.com/4965) |
| 126 SkImageFilter::Proxy* proxy() const { return fProxy; } | 113 SkImageFilter::Proxy* proxy() const { return fProxy; } |
| 127 | 114 |
| 128 private: | 115 private: |
| 129 const SkIRect fSubset; | 116 const SkIRect fSubset; |
| 130 const uint32_t fUniqueID; | 117 const uint32_t fUniqueID; |
| 131 | 118 |
| 132 // TODO: remove this ASAP (see skbug.com/4965) | 119 // TODO: remove this ASAP (see skbug.com/4965) |
| 133 SkImageFilter::Proxy* fProxy; | 120 SkImageFilter::Proxy* fProxy; |
| 134 | 121 |
| 135 typedef SkRefCnt INHERITED; | 122 typedef SkRefCnt INHERITED; |
| 136 }; | 123 }; |
| 137 | 124 |
| 138 #endif | 125 #endif |
| 139 | 126 |
| OLD | NEW |