64 private RectBounds finalClipRect;
65 protected RectBounds nodeBounds = null;
66 private Rectangle clipRect;
67 private int clipRectIndex;
68 private boolean hasPreCullingBits = false;
69 private float extraAlpha = 1f;
70 private CompositeMode compMode;
71 private boolean antialiasedShape = true;
72 private boolean depthBuffer = false;
73 private boolean depthTest = false;
74 protected Paint paint = DEFAULT_PAINT;
75 protected BasicStroke stroke = DEFAULT_STROKE;
76
77 protected boolean isSimpleTranslate = true;
78 protected float transX;
79 protected float transY;
80
81 private final BaseContext context;
82 private final RenderTarget renderTarget;
83 private boolean state3D = false;
84 private float pixelScale = 1.0f;
85
86 protected BaseGraphics(BaseContext context, RenderTarget target) {
87 this.context = context;
88 this.renderTarget = target;
89 devClipRect = new RectBounds(0, 0,
90 target.getContentWidth(),
91 target.getContentHeight());
92 finalClipRect = new RectBounds(devClipRect);
93 compMode = CompositeMode.SRC_OVER;
94 if (context != null) {
95 // RT-27422
96 // TODO: Ideally we wouldn't need this step here and would
97 // instead call some method prior to making any OpenGL calls
98 // to ensure that there is a current context. We're getting
99 // closer to that ideal in that we call validate*Op() before
100 // every graphics operation (which in turn calls the
101 // setRenderTarget() method), but there are still some cases
102 // remaining where this doesn't happen (e.g. texture creation).
103 // So for the time being this blanket call to setRenderTarget()
104 // is better than nothing...
257
258 public boolean isDepthBuffer() {
259 return depthBuffer;
260 }
261
262 // If true use fragment shader that does alpha testing (i.e. discard if alpha == 0.0)
263 // Currently it is required when depth testing is in use.
264 public boolean isAlphaTestShader() {
265 return (PrismSettings.forceAlphaTestShader || (isDepthTest() && isDepthBuffer()));
266 }
267
268 public void setAntialiasedShape(boolean aa) {
269 antialiasedShape = aa;
270 }
271
272 public boolean isAntialiasedShape() {
273 return antialiasedShape;
274 }
275
276 @Override
277 public void setPixelScaleFactor(float pixelScale) {
278 this.pixelScale = pixelScale;
279 }
280
281 @Override
282 public float getPixelScaleFactor() {
283 return pixelScale;
284 }
285
286 public void setCamera(NGCamera camera) {
287 this.camera = camera;
288 }
289
290 public Rectangle getClipRect() {
291 return (clipRect != null) ? new Rectangle(clipRect) : null;
292 }
293
294 public Rectangle getClipRectNoClone() {
295 return clipRect;
296 }
297
298 public RectBounds getFinalClipNoClone() {
299 return finalClipRect;
300 }
301
302 public void setClipRect(Rectangle clipRect) {
303 this.finalClipRect.setBounds(devClipRect);
|
64 private RectBounds finalClipRect;
65 protected RectBounds nodeBounds = null;
66 private Rectangle clipRect;
67 private int clipRectIndex;
68 private boolean hasPreCullingBits = false;
69 private float extraAlpha = 1f;
70 private CompositeMode compMode;
71 private boolean antialiasedShape = true;
72 private boolean depthBuffer = false;
73 private boolean depthTest = false;
74 protected Paint paint = DEFAULT_PAINT;
75 protected BasicStroke stroke = DEFAULT_STROKE;
76
77 protected boolean isSimpleTranslate = true;
78 protected float transX;
79 protected float transY;
80
81 private final BaseContext context;
82 private final RenderTarget renderTarget;
83 private boolean state3D = false;
84 private float pixelScaleX = 1.0f;
85 private float pixelScaleY = 1.0f;
86
87 protected BaseGraphics(BaseContext context, RenderTarget target) {
88 this.context = context;
89 this.renderTarget = target;
90 devClipRect = new RectBounds(0, 0,
91 target.getContentWidth(),
92 target.getContentHeight());
93 finalClipRect = new RectBounds(devClipRect);
94 compMode = CompositeMode.SRC_OVER;
95 if (context != null) {
96 // RT-27422
97 // TODO: Ideally we wouldn't need this step here and would
98 // instead call some method prior to making any OpenGL calls
99 // to ensure that there is a current context. We're getting
100 // closer to that ideal in that we call validate*Op() before
101 // every graphics operation (which in turn calls the
102 // setRenderTarget() method), but there are still some cases
103 // remaining where this doesn't happen (e.g. texture creation).
104 // So for the time being this blanket call to setRenderTarget()
105 // is better than nothing...
258
259 public boolean isDepthBuffer() {
260 return depthBuffer;
261 }
262
263 // If true use fragment shader that does alpha testing (i.e. discard if alpha == 0.0)
264 // Currently it is required when depth testing is in use.
265 public boolean isAlphaTestShader() {
266 return (PrismSettings.forceAlphaTestShader || (isDepthTest() && isDepthBuffer()));
267 }
268
269 public void setAntialiasedShape(boolean aa) {
270 antialiasedShape = aa;
271 }
272
273 public boolean isAntialiasedShape() {
274 return antialiasedShape;
275 }
276
277 @Override
278 public void setPixelScaleFactors(float pixelScaleX, float pixelScaleY) {
279 this.pixelScaleX = pixelScaleX;
280 this.pixelScaleY = pixelScaleY;
281 }
282
283 @Override
284 public float getPixelScaleFactorX() {
285 return pixelScaleX;
286 }
287
288 @Override
289 public float getPixelScaleFactorY() {
290 return pixelScaleY;
291 }
292
293 public void setCamera(NGCamera camera) {
294 this.camera = camera;
295 }
296
297 public Rectangle getClipRect() {
298 return (clipRect != null) ? new Rectangle(clipRect) : null;
299 }
300
301 public Rectangle getClipRectNoClone() {
302 return clipRect;
303 }
304
305 public RectBounds getFinalClipNoClone() {
306 return finalClipRect;
307 }
308
309 public void setClipRect(Rectangle clipRect) {
310 this.finalClipRect.setBounds(devClipRect);
|