| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright 2011 Google Inc. |    2  * Copyright 2011 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 SkImageFilter_DEFINED |    8 #ifndef SkImageFilter_DEFINED | 
|    9 #define SkImageFilter_DEFINED |    9 #define SkImageFilter_DEFINED | 
|   10  |   10  | 
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  286                                   const SkBitmap& src, const Context&, |  286                                   const SkBitmap& src, const Context&, | 
|  287                                   SkBitmap* result, SkIPoint* offset) const; |  287                                   SkBitmap* result, SkIPoint* offset) const; | 
|  288 #endif |  288 #endif | 
|  289  |  289  | 
|  290     SK_TO_STRING_PUREVIRT() |  290     SK_TO_STRING_PUREVIRT() | 
|  291     SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter) |  291     SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter) | 
|  292  |  292  | 
|  293 protected: |  293 protected: | 
|  294     class Common { |  294     class Common { | 
|  295     public: |  295     public: | 
|  296         Common() {} |  | 
|  297         ~Common(); |  | 
|  298  |  | 
|  299         /** |  296         /** | 
|  300          *  Attempt to unflatten the cropRect and the expected number of input f
     ilters. |  297          *  Attempt to unflatten the cropRect and the expected number of input f
     ilters. | 
|  301          *  If any number of input filters is valid, pass -1. |  298          *  If any number of input filters is valid, pass -1. | 
|  302          *  If this fails (i.e. corrupt buffer or contents) then return false an
     d common will |  299          *  If this fails (i.e. corrupt buffer or contents) then return false an
     d common will | 
|  303          *  be left uninitialized. |  300          *  be left uninitialized. | 
|  304          *  If this returns true, then inputCount() is the number of found input
      filters, each |  301          *  If this returns true, then inputCount() is the number of found input
      filters, each | 
|  305          *  of which may be NULL or a valid imagefilter. |  302          *  of which may be NULL or a valid imagefilter. | 
|  306          */ |  303          */ | 
|  307         bool unflatten(SkReadBuffer&, int expectedInputs); |  304         bool unflatten(SkReadBuffer&, int expectedInputs); | 
|  308  |  305  | 
|  309         const CropRect& cropRect() const { return fCropRect; } |  306         const CropRect& cropRect() const { return fCropRect; } | 
|  310         int             inputCount() const { return fInputs.count(); } |  307         int             inputCount() const { return fInputs.count(); } | 
|  311         SkImageFilter** inputs() const { return fInputs.get(); } |  308         sk_sp<SkImageFilter>* inputs() const { return fInputs.get(); } | 
|  312  |  309  | 
|  313         SkImageFilter*  getInput(int index) const { return fInputs[index]; } |  310         sk_sp<SkImageFilter>  getInput(int index) const { return fInputs[index];
      } | 
|  314  |  311  | 
|  315         // If the caller wants a copy of the inputs, call this and it will trans
     fer ownership |  312         // If the caller wants a copy of the inputs, call this and it will trans
     fer ownership | 
|  316         // of the unflattened input filters to the caller. This is just a short-
     cut for copying |  313         // of the unflattened input filters to the caller. This is just a short-
     cut for copying | 
|  317         // the inputs, calling ref() on each, and then waiting for Common's dest
     ructor to call |  314         // the inputs, calling ref() on each, and then waiting for Common's dest
     ructor to call | 
|  318         // unref() on each. |  315         // unref() on each. | 
|  319         void detachInputs(SkImageFilter** inputs); |  316         void detachInputs(SkImageFilter** inputs); | 
|  320  |  317  | 
|  321     private: |  318     private: | 
|  322         CropRect fCropRect; |  319         CropRect fCropRect; | 
|  323         // most filters accept at most 2 input-filters |  320         // most filters accept at most 2 input-filters | 
|  324         SkAutoSTArray<2, SkImageFilter*> fInputs; |  321         SkAutoSTArray<2, sk_sp<SkImageFilter>> fInputs; | 
|  325  |  322  | 
|  326         void allocInputs(int count); |  323         void allocInputs(int count); | 
|  327     }; |  324     }; | 
|  328  |  325  | 
|  329     SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRe
     ct = nullptr); |  326     SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRe
     ct = nullptr); | 
|  330  |  327  | 
|  331     SkImageFilter(sk_sp<SkImageFilter>* inputs, int inputCount, const CropRect* 
     cropRect); |  328     SkImageFilter(sk_sp<SkImageFilter>* inputs, int inputCount, const CropRect* 
     cropRect); | 
|  332  |  329  | 
|  333     virtual ~SkImageFilter(); |  330     virtual ~SkImageFilter(); | 
|  334  |  331  | 
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  485  */ |  482  */ | 
|  486 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount)    \ |  483 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount)    \ | 
|  487     Common localVar;                                                \ |  484     Common localVar;                                                \ | 
|  488     do {                                                            \ |  485     do {                                                            \ | 
|  489         if (!localVar.unflatten(buffer, expectedCount)) {           \ |  486         if (!localVar.unflatten(buffer, expectedCount)) {           \ | 
|  490             return NULL;                                            \ |  487             return NULL;                                            \ | 
|  491         }                                                           \ |  488         }                                                           \ | 
|  492     } while (0) |  489     } while (0) | 
|  493  |  490  | 
|  494 #endif |  491 #endif | 
| OLD | NEW |