OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 void setWHZ(int width, int height, int zoom) { | 100 void setWHZ(int width, int height, int zoom) { |
101 fW = width; | 101 fW = width; |
102 fH = height; | 102 fH = height; |
103 fZoom = zoom; | 103 fZoom = zoom; |
104 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo
om)); | 104 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo
om)); |
105 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); | 105 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); |
106 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); | 106 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); |
107 fShader->setLocalMatrix(fMatrix); | 107 fShader->setLocalMatrix(fMatrix); |
108 | 108 |
109 SkImageInfo info = { | 109 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
110 width, height, kPMColor_SkColorType, kPremul_SkAlphaType | |
111 }; | |
112 fMinSurface.reset(SkSurface::NewRaster(info)); | 110 fMinSurface.reset(SkSurface::NewRaster(info)); |
113 info.fWidth *= zoom; | 111 info.fWidth *= zoom; |
114 info.fHeight *= zoom; | 112 info.fHeight *= zoom; |
115 fMaxSurface.reset(SkSurface::NewRaster(info)); | 113 fMaxSurface.reset(SkSurface::NewRaster(info)); |
116 } | 114 } |
117 | 115 |
118 void drawBG(SkCanvas*); | 116 void drawBG(SkCanvas*); |
119 void drawFG(SkCanvas*); | 117 void drawFG(SkCanvas*); |
120 void drawLine(SkCanvas*, SkPoint pts[2]); | 118 void drawLine(SkCanvas*, SkPoint pts[2]); |
121 void drawRect(SkCanvas* canvas, SkPoint pts[2]); | 119 void drawRect(SkCanvas* canvas, SkPoint pts[2]); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 523 |
526 private: | 524 private: |
527 | 525 |
528 typedef SampleView INHERITED; | 526 typedef SampleView INHERITED; |
529 }; | 527 }; |
530 | 528 |
531 ////////////////////////////////////////////////////////////////////////////// | 529 ////////////////////////////////////////////////////////////////////////////// |
532 | 530 |
533 static SkView* MyFactory() { return new DrawLineView; } | 531 static SkView* MyFactory() { return new DrawLineView; } |
534 static SkViewRegister reg(MyFactory); | 532 static SkViewRegister reg(MyFactory); |
OLD | NEW |