| 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
| 9 #include "SampleCode.h" | 9 #include "SampleCode.h" |
| 10 #include "SkView.h" | 10 #include "SkView.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 Style getStyle() const { return fStyle; } | 81 Style getStyle() const { return fStyle; } |
| 82 void setStyle(Style s) { fStyle = s; } | 82 void setStyle(Style s) { fStyle = s; } |
| 83 | 83 |
| 84 void setWHZ(int width, int height, int zoom) { | 84 void setWHZ(int width, int height, int zoom) { |
| 85 fW = width; | 85 fW = width; |
| 86 fH = height; | 86 fH = height; |
| 87 fZoom = zoom; | 87 fZoom = zoom; |
| 88 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo
om)); | 88 fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zo
om)); |
| 89 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); | 89 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom)); |
| 90 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); | 90 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom); |
| 91 fShader.reset(sk_tool_utils::create_checkerboard_shader( | 91 fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFF
FF, zoom); |
| 92 0xFFCCCCCC, 0xFFFFFFFF, zoom)); | |
| 93 | 92 |
| 94 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 93 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
| 95 fMinSurface.reset(SkSurface::NewRaster(info)); | 94 fMinSurface.reset(SkSurface::NewRaster(info)); |
| 96 info = info.makeWH(width * zoom, height * zoom); | 95 info = info.makeWH(width * zoom, height * zoom); |
| 97 fMaxSurface.reset(SkSurface::NewRaster(info)); | 96 fMaxSurface.reset(SkSurface::NewRaster(info)); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void drawBG(SkCanvas*); | 99 void drawBG(SkCanvas*); |
| 101 void drawFG(SkCanvas*); | 100 void drawFG(SkCanvas*); |
| 102 void drawLine(SkCanvas*, SkPoint pts[2]); | 101 void drawLine(SkCanvas*, SkPoint pts[2]); |
| 103 void drawRect(SkCanvas* canvas, SkPoint pts[2]); | 102 void drawRect(SkCanvas* canvas, SkPoint pts[2]); |
| 104 void drawTriangle(SkCanvas* canvas, SkPoint pts[3]); | 103 void drawTriangle(SkCanvas* canvas, SkPoint pts[3]); |
| 105 | 104 |
| 106 SkPaint::Cap fStrokeCap; | 105 SkPaint::Cap fStrokeCap; |
| 107 | 106 |
| 108 private: | 107 private: |
| 109 bool fAA, fGrid, fShowSkeleton, fUseGPU, fUseClip, fRectAsOval, fUseTriangle
; | 108 bool fAA, fGrid, fShowSkeleton, fUseGPU, fUseClip, fRectAsOval, fUseTriangle
; |
| 110 Style fStyle; | 109 Style fStyle; |
| 111 int fW, fH, fZoom; | 110 int fW, fH, fZoom; |
| 112 SkMatrix fMatrix, fInverse; | 111 SkMatrix fMatrix, fInverse; |
| 113 SkRect fBounds, fClipRect; | 112 SkRect fBounds, fClipRect; |
| 114 SkAutoTUnref<SkShader> fShader; | 113 sk_sp<SkShader> fShader; |
| 115 SkAutoTUnref<SkSurface> fMinSurface; | 114 SkAutoTUnref<SkSurface> fMinSurface; |
| 116 SkAutoTUnref<SkSurface> fMaxSurface; | 115 SkAutoTUnref<SkSurface> fMaxSurface; |
| 117 | 116 |
| 118 void setupPaint(SkPaint* paint) { | 117 void setupPaint(SkPaint* paint) { |
| 119 bool aa = this->getAA(); | 118 bool aa = this->getAA(); |
| 120 paint->setStrokeCap(fStrokeCap); | 119 paint->setStrokeCap(fStrokeCap); |
| 121 switch (fStyle) { | 120 switch (fStyle) { |
| 122 case kHair_Style: | 121 case kHair_Style: |
| 123 paint->setStrokeWidth(0); | 122 paint->setStrokeWidth(0); |
| 124 break; | 123 break; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 525 |
| 527 private: | 526 private: |
| 528 | 527 |
| 529 typedef SampleView INHERITED; | 528 typedef SampleView INHERITED; |
| 530 }; | 529 }; |
| 531 | 530 |
| 532 ////////////////////////////////////////////////////////////////////////////// | 531 ////////////////////////////////////////////////////////////////////////////// |
| 533 | 532 |
| 534 static SkView* MyFactory() { return new DrawLineView; } | 533 static SkView* MyFactory() { return new DrawLineView; } |
| 535 static SkViewRegister reg(MyFactory); | 534 static SkViewRegister reg(MyFactory); |
| OLD | NEW |