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

Side by Side Diff: samplecode/SampleOverflow.cpp

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #include "SampleCode.h"
9 #include "SkView.h"
10 #include "SkCanvas.h"
11 #include "SkDevice.h"
12 #include "SkPaint.h"
13
14 static void DrawRoundRect() {
15 #ifdef SK_SCALAR_IS_FIXED
16 bool ret = false;
17 SkPaint paint;
18 SkBitmap bitmap;
19 SkMatrix matrix;
20 matrix.reset();
21
22 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1370, 812);
23 bitmap.allocPixels();
24
25 SkCanvas canvas(bitmap);
26
27 // set up clipper
28 SkRect skclip;
29 skclip.set(SkIntToFixed(284), SkIntToFixed(40), SkIntToFixed(1370), SkIntToF ixed(708));
30
31 ret = canvas.clipRect(skclip);
32 SkASSERT(ret);
33
34 matrix.set(SkMatrix::kMTransX, SkFloatToFixed(-1153.28));
35 matrix.set(SkMatrix::kMTransY, SkFloatToFixed(1180.50));
36
37 matrix.set(SkMatrix::kMScaleX, SkFloatToFixed(0.177171));
38 matrix.set(SkMatrix::kMScaleY, SkFloatToFixed(0.177043));
39
40 matrix.set(SkMatrix::kMSkewX, SkFloatToFixed(0.126968));
41 matrix.set(SkMatrix::kMSkewY, SkFloatToFixed(-0.126876));
42
43 matrix.set(SkMatrix::kMPersp0, SkFloatToFixed(0.0));
44 matrix.set(SkMatrix::kMPersp1, SkFloatToFixed(0.0));
45
46 ret = canvas.concat(matrix);
47
48 paint.setAntiAlias(true);
49 paint.setColor(0xb2202020);
50 paint.setStyle(SkPaint::kStroke_Style);
51 paint.setStrokeWidth(SkFloatToFixed(68.13));
52
53 SkRect r;
54 r.set(SkFloatToFixed(-313.714417), SkFloatToFixed(-4.826389), SkFloatToFixed (18014.447266), SkFloatToFixed(1858.154541));
55 canvas.drawRoundRect(r, SkFloatToFixed(91.756363), SkFloatToFixed(91.756363) , paint);
56 #endif
57 }
58
59 #ifdef SK_SCALAR_IS_FLOATx // FIXME: unclear when if ever this can be enabled
60 static bool HitTestPath(const SkPath& path, SkScalar x, SkScalar y) {
61 SkRegion rgn, clip;
62
63 int ix = SkScalarFloor(x);
64 int iy = SkScalarFloor(y);
65
66 clip.setRect(ix, iy, ix + 1, iy + 1);
67
68 bool contains = rgn.setPath(path, clip);
69 return contains;
70 }
71 #endif
72
73 static void TestOverflowHitTest() {
74 SkPath path;
75
76 #ifdef SK_SCALAR_IS_FLOATx // FIXME: unclear when if ever this can be enabled
77 path.addCircle(0, 0, 70000, SkPath::kCCW_Direction);
78 SkASSERT(HitTestPath(path, 40000, 40000));
79 #endif
80 }
81
82 class OverflowView : public SampleView {
83 public:
84 OverflowView() {}
85
86 protected:
87 // overrides from SkEventSink
88 virtual bool onQuery(SkEvent* evt) {
89 if (SampleCode::TitleQ(*evt)) {
90 SampleCode::TitleR(evt, "Circles");
91 return true;
92 }
93 return this->INHERITED::onQuery(evt);
94 }
95
96 virtual void onDrawContent(SkCanvas* canvas) {
97 DrawRoundRect();
98 TestOverflowHitTest();
99 }
100
101 private:
102 typedef SampleView INHERITED;
103 };
104
105 //////////////////////////////////////////////////////////////////////////////
106
107 static SkView* MyFactory() { return new OverflowView; }
108 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698