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

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 27490005: Make CropRect immutable after construction. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove now-stale comment. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkImageFilter.h ('k') | no next file » | 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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 #include "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer) 55 SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer)
56 : fInputCount(buffer.readInt()), fInputs(new SkImageFilter*[fInputCount]) { 56 : fInputCount(buffer.readInt()), fInputs(new SkImageFilter*[fInputCount]) {
57 for (int i = 0; i < fInputCount; i++) { 57 for (int i = 0; i < fInputCount; i++) {
58 if (buffer.readBool()) { 58 if (buffer.readBool()) {
59 fInputs[i] = buffer.readImageFilter(); 59 fInputs[i] = buffer.readImageFilter();
60 } else { 60 } else {
61 fInputs[i] = NULL; 61 fInputs[i] = NULL;
62 } 62 }
63 } 63 }
64 buffer.readRect(&fCropRect.fRect); 64 SkRect rect;
65 fCropRect.fFlags = buffer.readUInt(); 65 buffer.readRect(&rect);
66 uint32_t flags = buffer.readUInt();
67 fCropRect = CropRect(rect, flags);
66 } 68 }
67 69
68 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 70 void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
69 buffer.writeInt(fInputCount); 71 buffer.writeInt(fInputCount);
70 for (int i = 0; i < fInputCount; i++) { 72 for (int i = 0; i < fInputCount; i++) {
71 SkImageFilter* input = getInput(i); 73 SkImageFilter* input = getInput(i);
72 buffer.writeBool(input != NULL); 74 buffer.writeBool(input != NULL);
73 if (input != NULL) { 75 if (input != NULL) {
74 buffer.writeFlattenable(input); 76 buffer.writeFlattenable(input);
75 } 77 }
76 } 78 }
77 buffer.writeRect(fCropRect.fRect); 79 buffer.writeRect(fCropRect.rect());
78 buffer.writeUInt(fCropRect.fFlags); 80 buffer.writeUInt(fCropRect.flags());
79 } 81 }
80 82
81 bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, 83 bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src,
82 const SkMatrix& ctm, 84 const SkMatrix& ctm,
83 SkBitmap* result, SkIPoint* loc) { 85 SkBitmap* result, SkIPoint* loc) {
84 SkASSERT(result); 86 SkASSERT(result);
85 SkASSERT(loc); 87 SkASSERT(loc);
86 /* 88 /*
87 * Give the proxy first shot at the filter. If it returns false, ask 89 * Give the proxy first shot at the filter. If it returns false, ask
88 * the filter to do it. 90 * the filter to do it.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 offset->fX += bounds.left(); 153 offset->fX += bounds.left();
152 offset->fY += bounds.top(); 154 offset->fY += bounds.top();
153 return true; 155 return true;
154 #else 156 #else
155 return false; 157 return false;
156 #endif 158 #endif
157 } 159 }
158 160
159 bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const { 161 bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const {
160 SkRect cropRect; 162 SkRect cropRect;
161 matrix.mapRect(&cropRect, fCropRect.fRect); 163 matrix.mapRect(&cropRect, fCropRect.rect());
162 SkIRect cropRectI; 164 SkIRect cropRectI;
163 cropRect.roundOut(&cropRectI); 165 cropRect.roundOut(&cropRectI);
166 uint32_t flags = fCropRect.flags();
164 // If the original crop rect edges were unset, max out the new crop edges 167 // If the original crop rect edges were unset, max out the new crop edges
165 if (!(fCropRect.fFlags & CropRect::kHasLeft_CropEdge)) cropRectI.fLeft = SK_ MinS32; 168 if (!(flags & CropRect::kHasLeft_CropEdge)) cropRectI.fLeft = SK_MinS32;
166 if (!(fCropRect.fFlags & CropRect::kHasTop_CropEdge)) cropRectI.fTop = SK_Mi nS32; 169 if (!(flags & CropRect::kHasTop_CropEdge)) cropRectI.fTop = SK_MinS32;
167 if (!(fCropRect.fFlags & CropRect::kHasRight_CropEdge)) cropRectI.fRight = S K_MaxS32; 170 if (!(flags & CropRect::kHasRight_CropEdge)) cropRectI.fRight = SK_MaxS32;
168 if (!(fCropRect.fFlags & CropRect::kHasBottom_CropEdge)) cropRectI.fBottom = SK_MaxS32; 171 if (!(flags & CropRect::kHasBottom_CropEdge)) cropRectI.fBottom = SK_MaxS32;
169 return rect->intersect(cropRectI); 172 return rect->intersect(cropRectI);
170 } 173 }
171 174
172 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, 175 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
173 SkIRect* dst) { 176 SkIRect* dst) {
174 *dst = src; 177 *dst = src;
175 return true; 178 return true;
176 } 179 }
177 180
178 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&) cons t { 181 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&) cons t {
179 return false; 182 return false;
180 } 183 }
181 184
182 bool SkImageFilter::asColorFilter(SkColorFilter**) const { 185 bool SkImageFilter::asColorFilter(SkColorFilter**) const {
183 return false; 186 return false;
184 } 187 }
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698