| 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 |
| 11 #include "SkFilterQuality.h" | 11 #include "SkFilterQuality.h" |
| 12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
| 13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
| 14 #include "SkRect.h" | 14 #include "SkRect.h" |
| 15 #include "SkSurfaceProps.h" |
| 15 #include "SkTemplates.h" | 16 #include "SkTemplates.h" |
| 16 | 17 |
| 18 class GrFragmentProcessor; |
| 19 class GrTexture; |
| 20 class SkBaseDevice; |
| 17 class SkBitmap; | 21 class SkBitmap; |
| 18 class SkColorFilter; | 22 class SkColorFilter; |
| 19 class SkBaseDevice; | |
| 20 class SkSurfaceProps; | |
| 21 struct SkIPoint; | 23 struct SkIPoint; |
| 22 class GrFragmentProcessor; | |
| 23 class GrTexture; | |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Base class for image filters. If one is installed in the paint, then | 26 * Base class for image filters. If one is installed in the paint, then |
| 27 * all drawing occurs as usual, but it is as if the drawing happened into an | 27 * all drawing occurs as usual, but it is as if the drawing happened into an |
| 28 * offscreen (before the xfermode is applied). This offscreen bitmap will | 28 * offscreen (before the xfermode is applied). This offscreen bitmap will |
| 29 * then be handed to the imagefilter, who in turn creates a new bitmap which | 29 * then be handed to the imagefilter, who in turn creates a new bitmap which |
| 30 * is what will finally be drawn to the device (using the original xfermode). | 30 * is what will finally be drawn to the device (using the original xfermode). |
| 31 */ | 31 */ |
| 32 class SK_API SkImageFilter : public SkFlattenable { | 32 class SK_API SkImageFilter : public SkFlattenable { |
| 33 public: | 33 public: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 public: | 68 public: |
| 69 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) : | 69 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) : |
| 70 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { | 70 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { |
| 71 } | 71 } |
| 72 const SkMatrix& ctm() const { return fCTM; } | 72 const SkMatrix& ctm() const { return fCTM; } |
| 73 const SkIRect& clipBounds() const { return fClipBounds; } | 73 const SkIRect& clipBounds() const { return fClipBounds; } |
| 74 Cache* cache() const { return fCache; } | 74 Cache* cache() const { return fCache; } |
| 75 private: | 75 private: |
| 76 SkMatrix fCTM; | 76 SkMatrix fCTM; |
| 77 SkIRect fClipBounds; | 77 SkIRect fClipBounds; |
| 78 Cache* fCache; | 78 Cache* fCache; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class Proxy { | 81 class Proxy { |
| 82 public: | 82 public: |
| 83 virtual ~Proxy() {}; | 83 Proxy(SkBaseDevice* device, const SkSurfaceProps& props) |
| 84 | 84 : fDevice(device) |
| 85 virtual SkBaseDevice* createDevice(int width, int height) = 0; | 85 , fProps(props.flags(), kUnknown_SkPixelGeometry) |
| 86 {} |
| 87 |
| 88 SkBaseDevice* createDevice(int width, int height); |
| 86 // returns true if the proxy handled the filter itself. if this returns | 89 // returns true if the proxy handled the filter itself. if this returns |
| 87 // false then the filter's code will be called. | 90 // false then the filter's code will be called. |
| 88 virtual bool filterImage(const SkImageFilter*, const SkBitmap& src, | 91 bool filterImage(const SkImageFilter*, const SkBitmap& src, const SkImag
eFilter::Context&, |
| 89 const Context&, | 92 SkBitmap* result, SkIPoint* offset); |
| 90 SkBitmap* result, SkIPoint* offset) = 0; | 93 const SkSurfaceProps& surfaceProps() const { return fProps; } |
| 91 virtual const SkSurfaceProps* surfaceProps() const = 0; | 94 |
| 95 private: |
| 96 SkBaseDevice* fDevice; |
| 97 const SkSurfaceProps fProps; |
| 92 }; | 98 }; |
| 99 |
| 93 | 100 |
| 94 /** | 101 /** |
| 95 * Request a new (result) image to be created from the src image. | 102 * Request a new (result) image to be created from the src image. |
| 96 * If the src has no pixels (isNull()) then the request just wants to | 103 * If the src has no pixels (isNull()) then the request just wants to |
| 97 * receive the config and width/height of the result. | 104 * receive the config and width/height of the result. |
| 98 * | 105 * |
| 99 * The matrix is the current matrix on the canvas. | 106 * The matrix is the current matrix on the canvas. |
| 100 * | 107 * |
| 101 * Offset is the amount to translate the resulting image relative to the | 108 * Offset is the amount to translate the resulting image relative to the |
| 102 * src when it is drawn. This is an out-param. | 109 * src when it is drawn. This is an out-param. |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 */ | 366 */ |
| 360 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 367 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
| 361 Common localVar; \ | 368 Common localVar; \ |
| 362 do { \ | 369 do { \ |
| 363 if (!localVar.unflatten(buffer, expectedCount)) { \ | 370 if (!localVar.unflatten(buffer, expectedCount)) { \ |
| 364 return NULL; \ | 371 return NULL; \ |
| 365 } \ | 372 } \ |
| 366 } while (0) | 373 } while (0) |
| 367 | 374 |
| 368 #endif | 375 #endif |
| OLD | NEW |