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

Side by Side Diff: gm/imagefilters.cpp

Issue 1088773004: add GM to test imagefilters + xfermodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkImageFilter.h"
10 #include "SkColorMatrixFilter.h"
11
12 /**
13 * Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ ide ntity) to see
14 * that we apply the xfermode *after* the image has been created and filtered, and not during
15 * the creation step (i.e. before it is filtered).
16 */
robertphillips 2015/04/20 14:13:34 Maybe add a link to the Skia issue?
reed1 2015/04/20 14:20:45 Done.
17 class ImageFilterXfermodeTestGM : public skiagm::GM {
18 enum {
19 WIDTH = 640,
20 HEIGHT = 480
21 };
22 public:
23
24 protected:
25 SkString onShortName() override {
robertphillips 2015/04/20 14:13:34 rm "_test" ?
reed1 2015/04/20 14:20:45 Done.
26 return SkString("imagefilters_xfermode_test");
27 }
28
29 SkISize onISize() override { return SkISize::Make(WIDTH, HEIGHT); }
30
31 void doDraw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) {
32 SkPaint paint;
33 paint.setAntiAlias(true);
34
35 SkRect r0 = SkRect::MakeXYWH(10, 60, 200, 100);
36 SkRect r1 = SkRect::MakeXYWH(60, 10, 100, 200);
37
38 paint.setColor(SK_ColorRED);
39 canvas->drawOval(r0, paint);
40
41 paint.setColor(0x800000FF);
42 paint.setImageFilter(imf);
43 paint.setXfermodeMode(mode);
44 canvas->drawOval(r1, paint);
45 }
46
47 void onDraw(SkCanvas* canvas) override {
48 // just need an imagefilter to trigger the code-path (which creates a tm p layer)
49 SkAutoTUnref<SkImageFilter> imf(SkImageFilter::CreateMatrixFilter(SkMatr ix::I(),
50 kNone_ SkFilterQuality));
51
52 const SkXfermode::Mode modes[] = {
53 SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode
54 };
55
56 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) {
57 canvas->save();
58 this->doDraw(canvas, modes[i], NULL);
59 canvas->translate(250, 0);
60 this->doDraw(canvas, modes[i], imf);
61 canvas->restore();
62
63 canvas->translate(0, 250);
64 }
65 }
66
67 private:
68 typedef GM INHERITED;
69 };
70 DEF_GM( return new ImageFilterXfermodeTestGM; )
71
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698