Skip to content

Commit 3e34cf7

Browse files
committed
[lib] Reduced calling of property setters in renderer
1 parent 20dee96 commit 3e34cf7

File tree

1 file changed

+21
-34
lines changed
  • tehreer-android/src/main/java/com/mta/tehreer/graphics

1 file changed

+21
-34
lines changed

tehreer-android/src/main/java/com/mta/tehreer/graphics/Renderer.java

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,56 +34,43 @@
3434
* glyph paths, measure their bounding boxes and draw them on a <code>Canvas</code> object.
3535
*/
3636
public class Renderer {
37-
3837
private static final String TAG = Renderer.class.getSimpleName();
3938

40-
private GlyphStrike mGlyphStrike;
39+
private GlyphStrike mGlyphStrike = new GlyphStrike();
4140
private int mGlyphLineRadius;
4241
private int mGlyphLineCap;
4342
private int mGlyphLineJoin;
4443
private int mGlyphMiterLimit;
4544

46-
private Paint mPaint;
47-
private boolean mShouldRender;
48-
private boolean mShadowLayerSynced;
49-
50-
private int mFillColor;
51-
private RenderingStyle mRenderingStyle;
52-
private WritingDirection mWritingDirection;
53-
private Typeface mTypeface;
54-
private float mTypeSize;
55-
private float mSlantAngle;
56-
private float mScaleX;
57-
private float mScaleY;
58-
private int mStrokeColor;
45+
private Paint mPaint = new Paint();
46+
private boolean mShouldRender = false;
47+
private boolean mShadowLayerSynced = true;
48+
49+
private int mFillColor = Color.BLACK;
50+
private RenderingStyle mRenderingStyle = RenderingStyle.FILL;
51+
private WritingDirection mWritingDirection = WritingDirection.LEFT_TO_RIGHT;
52+
private Typeface mTypeface = null;
53+
private float mTypeSize = 16.0f;
54+
private float mSlantAngle = 0.0f;
55+
private float mScaleX = 1.0f;
56+
private float mScaleY = 1.0f;
57+
private int mStrokeColor = Color.BLACK;
5958
private float mStrokeWidth;
6059
private StrokeCap mStrokeCap;
6160
private StrokeJoin mStrokeJoin;
6261
private float mStrokeMiter;
63-
private float mShadowRadius;
64-
private float mShadowDx;
65-
private float mShadowDy;
66-
private int mShadowColor;
62+
private float mShadowRadius = 0.0f;
63+
private float mShadowDx = 0.0f;
64+
private float mShadowDy = 0.0f;
65+
private int mShadowColor = Color.TRANSPARENT;
6766

6867
/**
6968
* Constructs a renderer object.
7069
*/
7170
public Renderer() {
72-
mGlyphStrike = new GlyphStrike();
73-
mPaint = new Paint();
74-
mShadowRadius = 0.0f;
75-
mShadowDx = 0.0f;
76-
mShadowDy = 0.0f;
77-
mShadowColor = Color.TRANSPARENT;
78-
79-
setFillColor(Color.BLACK);
80-
setRenderingStyle(RenderingStyle.FILL);
81-
setWritingDirection(WritingDirection.LEFT_TO_RIGHT);
82-
setTypeSize(16.0f);
83-
setSlantAngle(0.0f);
84-
setScaleX(1.0f);
85-
setScaleY(1.0f);
86-
setStrokeColor(Color.BLACK);
71+
updatePixelSizes();
72+
updateTransform();
73+
8774
setStrokeWidth(1.0f);
8875
setStrokeCap(StrokeCap.BUTT);
8976
setStrokeJoin(StrokeJoin.ROUND);

0 commit comments

Comments
 (0)