Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: include/core/SkImageFilter.h

Issue 2357273002: Add output format properties to SkImageFilter::Context (Closed)
Patch Set: Spelling Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/effects/SkXfermodeImageFilter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 27
28 /** 28 /**
29 * Base class for image filters. If one is installed in the paint, then 29 * Base class for image filters. If one is installed in the paint, then
30 * all drawing occurs as usual, but it is as if the drawing happened into an 30 * all drawing occurs as usual, but it is as if the drawing happened into an
31 * offscreen (before the xfermode is applied). This offscreen bitmap will 31 * offscreen (before the xfermode is applied). This offscreen bitmap will
32 * then be handed to the imagefilter, who in turn creates a new bitmap which 32 * then be handed to the imagefilter, who in turn creates a new bitmap which
33 * is what will finally be drawn to the device (using the original xfermode). 33 * is what will finally be drawn to the device (using the original xfermode).
34 */ 34 */
35 class SK_API SkImageFilter : public SkFlattenable { 35 class SK_API SkImageFilter : public SkFlattenable {
36 public: 36 public:
37 // Extra information about the output of a filter DAG. For now, this is just the color space
38 // (of the original requesting device). This is used when constructing inter mediate rendering
39 // surfaces, so that we ensure we land in a surface that's similar/compatibl e to the final
40 // consumer of the DAG's output.
41 class OutputProperties {
42 public:
43 explicit OutputProperties(SkColorSpace* colorSpace) : fColorSpace(colorS pace) {}
44
45 SkColorSpace* colorSpace() const { return fColorSpace; }
46
47 private:
48 // This will be a pointer to the device's color space, and our lifetime is bounded by
49 // the device, so we can store a bare pointer.
50 SkColorSpace* fColorSpace;
51 };
52
37 class Context { 53 class Context {
38 public: 54 public:
39 Context(const SkMatrix& ctm, const SkIRect& clipBounds, SkImageFilterCac he* cache) 55 Context(const SkMatrix& ctm, const SkIRect& clipBounds, SkImageFilterCac he* cache,
56 const OutputProperties& outputProperties)
40 : fCTM(ctm) 57 : fCTM(ctm)
41 , fClipBounds(clipBounds) 58 , fClipBounds(clipBounds)
42 , fCache(cache) 59 , fCache(cache)
60 , fOutputProperties(outputProperties)
43 {} 61 {}
44 62
45 const SkMatrix& ctm() const { return fCTM; } 63 const SkMatrix& ctm() const { return fCTM; }
46 const SkIRect& clipBounds() const { return fClipBounds; } 64 const SkIRect& clipBounds() const { return fClipBounds; }
47 SkImageFilterCache* cache() const { return fCache; } 65 SkImageFilterCache* cache() const { return fCache; }
66 const OutputProperties& outputProperties() const { return fOutputPropert ies; }
48 67
49 private: 68 private:
50 SkMatrix fCTM; 69 SkMatrix fCTM;
51 SkIRect fClipBounds; 70 SkIRect fClipBounds;
52 SkImageFilterCache* fCache; 71 SkImageFilterCache* fCache;
72 OutputProperties fOutputProperties;
53 }; 73 };
54 74
55 class CropRect { 75 class CropRect {
56 public: 76 public:
57 enum CropEdge { 77 enum CropEdge {
58 kHasLeft_CropEdge = 0x01, 78 kHasLeft_CropEdge = 0x01,
59 kHasTop_CropEdge = 0x02, 79 kHasTop_CropEdge = 0x02,
60 kHasWidth_CropEdge = 0x04, 80 kHasWidth_CropEdge = 0x04,
61 kHasHeight_CropEdge = 0x08, 81 kHasHeight_CropEdge = 0x08,
62 kHasAll_CropEdge = 0x0F, 82 kHasAll_CropEdge = 0x0F,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 * image would be required to fill the given rect (typically, clip bounds). 143 * image would be required to fill the given rect (typically, clip bounds).
124 * Used for clipping and temp-buffer allocations, so the result need not 144 * Used for clipping and temp-buffer allocations, so the result need not
125 * be exact, but should never be smaller than the real answer. The default 145 * be exact, but should never be smaller than the real answer. The default
126 * implementation recursively unions all input bounds, or returns the 146 * implementation recursively unions all input bounds, or returns the
127 * source rect if no inputs. 147 * source rect if no inputs.
128 */ 148 */
129 SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm, 149 SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm,
130 MapDirection = kReverse_MapDirection) const; 150 MapDirection = kReverse_MapDirection) const;
131 151
132 #if SK_SUPPORT_GPU 152 #if SK_SUPPORT_GPU
133 static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context, 153 static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context,
134 sk_sp<GrFragmentProcessor> fp, 154 sk_sp<GrFragmentProcessor> fp,
135 const SkIRect& bounds, 155 const SkIRect& bounds,
136 sk_sp<SkColorSpace> colorSpace); 156 const OutputProperties& outputProper ties);
137 #endif 157 #endif
138 158
139 /** 159 /**
140 * Returns whether this image filter is a color filter and puts the color f ilter into the 160 * Returns whether this image filter is a color filter and puts the color f ilter into the
141 * "filterPtr" parameter if it can. Does nothing otherwise. 161 * "filterPtr" parameter if it can. Does nothing otherwise.
142 * If this returns false, then the filterPtr is unchanged. 162 * If this returns false, then the filterPtr is unchanged.
143 * If this returns true, then if filterPtr is not null, it must be set to a ref'd colorfitler 163 * If this returns true, then if filterPtr is not null, it must be set to a ref'd colorfitler
144 * (i.e. it may not be set to NULL). 164 * (i.e. it may not be set to NULL).
145 */ 165 */
146 bool isColorFilterNode(SkColorFilter** filterPtr) const { 166 bool isColorFilterNode(SkColorFilter** filterPtr) const {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 */ 424 */
405 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ 425 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
406 Common localVar; \ 426 Common localVar; \
407 do { \ 427 do { \
408 if (!localVar.unflatten(buffer, expectedCount)) { \ 428 if (!localVar.unflatten(buffer, expectedCount)) { \
409 return NULL; \ 429 return NULL; \
410 } \ 430 } \
411 } while (0) 431 } while (0)
412 432
413 #endif 433 #endif
OLDNEW
« no previous file with comments | « no previous file | include/effects/SkXfermodeImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698