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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 920513003: Make filters use SkImage instead of SkBitmap Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « gm/imagefiltersbase.cpp ('k') | gyp/effects.gyp » ('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 "gm.h" 8 #include "gm.h"
9 9
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 19 matching lines...) Expand all
30 Registrar() { 30 Registrar() {
31 SkFlattenable::Register("SimpleOffsetFilter", 31 SkFlattenable::Register("SimpleOffsetFilter",
32 SimpleOffsetFilter::CreateProc, 32 SimpleOffsetFilter::CreateProc,
33 SimpleOffsetFilter::GetFlattenableType()); 33 SimpleOffsetFilter::GetFlattenableType());
34 } 34 }
35 }; 35 };
36 static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input) { 36 static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input) {
37 return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input)); 37 return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input));
38 } 38 }
39 39
40 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx, 40 virtual bool onFilterImage(Proxy* proxy, const SkImage* src, const Context& ctx,
41 SkBitmap* dst, SkIPoint* offset) const SK_OVERRID E { 41 SkAutoTUnref<const SkImage>& dst, SkIPoint* offse t) const SK_OVERRIDE {
42 SkBitmap source = src; 42 SkAutoTUnref<const SkImage> source(SkRef(src));
43 SkImageFilter* input = getInput(0); 43 SkImageFilter* input = getInput(0);
44 SkIPoint srcOffset = SkIPoint::Make(0, 0); 44 SkIPoint srcOffset = SkIPoint::Make(0, 0);
45 if (input && !input->filterImage(proxy, src, ctx, &source, &srcOffset)) { 45 if (input && !input->filterImage(proxy, src, ctx, source, &srcOffset)) {
46 return false; 46 return false;
47 } 47 }
48 48
49 SkIRect bounds; 49 SkIRect bounds;
50 if (!this->applyCropRect(ctx, proxy, source, &srcOffset, &bounds, &sourc e)) { 50 if (!this->applyCropRect(ctx, proxy, source, &srcOffset, &bounds, source )) {
51 return false; 51 return false;
52 } 52 }
53 53
54 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo unds.height())); 54 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo unds.height()));
55 SkCanvas canvas(device); 55 SkCanvas canvas(device);
56 SkPaint paint; 56 SkPaint paint;
57 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 57 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
58 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain t); 58 canvas.drawImage(source, fDX - bounds.left(), fDY - bounds.top(), &paint );
59 *dst = device->accessBitmap(false); 59 SkImage* image = device->newImageSnapshot();
60 if (NULL == image) {
61 return false;
62 }
63 dst.reset(image);
60 offset->fX += bounds.left(); 64 offset->fX += bounds.left();
61 offset->fY += bounds.top(); 65 offset->fY += bounds.top();
62 return true; 66 return true;
63 } 67 }
64 68
65 SK_TO_STRING_OVERRIDE() 69 SK_TO_STRING_OVERRIDE()
66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); 70 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
67 71
68 protected: 72 protected:
69 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 73 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 228
225 private: 229 private:
226 typedef GM INHERITED; 230 typedef GM INHERITED;
227 SkBitmap fBitmap; 231 SkBitmap fBitmap;
228 }; 232 };
229 233
230 /////////////////////////////////////////////////////////////////////////////// 234 ///////////////////////////////////////////////////////////////////////////////
231 235
232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 236 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; }
233 static skiagm::GMRegistry reg(MyFactory); 237 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | gyp/effects.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698