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

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

Issue 742663002: add roundOut that returns its result (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 | « src/core/SkDraw.cpp ('k') | src/core/SkMaskFilter.cpp » ('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 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return false; 283 return false;
284 } 284 }
285 285
286 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, 286 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src,
287 const SkIPoint& srcOffset, SkIRect* bounds) co nst { 287 const SkIPoint& srcOffset, SkIRect* bounds) co nst {
288 SkIRect srcBounds; 288 SkIRect srcBounds;
289 src.getBounds(&srcBounds); 289 src.getBounds(&srcBounds);
290 srcBounds.offset(srcOffset); 290 srcBounds.offset(srcOffset);
291 SkRect cropRect; 291 SkRect cropRect;
292 ctx.ctm().mapRect(&cropRect, fCropRect.rect()); 292 ctx.ctm().mapRect(&cropRect, fCropRect.rect());
293 SkIRect cropRectI; 293 const SkIRect cropRectI = cropRect.roundOut();
294 cropRect.roundOut(&cropRectI);
295 uint32_t flags = fCropRect.flags(); 294 uint32_t flags = fCropRect.flags();
296 if (flags & CropRect::kHasLeft_CropEdge) srcBounds.fLeft = cropRectI.fLeft; 295 if (flags & CropRect::kHasLeft_CropEdge) srcBounds.fLeft = cropRectI.fLeft;
297 if (flags & CropRect::kHasTop_CropEdge) srcBounds.fTop = cropRectI.fTop; 296 if (flags & CropRect::kHasTop_CropEdge) srcBounds.fTop = cropRectI.fTop;
298 if (flags & CropRect::kHasRight_CropEdge) srcBounds.fRight = cropRectI.fRigh t; 297 if (flags & CropRect::kHasRight_CropEdge) srcBounds.fRight = cropRectI.fRigh t;
299 if (flags & CropRect::kHasBottom_CropEdge) srcBounds.fBottom = cropRectI.fBo ttom; 298 if (flags & CropRect::kHasBottom_CropEdge) srcBounds.fBottom = cropRectI.fBo ttom;
300 if (!srcBounds.intersect(ctx.clipBounds())) { 299 if (!srcBounds.intersect(ctx.clipBounds())) {
301 return false; 300 return false;
302 } 301 }
303 *bounds = srcBounds; 302 *bounds = srcBounds;
304 return true; 303 return true;
305 } 304 }
306 305
307 bool SkImageFilter::applyCropRect(const Context& ctx, Proxy* proxy, const SkBitm ap& src, 306 bool SkImageFilter::applyCropRect(const Context& ctx, Proxy* proxy, const SkBitm ap& src,
308 SkIPoint* srcOffset, SkIRect* bounds, SkBitmap * dst) const { 307 SkIPoint* srcOffset, SkIRect* bounds, SkBitmap * dst) const {
309 SkIRect srcBounds; 308 SkIRect srcBounds;
310 src.getBounds(&srcBounds); 309 src.getBounds(&srcBounds);
311 srcBounds.offset(*srcOffset); 310 srcBounds.offset(*srcOffset);
312 SkRect cropRect; 311 SkRect cropRect;
313 ctx.ctm().mapRect(&cropRect, fCropRect.rect()); 312 ctx.ctm().mapRect(&cropRect, fCropRect.rect());
314 SkIRect cropRectI; 313 const SkIRect cropRectI = cropRect.roundOut();
315 cropRect.roundOut(&cropRectI);
316 uint32_t flags = fCropRect.flags(); 314 uint32_t flags = fCropRect.flags();
317 *bounds = srcBounds; 315 *bounds = srcBounds;
318 if (flags & CropRect::kHasLeft_CropEdge) bounds->fLeft = cropRectI.fLeft; 316 if (flags & CropRect::kHasLeft_CropEdge) bounds->fLeft = cropRectI.fLeft;
319 if (flags & CropRect::kHasTop_CropEdge) bounds->fTop = cropRectI.fTop; 317 if (flags & CropRect::kHasTop_CropEdge) bounds->fTop = cropRectI.fTop;
320 if (flags & CropRect::kHasRight_CropEdge) bounds->fRight = cropRectI.fRight; 318 if (flags & CropRect::kHasRight_CropEdge) bounds->fRight = cropRectI.fRight;
321 if (flags & CropRect::kHasBottom_CropEdge) bounds->fBottom = cropRectI.fBott om; 319 if (flags & CropRect::kHasBottom_CropEdge) bounds->fBottom = cropRectI.fBott om;
322 if (!bounds->intersect(ctx.clipBounds())) { 320 if (!bounds->intersect(ctx.clipBounds())) {
323 return false; 321 return false;
324 } 322 }
325 if (srcBounds.contains(*bounds)) { 323 if (srcBounds.contains(*bounds)) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 492
495 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { 493 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) {
496 return SkNEW_ARGS(CacheImpl, (maxBytes)); 494 return SkNEW_ARGS(CacheImpl, (maxBytes));
497 } 495 }
498 496
499 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); 497 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache);
500 498
501 SkImageFilter::Cache* SkImageFilter::Cache::Get() { 499 SkImageFilter::Cache* SkImageFilter::Cache::Get() {
502 return cache.get(); 500 return cache.get();
503 } 501 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698