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

Side by Side Diff: samplecode/SampleFatBits.cpp

Issue 278903002: Revert of hide get/setLocalMatrix (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 | « include/core/SkShader.h ('k') | src/core/SkPictureShader.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 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 17 matching lines...) Expand all
28 static void apply_grid(SkPoint pts[], int count) { 28 static void apply_grid(SkPoint pts[], int count) {
29 for (int i = 0; i < count; ++i) { 29 for (int i = 0; i < count; ++i) {
30 pts[i].set(apply_grid(pts[i].fX), apply_grid(pts[i].fY)); 30 pts[i].set(apply_grid(pts[i].fX), apply_grid(pts[i].fY));
31 } 31 }
32 } 32 }
33 33
34 static void erase(SkSurface* surface) { 34 static void erase(SkSurface* surface) {
35 surface->getCanvas()->clear(SK_ColorTRANSPARENT); 35 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
36 } 36 }
37 37
38 static SkShader* createChecker(const SkMatrix& localMatrix) { 38 static SkShader* createChecker() {
39 // SkColor colors[] = { 0xFFFDFDFD, 0xFFF4F4F4 }; 39 // SkColor colors[] = { 0xFFFDFDFD, 0xFFF4F4F4 };
40 SkColor colors[] = { 0xFFFFFFFF, 0xFFFFFFFF }; 40 SkColor colors[] = { 0xFFFFFFFF, 0xFFFFFFFF };
41 SkBitmap bm; 41 SkBitmap bm;
42 bm.allocN32Pixels(2, 2); 42 bm.allocN32Pixels(2, 2);
43 bm.lockPixels(); 43 bm.lockPixels();
44 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = SkPreMultiplyColor(colors[0]); 44 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = SkPreMultiplyColor(colors[0]);
45 *bm.getAddr32(0, 1) = *bm.getAddr32(1, 0) = SkPreMultiplyColor(colors[1]); 45 *bm.getAddr32(0, 1) = *bm.getAddr32(1, 0) = SkPreMultiplyColor(colors[1]);
46 SkMatrix m;
47 m.setScale(12, 12);
46 return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, 48 return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
47 SkShader::kRepeat_TileMode, &localMatrix ); 49 SkShader::kRepeat_TileMode, &m);
48 } 50 }
49 51
50 class FatBits { 52 class FatBits {
51 public: 53 public:
52 FatBits() { 54 FatBits() : fShader(createChecker()) {
53 fAA = false; 55 fAA = false;
54 fStyle = kHair_Style; 56 fStyle = kHair_Style;
55 fGrid = true; 57 fGrid = true;
56 fShowSkeleton = true; 58 fShowSkeleton = true;
57 fUseGPU = false; 59 fUseGPU = false;
58 fUseClip = false; 60 fUseClip = false;
59 fRectAsOval = false; 61 fRectAsOval = false;
60 fUseTriangle = false; 62 fUseTriangle = false;
61 63
62 fClipRect.set(2, 2, 11, 8 ); 64 fClipRect.set(2, 2, 11, 8 );
(...skipping 28 matching lines...) Expand all
91 Style getStyle() const { return fStyle; } 93 Style getStyle() const { return fStyle; }
92 void setStyle(Style s) { fStyle = s; } 94 void setStyle(Style s) { fStyle = s; }
93 95
94 void setWHZ(int width, int height, int zoom) { 96 void setWHZ(int width, int height, int zoom) {
95 fW = width; 97 fW = width;
96 fH = height; 98 fH = height;
97 fZoom = zoom; 99 fZoom = zoom;
98 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo om)); 100 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo om));
99 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); 101 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
100 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); 102 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
101 fShader.reset(createChecker(fMatrix)); 103 fShader->setLocalMatrix(fMatrix);
102 104
103 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 105 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
104 fMinSurface.reset(SkSurface::NewRaster(info)); 106 fMinSurface.reset(SkSurface::NewRaster(info));
105 info.fWidth *= zoom; 107 info.fWidth *= zoom;
106 info.fHeight *= zoom; 108 info.fHeight *= zoom;
107 fMaxSurface.reset(SkSurface::NewRaster(info)); 109 fMaxSurface.reset(SkSurface::NewRaster(info));
108 } 110 }
109 111
110 void drawBG(SkCanvas*); 112 void drawBG(SkCanvas*);
111 void drawFG(SkCanvas*); 113 void drawFG(SkCanvas*);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 519
518 private: 520 private:
519 521
520 typedef SampleView INHERITED; 522 typedef SampleView INHERITED;
521 }; 523 };
522 524
523 ////////////////////////////////////////////////////////////////////////////// 525 //////////////////////////////////////////////////////////////////////////////
524 526
525 static SkView* MyFactory() { return new DrawLineView; } 527 static SkView* MyFactory() { return new DrawLineView; }
526 static SkViewRegister reg(MyFactory); 528 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/core/SkShader.h ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698