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

Side by Side Diff: gm/displacement.cpp

Issue 12787007: Fix for displacement mapping (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | include/core/SkScalar.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 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 "gm.h" 8 #include "gm.h"
9 #include "SkDisplacementMapEffect.h" 9 #include "SkDisplacementMapEffect.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 canvas->clear(0x00000000); 80 canvas->clear(0x00000000);
81 SkPaint paint; 81 SkPaint paint;
82 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 82 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
83 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 83 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
84 (SkDisplacementMapEffect::kR_ChannelSelectorType, 84 (SkDisplacementMapEffect::kR_ChannelSelectorType,
85 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->un ref(); 85 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->un ref();
86 drawClippedBitmap(canvas, 0, 0, paint); 86 drawClippedBitmap(canvas, 0, 0, paint);
87 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 87 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
88 (SkDisplacementMapEffect::kB_ChannelSelectorType, 88 (SkDisplacementMapEffect::kB_ChannelSelectorType,
89 SkDisplacementMapEffect::kA_ChannelSelectorType, 0.2f, displ)))->un ref(); 89 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->u nref();
90 drawClippedBitmap(canvas, 100, 0, paint); 90 drawClippedBitmap(canvas, 100, 0, paint);
91 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 91 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
92 (SkDisplacementMapEffect::kR_ChannelSelectorType, 92 (SkDisplacementMapEffect::kR_ChannelSelectorType,
93 SkDisplacementMapEffect::kB_ChannelSelectorType, 0.4f, displ)))->un ref(); 93 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->u nref();
94 drawClippedBitmap(canvas, 200, 0, paint); 94 drawClippedBitmap(canvas, 200, 0, paint);
95 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 95 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
96 (SkDisplacementMapEffect::kG_ChannelSelectorType, 96 (SkDisplacementMapEffect::kG_ChannelSelectorType,
97 SkDisplacementMapEffect::kA_ChannelSelectorType, 0.6f, displ)))->un ref(); 97 SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ)))->u nref();
98 drawClippedBitmap(canvas, 300, 0, paint); 98 drawClippedBitmap(canvas, 300, 0, paint);
99 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 99 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
100 (SkDisplacementMapEffect::kR_ChannelSelectorType, 100 (SkDisplacementMapEffect::kR_ChannelSelectorType,
101 SkDisplacementMapEffect::kA_ChannelSelectorType, 0.8f, displ)))->un ref(); 101 SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ)))->u nref();
102 drawClippedBitmap(canvas, 400, 0, paint); 102 drawClippedBitmap(canvas, 400, 0, paint);
103 103
104 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 104 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
105 (SkDisplacementMapEffect::kR_ChannelSelectorType, 105 (SkDisplacementMapEffect::kR_ChannelSelectorType,
106 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.5f, displ)))->un ref(); 106 SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ)))->u nref();
107 drawClippedBitmap(canvas, 0, 100, paint); 107 drawClippedBitmap(canvas, 0, 100, paint);
108 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 108 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
109 (SkDisplacementMapEffect::kB_ChannelSelectorType, 109 (SkDisplacementMapEffect::kB_ChannelSelectorType,
110 SkDisplacementMapEffect::kA_ChannelSelectorType, 0.5f, displ)))->un ref(); 110 SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->u nref();
111 drawClippedBitmap(canvas, 100, 100, paint); 111 drawClippedBitmap(canvas, 100, 100, paint);
112 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 112 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
113 (SkDisplacementMapEffect::kR_ChannelSelectorType, 113 (SkDisplacementMapEffect::kR_ChannelSelectorType,
114 SkDisplacementMapEffect::kB_ChannelSelectorType, 0.5f, displ)))->un ref(); 114 SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ)))->u nref();
115 drawClippedBitmap(canvas, 200, 100, paint); 115 drawClippedBitmap(canvas, 200, 100, paint);
116 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 116 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
117 (SkDisplacementMapEffect::kG_ChannelSelectorType, 117 (SkDisplacementMapEffect::kG_ChannelSelectorType,
118 SkDisplacementMapEffect::kA_ChannelSelectorType, 0.5f, displ)))->un ref(); 118 SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->u nref();
119 drawClippedBitmap(canvas, 300, 100, paint); 119 drawClippedBitmap(canvas, 300, 100, paint);
120 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 120 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
121 (SkDisplacementMapEffect::kR_ChannelSelectorType, 121 (SkDisplacementMapEffect::kR_ChannelSelectorType,
122 SkDisplacementMapEffect::kA_ChannelSelectorType, 0.5f, displ)))->un ref(); 122 SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->u nref();
123 drawClippedBitmap(canvas, 400, 100, paint); 123 drawClippedBitmap(canvas, 400, 100, paint);
124 } 124 }
125 125
126 private: 126 private:
127 typedef GM INHERITED; 127 typedef GM INHERITED;
128 SkBitmap fBitmap, fCheckerboard; 128 SkBitmap fBitmap, fCheckerboard;
129 bool fInitialized; 129 bool fInitialized;
130 }; 130 };
131 131
132 ////////////////////////////////////////////////////////////////////////////// 132 //////////////////////////////////////////////////////////////////////////////
133 133
134 static GM* MyFactory(void*) { return new DisplacementMapGM; } 134 static GM* MyFactory(void*) { return new DisplacementMapGM; }
135 static GMRegistry reg(MyFactory); 135 static GMRegistry reg(MyFactory);
136 136
137 } 137 }
OLDNEW
« no previous file with comments | « no previous file | include/core/SkScalar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698