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

Side by Side Diff: src/image/SkImage.cpp

Issue 1573653002: remove SkImage::applyFilter() -- unused, can always re-add later (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 | « include/core/SkImage.h ('k') | src/image/SkImage_Base.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // For now, and to maintain parity w/ previous pixelref behavior, we just fo rce the image 82 // For now, and to maintain parity w/ previous pixelref behavior, we just fo rce the image
83 // to produce a cached raster-bitmap form, so that drawing to a raster canva s should be fast. 83 // to produce a cached raster-bitmap form, so that drawing to a raster canva s should be fast.
84 // 84 //
85 SkBitmap bm; 85 SkBitmap bm;
86 if (as_IB(this)->getROPixels(&bm)) { 86 if (as_IB(this)->getROPixels(&bm)) {
87 bm.lockPixels(); 87 bm.lockPixels();
88 bm.unlockPixels(); 88 bm.unlockPixels();
89 } 89 }
90 } 90 }
91 91
92 SkImage* SkImage::applyFilter(SkImageFilter* filter, SkIPoint* offset,
93 bool forceResultToOriginalSize) const {
94 if (!filter) {
95 return nullptr;
96 }
97
98 SkIPoint offsetStorage;
99 if (!offset) {
100 offset = &offsetStorage;
101 }
102 return as_IB(this)->onApplyFilter(filter, offset, forceResultToOriginalSize) ;
103 }
104
105 //////////////////////////////////////////////////////////////////////////////// ///////////////////
106
107 #include "SkImageFilter.h"
108 #include "SkBitmapDevice.h"
109
110 static SkIRect compute_fast_ibounds(SkImageFilter* filter, const SkIRect& srcBou nds) {
111 SkRect fastBounds;
112 fastBounds.set(srcBounds);
113 filter->computeFastBounds(fastBounds, &fastBounds);
114 return fastBounds.roundOut();
115 }
116
117 class SkRasterImageFilterProxy : public SkImageFilter::Proxy {
118 public:
119 SkBaseDevice* createDevice(int width, int height) override {
120 return SkBitmapDevice::Create(SkImageInfo::MakeN32Premul(width, height)) ;
121 }
122
123 bool filterImage(const SkImageFilter*, const SkBitmap&, const SkImageFilter: :Context&,
124 SkBitmap*, SkIPoint*) override {
125 return false;
126 }
127 };
128
129 SkImage* SkImage_Base::onApplyFilter(SkImageFilter* filter, SkIPoint* offsetResu lt,
130 bool forceResultToOriginalSize) const {
131 SkBitmap src;
132 if (!this->getROPixels(&src)) {
133 return nullptr;
134 }
135
136 const SkIRect srcBounds = SkIRect::MakeWH(this->width(), this->height());
137
138 if (forceResultToOriginalSize) {
139 const SkIRect clipBounds = srcBounds;
140 SkRasterImageFilterProxy proxy;
141 SkImageFilter::Context ctx(SkMatrix::I(), clipBounds, SkImageFilter::Cac he::Get(),
142 SkImageFilter::kExact_SizeConstraint);
143
144 SkBitmap dst;
145 if (filter->filterImage(&proxy, src, ctx, &dst, offsetResult)) {
146 dst.setImmutable();
147 return SkImage::NewFromBitmap(dst);
148 }
149 } else {
150 const SkIRect dstR = compute_fast_ibounds(filter, srcBounds);
151
152 SkImageInfo info = SkImageInfo::MakeN32Premul(dstR.width(), dstR.height( ));
153 SkAutoTUnref<SkSurface> surface(this->onNewSurface(info));
154
155 SkPaint paint;
156 paint.setImageFilter(filter);
157 surface->getCanvas()->drawImage(this, SkIntToScalar(-dstR.x()), SkIntToS calar(-dstR.y()),
158 &paint);
159
160 offsetResult->set(dstR.x(), dstR.y());
161 return surface->newImageSnapshot();
162 }
163 return nullptr;
164 }
165
166 //////////////////////////////////////////////////////////////////////////////// /////////////////// 92 //////////////////////////////////////////////////////////////////////////////// ///////////////////
167 93
168 SkShader* SkImage::newShader(SkShader::TileMode tileX, 94 SkShader* SkImage::newShader(SkShader::TileMode tileX,
169 SkShader::TileMode tileY, 95 SkShader::TileMode tileY,
170 const SkMatrix* localMatrix) const { 96 const SkMatrix* localMatrix) const {
171 return SkImageShader::Create(this, tileX, tileY, localMatrix); 97 return SkImageShader::Create(this, tileX, tileY, localMatrix);
172 } 98 }
173 99
174 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { 100 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
175 SkBitmap bm; 101 SkBitmap bm;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 333
408 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { 334 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) {
409 return nullptr; 335 return nullptr;
410 } 336 }
411 337
412 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { 338 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) {
413 return nullptr; 339 return nullptr;
414 } 340 }
415 341
416 #endif 342 #endif
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698