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

Side by Side Diff: gm/nocolorbleed.cpp

Issue 23264014: Bleed cleanup (remove nocolorbleed GM & enable bleed in game bench) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 | « bench/GameBench.cpp ('k') | 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 /*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #include "gm.h"
9
10 namespace skiagm {
11
12 class NoColorBleedGM : public GM {
13 public:
14 NoColorBleedGM() {
15 this->setBGColor(0xFFDDDDDD);
16 }
17
18 protected:
19 virtual SkString onShortName() {
20 return SkString("nocolorbleed");
21 }
22
23 virtual SkISize onISize() {
24 return make_isize(200, 200);
25 }
26
27 virtual void onDraw(SkCanvas* canvas) {
28 SkBitmap sprite;
29 sprite.setConfig(SkBitmap::kARGB_8888_Config, 4, 4, 4*sizeof(SkColor));
30 const SkColor spriteData[16] = {
31 SK_ColorBLACK, SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW,
32 SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorRED,
33 SK_ColorGREEN, SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLUE,
34 SK_ColorYELLOW, SK_ColorMAGENTA, SK_ColorCYAN, SK_ColorBLACK
35 };
36 sprite.allocPixels();
37 sprite.lockPixels();
38 SkPMColor* addr = sprite.getAddr32(0, 0);
39 for (size_t i = 0; i < SK_ARRAY_COUNT(spriteData); ++i) {
40 addr[i] = SkPreMultiplyColor(spriteData[i]);
41 }
42 sprite.unlockPixels();
43
44 // We draw a magnified subrect of the sprite
45 // sample interpolation may cause color bleeding around edges
46 // the subrect is a pure white area
47 SkIRect srcRect;
48 SkRect dstRect;
49 SkPaint paint;
50 paint.setFilterBitmap(true);
51 //First row : full texture with and without filtering
52 srcRect.setXYWH(0, 0, 4, 4);
53 dstRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0)
54 , SkIntToScalar(100), SkIntToScalar(100));
55 canvas->drawBitmapRect(sprite, &srcRect, dstRect, &paint);
56 dstRect.setXYWH(SkIntToScalar(100), SkIntToScalar(0)
57 , SkIntToScalar(100), SkIntToScalar(100));
58 canvas->drawBitmapRect(sprite, &srcRect, dstRect);
59 //Second row : sub rect of texture with and without filtering
60 srcRect.setXYWH(1, 1, 2, 2);
61 dstRect.setXYWH(SkIntToScalar(25), SkIntToScalar(125)
62 , SkIntToScalar(50), SkIntToScalar(50));
63 canvas->drawBitmapRect(sprite, &srcRect, dstRect, &paint);
64 dstRect.setXYWH(SkIntToScalar(125), SkIntToScalar(125)
65 , SkIntToScalar(50), SkIntToScalar(50));
66 canvas->drawBitmapRect(sprite, &srcRect, dstRect);
67 }
68
69 private:
70 typedef GM INHERITED;
71 };
72
73 //////////////////////////////////////////////////////////////////////////////
74
75 static GM* MyFactory(void*) { return new NoColorBleedGM; }
76 static GMRegistry reg(MyFactory);
77
78 }
OLDNEW
« no previous file with comments | « bench/GameBench.cpp ('k') | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698