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

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

Issue 1414843003: Image filters: Replace all use of tryAllocPixels() with createDevice(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix morphology: don't allocate dest or temp until we need them Created 5 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
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | src/effects/SkLightingImageFilter.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 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 "SkDisplacementMapEffect.h" 8 #include "SkDisplacementMapEffect.h"
9 #include "SkDevice.h"
9 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
11 #include "SkUnPreMultiply.h" 12 #include "SkUnPreMultiply.h"
12 #include "SkColorPriv.h" 13 #include "SkColorPriv.h"
13 #if SK_SUPPORT_GPU 14 #if SK_SUPPORT_GPU
14 #include "GrContext.h" 15 #include "GrContext.h"
15 #include "GrDrawContext.h" 16 #include "GrDrawContext.h"
16 #include "GrCoordTransform.h" 17 #include "GrCoordTransform.h"
17 #include "GrInvariantOutput.h" 18 #include "GrInvariantOutput.h"
18 #include "effects/GrTextureDomain.h" 19 #include "effects/GrTextureDomain.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return false; 233 return false;
233 } 234 }
234 if (!bounds.intersect(displBounds)) { 235 if (!bounds.intersect(displBounds)) {
235 return false; 236 return false;
236 } 237 }
237 SkAutoLockPixels alp_displacement(displ), alp_color(color); 238 SkAutoLockPixels alp_displacement(displ), alp_color(color);
238 if (!displ.getPixels() || !color.getPixels()) { 239 if (!displ.getPixels() || !color.getPixels()) {
239 return false; 240 return false;
240 } 241 }
241 242
242 if (!dst->tryAllocPixels(color.info().makeWH(bounds.width(), bounds.height() ))) { 243 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
244 if (!device) {
243 return false; 245 return false;
244 } 246 }
247 *dst = device->accessBitmap(false);
248 SkAutoLockPixels alp_dst(*dst);
245 249
246 SkVector scale = SkVector::Make(fScale, fScale); 250 SkVector scale = SkVector::Make(fScale, fScale);
247 ctx.ctm().mapVectors(&scale, 1); 251 ctx.ctm().mapVectors(&scale, 1);
248 SkIRect colorBounds = bounds; 252 SkIRect colorBounds = bounds;
249 colorBounds.offset(-colorOffset); 253 colorBounds.offset(-colorOffset);
250 254
251 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, 255 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst,
252 &displ, colorOffset - displOffset, &color, colorBounds); 256 &displ, colorOffset - displOffset, &color, colorBounds);
253 257
254 offset->fX = bounds.left(); 258 offset->fX = bounds.left();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 625 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
622 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 626 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
623 627
624 uint32_t xKey = displacementMap.xChannelSelector(); 628 uint32_t xKey = displacementMap.xChannelSelector();
625 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 629 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
626 630
627 b->add32(xKey | yKey); 631 b->add32(xKey | yKey);
628 } 632 }
629 #endif 633 #endif
630 634
OLDNEW
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698