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

Side by Side Diff: gm/filterindiabox.cpp

Issue 334793002: hide Config in SkImageDecoder -- use SkColorType instead (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning 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
« no previous file with comments | « gm/filterbitmap.cpp ('k') | gm/gm_expectations.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 27 matching lines...) Expand all
38 canvas->translate(dx, 0); 38 canvas->translate(dx, 0);
39 canvas->drawBitmapMatrix(bm, mat, &paint); 39 canvas->drawBitmapMatrix(bm, mat, &paint);
40 40
41 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); 41 paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
42 canvas->translate(dx, 0); 42 canvas->translate(dx, 0);
43 canvas->drawBitmapMatrix(bm, mat, &paint); 43 canvas->drawBitmapMatrix(bm, mat, &paint);
44 } 44 }
45 45
46 class FilterIndiaBoxGM : public skiagm::GM { 46 class FilterIndiaBoxGM : public skiagm::GM {
47 void onOnceBeforeDraw() { 47 void onOnceBeforeDraw() {
48
49 this->makeBitmap(); 48 this->makeBitmap();
50 49
51 SkScalar cx = SkScalarHalf(fBM.width()); 50 SkScalar cx = SkScalarHalf(fBM.width());
52 SkScalar cy = SkScalarHalf(fBM.height()); 51 SkScalar cy = SkScalarHalf(fBM.height());
53 52
54 float vertScale = 30.0f/55.0f; 53 float vertScale = 30.0f/55.0f;
55 float horizScale = 150.0f/200.0f; 54 float horizScale = 150.0f/200.0f;
56 55
57 fMatrix[0].setScale(horizScale, vertScale); 56 fMatrix[0].setScale(horizScale, vertScale);
58 fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(horizScale, vertS cale); 57 fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(horizScale, vertS cale);
59 } 58 }
60 59
61 public: 60 public:
62 SkBitmap fBM; 61 SkBitmap fBM;
63 SkMatrix fMatrix[2]; 62 SkMatrix fMatrix[2];
64 SkString fName; 63 SkString fName;
65 64
66 FilterIndiaBoxGM() 65 FilterIndiaBoxGM() {
67 {
68 this->setBGColor(0xFFDDDDDD); 66 this->setBGColor(0xFFDDDDDD);
69 } 67 }
70 68
71 FilterIndiaBoxGM(const char filename[]) 69 FilterIndiaBoxGM(const char filename[]) : fFilename(filename) {
72 : fFilename(filename)
73 {
74 fName.printf("filterindiabox"); 70 fName.printf("filterindiabox");
75 } 71 }
76 72
77 protected: 73 protected:
78 virtual uint32_t onGetFlags() const SK_OVERRIDE { 74 virtual uint32_t onGetFlags() const SK_OVERRIDE {
79 return kSkipTiled_Flag; 75 return kSkipTiled_Flag;
80 } 76 }
81 77
82 virtual SkString onShortName() SK_OVERRIDE { 78 virtual SkString onShortName() SK_OVERRIDE {
83 return fName; 79 return fName;
84 } 80 }
85 81
86 virtual SkISize onISize() SK_OVERRIDE { 82 virtual SkISize onISize() SK_OVERRIDE {
87 return SkISize::Make(1024, 768); 83 return SkISize::Make(1024, 768);
88 } 84 }
89 85
90 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 86 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
91
92 canvas->translate(10, 10); 87 canvas->translate(10, 10);
93 for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrix); ++i) { 88 for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrix); ++i) {
94 SkSize size = computeSize(fBM, fMatrix[i]); 89 SkSize size = computeSize(fBM, fMatrix[i]);
95 size.fWidth += 20; 90 size.fWidth += 20;
96 size.fHeight += 20; 91 size.fHeight += 20;
97 92
98 draw_row(canvas, fBM, fMatrix[i], size.fWidth); 93 draw_row(canvas, fBM, fMatrix[i], size.fWidth);
99 canvas->translate(0, size.fHeight); 94 canvas->translate(0, size.fHeight);
100 } 95 }
101 } 96 }
(...skipping 11 matching lines...) Expand all
113 path.append("/"); 108 path.append("/");
114 path.append(fFilename); 109 path.append(fFilename);
115 110
116 SkImageDecoder *codec = NULL; 111 SkImageDecoder *codec = NULL;
117 SkFILEStream stream(path.c_str()); 112 SkFILEStream stream(path.c_str());
118 if (stream.isValid()) { 113 if (stream.isValid()) {
119 codec = SkImageDecoder::Factory(&stream); 114 codec = SkImageDecoder::Factory(&stream);
120 } 115 }
121 if (codec) { 116 if (codec) {
122 stream.rewind(); 117 stream.rewind();
123 codec->decode(&stream, &fBM, SkBitmap::kARGB_8888_Config, 118 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe codePixels_Mode);
124 SkImageDecoder::kDecodePixels_Mode);
125 SkDELETE(codec); 119 SkDELETE(codec);
126 } else { 120 } else {
127 fBM.allocN32Pixels(1, 1); 121 fBM.allocN32Pixels(1, 1);
128 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 122 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
129 } 123 }
130 fSize = fBM.height(); 124 fSize = fBM.height();
131 } 125 }
132 private: 126 private:
133 typedef skiagm::GM INHERITED; 127 typedef skiagm::GM INHERITED;
134 }; 128 };
135 129
136 ////////////////////////////////////////////////////////////////////////////// 130 //////////////////////////////////////////////////////////////////////////////
137 131
138 132
139 DEF_GM( return new FilterIndiaBoxGM("box.gif"); ) 133 DEF_GM( return new FilterIndiaBoxGM("box.gif"); )
OLDNEW
« no previous file with comments | « gm/filterbitmap.cpp ('k') | gm/gm_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698