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

Side by Side Diff: gm/bitmaprect.cpp

Issue 303403003: using real tiles when simulating tiling (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: put no_tiling case first Created 6 years, 6 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 | samplecode/SampleApp.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 } 166 }
167 } 167 }
168 168
169 // This GM attempts to reveal any issues we may have when the GPU has to 169 // This GM attempts to reveal any issues we may have when the GPU has to
170 // break up a large texture in order to draw it. The XOR transfer mode will 170 // break up a large texture in order to draw it. The XOR transfer mode will
171 // create stripes in the image if there is imprecision in the destination 171 // create stripes in the image if there is imprecision in the destination
172 // tile placement. 172 // tile placement.
173 class DrawBitmapRect4 : public skiagm::GM { 173 class DrawBitmapRect4 : public skiagm::GM {
174 bool fUseIRect; 174 bool fUseIRect;
175 SkBitmap fBigBitmap;
176
175 public: 177 public:
176 DrawBitmapRect4(bool useIRect) : fUseIRect(useIRect) { 178 DrawBitmapRect4(bool useIRect) : fUseIRect(useIRect) {
177 this->setBGColor(0x88444444); 179 this->setBGColor(0x88444444);
178 } 180 }
179 181
180 protected: 182 protected:
181 virtual SkString onShortName() SK_OVERRIDE { 183 virtual SkString onShortName() SK_OVERRIDE {
182 SkString str; 184 SkString str;
183 str.printf("bigbitmaprect_%s", fUseIRect ? "i" : "s"); 185 str.printf("bigbitmaprect_%s", fUseIRect ? "i" : "s");
184 return str; 186 return str;
185 } 187 }
186 188
187 virtual SkISize onISize() SK_OVERRIDE { 189 virtual SkISize onISize() SK_OVERRIDE {
188 return SkISize::Make(640, 480); 190 return SkISize::Make(640, 480);
189 } 191 }
190 192
193 virtual void onOnceBeforeDraw() SK_OVERRIDE {
194 make_big_bitmap(&fBigBitmap);
195 }
196
191 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 197 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
192 198
193 SkXfermode* mode = SkXfermode::Create(SkXfermode::kXor_Mode); 199 SkXfermode* mode = SkXfermode::Create(SkXfermode::kXor_Mode);
194 200
195 SkPaint paint; 201 SkPaint paint;
196 paint.setAlpha(128); 202 paint.setAlpha(128);
197 paint.setXfermode(mode)->unref(); 203 paint.setXfermode(mode)->unref();
198 204
199 SkBitmap bitmap;
200 make_big_bitmap(&bitmap);
201
202 SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f }; 205 SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f };
203 SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f }; 206 SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f };
204 207
205 SkRect srcR2 = { 4085.0f, 10.0f, 4087.0f, 12.0f }; 208 SkRect srcR2 = { 4085.0f, 10.0f, 4087.0f, 12.0f };
206 SkRect dstR2 = { 10, 410, 30, 430 }; 209 SkRect dstR2 = { 10, 410, 30, 430 };
207 210
208 if (!fUseIRect) { 211 if (!fUseIRect) {
209 canvas->drawBitmapRectToRect(bitmap, &srcR1, dstR1, &paint); 212 canvas->drawBitmapRectToRect(fBigBitmap, &srcR1, dstR1, &paint);
210 canvas->drawBitmapRectToRect(bitmap, &srcR2, dstR2, &paint); 213 canvas->drawBitmapRectToRect(fBigBitmap, &srcR2, dstR2, &paint);
211 } else { 214 } else {
212 SkIRect iSrcR1, iSrcR2; 215 SkIRect iSrcR1, iSrcR2;
213 216
214 srcR1.roundOut(&iSrcR1); 217 srcR1.roundOut(&iSrcR1);
215 srcR2.roundOut(&iSrcR2); 218 srcR2.roundOut(&iSrcR2);
216 219
217 canvas->drawBitmapRect(bitmap, &iSrcR1, dstR1, &paint); 220 canvas->drawBitmapRect(fBigBitmap, &iSrcR1, dstR1, &paint);
218 canvas->drawBitmapRect(bitmap, &iSrcR2, dstR2, &paint); 221 canvas->drawBitmapRect(fBigBitmap, &iSrcR2, dstR2, &paint);
219 } 222 }
220 } 223 }
221 224
222 private: 225 private:
223 typedef skiagm::GM INHERITED; 226 typedef skiagm::GM INHERITED;
224 }; 227 };
225 228
226 ////////////////////////////////////////////////////////////////////////////// 229 //////////////////////////////////////////////////////////////////////////////
227 230
228 static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); } 231 static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); }
229 static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); } 232 static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); }
230 233
231 static skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); } 234 static skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); }
232 235
233 #ifndef SK_BUILD_FOR_ANDROID 236 #ifndef SK_BUILD_FOR_ANDROID
234 static skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); } 237 static skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); }
235 static skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); } 238 static skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); }
236 #endif 239 #endif
237 240
238 static skiagm::GMRegistry reg0(MyFactory0); 241 static skiagm::GMRegistry reg0(MyFactory0);
239 static skiagm::GMRegistry reg1(MyFactory1); 242 static skiagm::GMRegistry reg1(MyFactory1);
240 243
241 static skiagm::GMRegistry reg2(MyFactory2); 244 static skiagm::GMRegistry reg2(MyFactory2);
242 245
243 #ifndef SK_BUILD_FOR_ANDROID 246 #ifndef SK_BUILD_FOR_ANDROID
244 static skiagm::GMRegistry reg3(MyFactory3); 247 static skiagm::GMRegistry reg3(MyFactory3);
245 static skiagm::GMRegistry reg4(MyFactory4); 248 static skiagm::GMRegistry reg4(MyFactory4);
246 #endif 249 #endif
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698