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

Side by Side Diff: samplecode/SampleFilter2.cpp

Issue 51033004: add SK_ATTR_DEPRECATED -- will need to disable for chrome, since it triggers a warning (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | « samplecode/SampleFilter.cpp ('k') | samplecode/SampleFilterFuzz.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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 canvas->translate(SkIntToScalar(10), SkIntToScalar(50)); 69 canvas->translate(SkIntToScalar(10), SkIntToScalar(50));
70 70
71 const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1); 71 const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1);
72 const SkScalar H = SkIntToScalar(fBitmaps[0].height() + 1); 72 const SkScalar H = SkIntToScalar(fBitmaps[0].height() + 1);
73 SkPaint paint; 73 SkPaint paint;
74 74
75 const SkScalar scale = SkFloatToScalar(0.897917f); 75 const SkScalar scale = SkFloatToScalar(0.897917f);
76 canvas->scale(SK_Scalar1, scale); 76 canvas->scale(SK_Scalar1, scale);
77 77
78 for (int k = 0; k < 2; k++) { 78 for (int k = 0; k < 2; k++) {
79 paint.setFilterBitmap(k == 1); 79 paint.setFilterLevel(k == 1 ? SkPaint::kLow_FilterLevel : SkPaint::k None_FilterLevel);
80 for (int j = 0; j < 2; j++) { 80 for (int j = 0; j < 2; j++) {
81 paint.setDither(j == 1); 81 paint.setDither(j == 1);
82 for (int i = 0; i < fBitmapCount; i++) { 82 for (int i = 0; i < fBitmapCount; i++) {
83 SkScalar x = (k * fBitmapCount + j) * W; 83 SkScalar x = (k * fBitmapCount + j) * W;
84 SkScalar y = i * H; 84 SkScalar y = i * H;
85 x = SkIntToScalar(SkScalarRound(x)); 85 x = SkIntToScalar(SkScalarRound(x));
86 y = SkIntToScalar(SkScalarRound(y)); 86 y = SkIntToScalar(SkScalarRound(y));
87 canvas->drawBitmap(fBitmaps[i], x, y, &paint); 87 canvas->drawBitmap(fBitmaps[i], x, y, &paint);
88 if (i == 0) { 88 if (i == 0) {
89 SkPaint p; 89 SkPaint p;
90 p.setAntiAlias(true); 90 p.setAntiAlias(true);
91 p.setTextAlign(SkPaint::kCenter_Align); 91 p.setTextAlign(SkPaint::kCenter_Align);
92 p.setTextSize(SkIntToScalar(18)); 92 p.setTextSize(SkIntToScalar(18));
93 SkString s("dither="); 93 SkString s("dither=");
94 s.appendS32(paint.isDither()); 94 s.appendS32(paint.isDither());
95 s.append(" filter="); 95 s.append(" filter=");
96 s.appendS32(paint.isFilterBitmap()); 96 s.appendS32(paint.getFilterLevel() != SkPaint::kNone_Fil terLevel);
97 canvas->drawText(s.c_str(), s.size(), x + W/2, 97 canvas->drawText(s.c_str(), s.size(), x + W/2,
98 y - p.getTextSize(), p); 98 y - p.getTextSize(), p);
99 } 99 }
100 if (k+j == 2) { 100 if (k+j == 2) {
101 SkPaint p; 101 SkPaint p;
102 p.setAntiAlias(true); 102 p.setAntiAlias(true);
103 p.setTextSize(SkIntToScalar(18)); 103 p.setTextSize(SkIntToScalar(18));
104 SkString s; 104 SkString s;
105 s.append(" depth="); 105 s.append(" depth=");
106 s.appendS32(fBitmaps[i].config() == SkBitmap::kRGB_565_C onfig ? 16 : 32); 106 s.appendS32(fBitmaps[i].config() == SkBitmap::kRGB_565_C onfig ? 16 : 32);
107 canvas->drawText(s.c_str(), s.size(), x + W + SkIntToSca lar(4), 107 canvas->drawText(s.c_str(), s.size(), x + W + SkIntToSca lar(4),
108 y + H/2, p); 108 y + H/2, p);
109 } 109 }
110 } 110 }
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 private: 115 private:
116 typedef SampleView INHERITED; 116 typedef SampleView INHERITED;
117 }; 117 };
118 118
119 ////////////////////////////////////////////////////////////////////////////// 119 //////////////////////////////////////////////////////////////////////////////
120 120
121 static SkView* MyFactory() { return new Filter2View; } 121 static SkView* MyFactory() { return new Filter2View; }
122 static SkViewRegister reg(MyFactory); 122 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleFilter.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698