| OLD | NEW | 
|    1  |    1  | 
|    2 /* |    2 /* | 
|    3  * Copyright 2008 The Android Open Source Project |    3  * Copyright 2008 The Android Open Source Project | 
|    4  * |    4  * | 
|    5  * Use of this source code is governed by a BSD-style license that can be |    5  * Use of this source code is governed by a BSD-style license that can be | 
|    6  * found in the LICENSE file. |    6  * found in the LICENSE file. | 
|    7  */ |    7  */ | 
|    8  |    8  | 
|    9  |    9  | 
|   10 #ifndef SkPixelRef_DEFINED |   10 #ifndef SkPixelRef_DEFINED | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  134      *  return a ref to its data. If the pixelRef |  134      *  return a ref to its data. If the pixelRef | 
|  135      *  is uncompressed or otherwise does not have this form, return NULL. |  135      *  is uncompressed or otherwise does not have this form, return NULL. | 
|  136      * |  136      * | 
|  137      *  If non-null is returned, the caller is responsible for calling unref() |  137      *  If non-null is returned, the caller is responsible for calling unref() | 
|  138      *  on the data when it is finished. |  138      *  on the data when it is finished. | 
|  139      */ |  139      */ | 
|  140     SkData* refEncodedData() { |  140     SkData* refEncodedData() { | 
|  141         return this->onRefEncodedData(); |  141         return this->onRefEncodedData(); | 
|  142     } |  142     } | 
|  143  |  143  | 
 |  144     /** | 
 |  145      *  Experimental -- tells the caller if it is worth it to call decodeInto(). | 
 |  146      *  Just an optimization at this point, to avoid checking the cache first. | 
 |  147      *  We may remove/change this call in the future. | 
 |  148      */ | 
 |  149     bool implementsDecodeInto() { | 
 |  150         return this->onImplementsDecodeInto(); | 
 |  151     } | 
 |  152  | 
 |  153     /** | 
 |  154      *  Return a decoded instance of this pixelRef in bitmap. If this cannot be | 
 |  155      *  done, return false and the bitmap parameter is ignored/unchanged. | 
 |  156      * | 
 |  157      *  pow2 is the requeste power-of-two downscale that the caller needs. This | 
 |  158      *  can be ignored, and the "original" size can be returned, but if the | 
 |  159      *  underlying codec can efficiently return a smaller size, that should be | 
 |  160      *  done. Some examples: | 
 |  161      * | 
 |  162      *  To request the "base" version (original scale), pass 0 for pow2 | 
 |  163      *  To request 1/2 scale version (1/2 width, 1/2 height), pass 1 for pow2 | 
 |  164      *  To request 1/4 scale version (1/4 width, 1/4 height), pass 2 for pow2 | 
 |  165      *  ... | 
 |  166      * | 
 |  167      *  If this returns true, then bitmap must be "locked" such that | 
 |  168      *  bitmap->getPixels() will return the correct address. | 
 |  169      */ | 
 |  170     bool decodeInto(int pow2, SkBitmap* bitmap) { | 
 |  171         SkASSERT(pow2 >= 0); | 
 |  172         return this->onDecodeInto(pow2, bitmap); | 
 |  173     } | 
 |  174  | 
|  144     /** Are we really wrapping a texture instead of a bitmap? |  175     /** Are we really wrapping a texture instead of a bitmap? | 
|  145      */ |  176      */ | 
|  146     virtual GrTexture* getTexture() { return NULL; } |  177     virtual GrTexture* getTexture() { return NULL; } | 
|  147  |  178  | 
|  148     bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); |  179     bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL); | 
|  149  |  180  | 
|  150     /** |  181     /** | 
|  151      *  Makes a deep copy of this PixelRef, respecting the requested config. |  182      *  Makes a deep copy of this PixelRef, respecting the requested config. | 
|  152      *  @param config Desired config. |  183      *  @param config Desired config. | 
|  153      *  @param subset Subset of this PixelRef to copy. Must be fully contained w
     ithin the bounds of |  184      *  @param subset Subset of this PixelRef to copy. Must be fully contained w
     ithin the bounds of | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  183     virtual void* onLockPixels(SkColorTable**) = 0; |  214     virtual void* onLockPixels(SkColorTable**) = 0; | 
|  184     /** Called when the lock count goes from 1 to 0. The caller will have |  215     /** Called when the lock count goes from 1 to 0. The caller will have | 
|  185         already acquire a mutex for thread safety, so this method need not do |  216         already acquire a mutex for thread safety, so this method need not do | 
|  186         that. |  217         that. | 
|  187     */ |  218     */ | 
|  188     virtual void onUnlockPixels() = 0; |  219     virtual void onUnlockPixels() = 0; | 
|  189  |  220  | 
|  190     /** Default impl returns true */ |  221     /** Default impl returns true */ | 
|  191     virtual bool onLockPixelsAreWritable() const; |  222     virtual bool onLockPixelsAreWritable() const; | 
|  192  |  223  | 
 |  224     // returns false; | 
 |  225     virtual bool onImplementsDecodeInto(); | 
 |  226     // returns false; | 
 |  227     virtual bool onDecodeInto(int pow2, SkBitmap* bitmap); | 
 |  228  | 
|  193     /** |  229     /** | 
|  194      *  For pixelrefs that don't have access to their raw pixels, they may be |  230      *  For pixelrefs that don't have access to their raw pixels, they may be | 
|  195      *  able to make a copy of them (e.g. if the pixels are on the GPU). |  231      *  able to make a copy of them (e.g. if the pixels are on the GPU). | 
|  196      * |  232      * | 
|  197      *  The base class implementation returns false; |  233      *  The base class implementation returns false; | 
|  198      */ |  234      */ | 
|  199     virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); |  235     virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); | 
|  200  |  236  | 
|  201     // default impl returns NULL. |  237     // default impl returns NULL. | 
|  202     virtual SkData* onRefEncodedData(); |  238     virtual SkData* onRefEncodedData(); | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  234     bool    fIsImmutable; |  270     bool    fIsImmutable; | 
|  235     // only ever set in constructor, const after that |  271     // only ever set in constructor, const after that | 
|  236     bool    fPreLocked; |  272     bool    fPreLocked; | 
|  237  |  273  | 
|  238     void setMutex(SkBaseMutex* mutex); |  274     void setMutex(SkBaseMutex* mutex); | 
|  239  |  275  | 
|  240     typedef SkFlattenable INHERITED; |  276     typedef SkFlattenable INHERITED; | 
|  241 }; |  277 }; | 
|  242  |  278  | 
|  243 #endif |  279 #endif | 
| OLD | NEW |