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

Side by Side Diff: src/effects/SkTileImageFilter.cpp

Issue 1578983002: Optimize SkTileImageFilter in an offset filter when possible. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | 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 2013 Google Inc. 2 * Copyright 2013 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 #include "SkTileImageFilter.h" 8 #include "SkTileImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkOffsetImageFilter.h"
12 #include "SkReadBuffer.h" 13 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h" 14 #include "SkWriteBuffer.h"
14 #include "SkMatrix.h" 15 #include "SkMatrix.h"
15 #include "SkPaint.h" 16 #include "SkPaint.h"
16 #include "SkShader.h" 17 #include "SkShader.h"
17 #include "SkValidationUtils.h" 18 #include "SkValidationUtils.h"
18 19
19 SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& ds tRect, 20 SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& ds tRect,
20 SkImageFilter* input) { 21 SkImageFilter* input) {
21 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { 22 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) {
22 return nullptr; 23 return nullptr;
23 } 24 }
robertphillips 2016/01/12 14:18:29 Can this fit on one line ?
Stephen White 2016/01/12 14:23:12 Done.
25 if (srcRect.width() == dstRect.width() &&
26 srcRect.height() == dstRect.height()) {
27 SkRect ir = dstRect;
28 if (!ir.intersect(srcRect)) {
29 return SkSafeRef(input);
30 }
31 CropRect cropRect(ir);
32 return SkOffsetImageFilter::Create(dstRect.x() - srcRect.x(),
33 dstRect.y() - srcRect.y(),
34 input, &cropRect);
35 }
24 return new SkTileImageFilter(srcRect, dstRect, input); 36 return new SkTileImageFilter(srcRect, dstRect, input);
25 } 37 }
26 38
27 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, 39 bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
28 const Context& ctx, 40 const Context& ctx,
29 SkBitmap* dst, SkIPoint* offset) const { 41 SkBitmap* dst, SkIPoint* offset) const {
30 SkBitmap source = src; 42 SkBitmap source = src;
31 SkIPoint srcOffset = SkIPoint::Make(0, 0); 43 SkIPoint srcOffset = SkIPoint::Make(0, 0);
32 if (!this->filterInput(0, proxy, src, ctx, &source, &srcOffset)) { 44 if (!this->filterInput(0, proxy, src, ctx, &source, &srcOffset)) {
33 return false; 45 return false;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 str->appendf(" dst: %.2f %.2f %.2f %.2f", 159 str->appendf(" dst: %.2f %.2f %.2f %.2f",
148 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m); 160 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m);
149 if (this->getInput(0)) { 161 if (this->getInput(0)) {
150 str->appendf("input: ("); 162 str->appendf("input: (");
151 this->getInput(0)->toString(str); 163 this->getInput(0)->toString(str);
152 str->appendf(")"); 164 str->appendf(")");
153 } 165 }
154 str->append(")"); 166 str->append(")");
155 } 167 }
156 #endif 168 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698