Skip to content

Commit 0a760ef

Browse files
committed
change hint to DISABLE_OPTIMIZED_STROKE (issue #1302)
1 parent 3c29172 commit 0a760ef

8 files changed

Lines changed: 33 additions & 22 deletions

File tree

android/core/src/processing/core/PConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ public interface PConstants {
406406
static final int DISABLE_DEPTH_MASK = 5;
407407
static final int ENABLE_DEPTH_MASK = -5;
408408

409-
static final int ENABLE_ACCURATE_2D = 6;
410-
static final int DISABLE_ACCURATE_2D = -6;
409+
static final int DISABLE_OPTIMIZED_STROKE = 6;
410+
static final int ENABLE_OPTIMIZED_STROKE = -6;
411411

412412
static final int ENABLE_STROKE_PERSPECTIVE = 7;
413413
static final int DISABLE_STROKE_PERSPECTIVE = -7;

android/core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,10 +1946,10 @@ public void hint(int which) {
19461946
} else if (which == ENABLE_DEPTH_MASK) {
19471947
flush();
19481948
pgl.depthMask(true);
1949-
} else if (which == DISABLE_ACCURATE_2D) {
1949+
} else if (which == ENABLE_OPTIMIZED_STROKE) {
19501950
flush();
19511951
setFlushMode(FLUSH_WHEN_FULL);
1952-
} else if (which == ENABLE_ACCURATE_2D) {
1952+
} else if (which == DISABLE_OPTIMIZED_STROKE) {
19531953
flush();
19541954
setFlushMode(FLUSH_CONTINUOUSLY);
19551955
} else if (which == DISABLE_STROKE_PERSPECTIVE) {
@@ -5910,7 +5910,7 @@ protected void setDefaults() {
59105910
// use <= since that's what processing.core does
59115911
pgl.depthFunc(PGL.LEQUAL);
59125912

5913-
if (hints[ENABLE_ACCURATE_2D]) {
5913+
if (hints[DISABLE_OPTIMIZED_STROKE]) {
59145914
flushMode = FLUSH_CONTINUOUSLY;
59155915
} else {
59165916
flushMode = FLUSH_WHEN_FULL;
@@ -7029,7 +7029,7 @@ public void bind() {
70297029
setUniformValue(perspectiveLoc, 0);
70307030
}
70317031

7032-
if (pgCurrent.getHint(ENABLE_ACCURATE_2D)) {
7032+
if (pgCurrent.getHint(DISABLE_OPTIMIZED_STROKE)) {
70337033
setUniformValue(scaleLoc, 1.0f, 1.0f, 1.0f);
70347034
} else {
70357035
if (usingOrthoProjection) {

android/core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4225,7 +4225,7 @@ public void draw(PGraphics g) {
42254225
// Or accurate 2D mode is enabled, which forces each
42264226
// shape to be rendered separately.
42274227
protected boolean fragmentedGroup(PGraphicsOpenGL g) {
4228-
return g.getHint(ENABLE_ACCURATE_2D) ||
4228+
return g.getHint(DISABLE_OPTIMIZED_STROKE) ||
42294229
(textures != null && 1 < textures.size()) ||
42304230
strokedTexture;
42314231
}

build/shared/revisions.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ PROCESSING 2.0b7 (REV 0215) - 25 November 2012
2727
If we're missing anything that's not covered in the reference, please
2828
let us know via the bugs database.
2929

30+
+ hint(ENABLE_ACCURATE_2D) has been renamed to hint(DISABLE_OPTIMIZED_STROKE)
31+
to better reflect what it actually does. Reference has been added.
32+
OpenGL drawing is significantly faster when the fill and stroke of a shape
33+
is drawn separately. This leads to visual artifacts on shapes where both
34+
fill and stroke is enabled (not a great idea in 3D anyway), so this option
35+
fixes the visual artifacts at the expense of speed.
36+
http://code.google.com/p/processing/issues/detail?id=1302
37+
3038
+ Sketch names can no longer begin with underscores (fixes an Android
3139
compatibility issue). This was changed in recent releases, but missing here.
3240
http://code.google.com/p/processing/issues/detail?id=859

core/src/processing/core/PConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ public interface PConstants {
453453
static final int DISABLE_DEPTH_MASK = 5;
454454
static final int ENABLE_DEPTH_MASK = -5;
455455

456-
static final int ENABLE_ACCURATE_2D = 6;
457-
static final int DISABLE_ACCURATE_2D = -6;
456+
static final int DISABLE_OPTIMIZED_STROKE = 6;
457+
static final int ENABLE_OPTIMIZED_STROKE = -6;
458458

459459
static final int ENABLE_STROKE_PERSPECTIVE = 7;
460460
static final int DISABLE_STROKE_PERSPECTIVE = -7;

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,10 +1946,10 @@ public void hint(int which) {
19461946
} else if (which == ENABLE_DEPTH_MASK) {
19471947
flush();
19481948
pgl.depthMask(true);
1949-
} else if (which == DISABLE_ACCURATE_2D) {
1949+
} else if (which == ENABLE_OPTIMIZED_STROKE) {
19501950
flush();
19511951
setFlushMode(FLUSH_WHEN_FULL);
1952-
} else if (which == ENABLE_ACCURATE_2D) {
1952+
} else if (which == DISABLE_OPTIMIZED_STROKE) {
19531953
flush();
19541954
setFlushMode(FLUSH_CONTINUOUSLY);
19551955
} else if (which == DISABLE_STROKE_PERSPECTIVE) {
@@ -5910,7 +5910,7 @@ protected void setDefaults() {
59105910
// use <= since that's what processing.core does
59115911
pgl.depthFunc(PGL.LEQUAL);
59125912

5913-
if (hints[ENABLE_ACCURATE_2D]) {
5913+
if (hints[DISABLE_OPTIMIZED_STROKE]) {
59145914
flushMode = FLUSH_CONTINUOUSLY;
59155915
} else {
59165916
flushMode = FLUSH_WHEN_FULL;
@@ -7029,7 +7029,7 @@ public void bind() {
70297029
setUniformValue(perspectiveLoc, 0);
70307030
}
70317031

7032-
if (pgCurrent.getHint(ENABLE_ACCURATE_2D)) {
7032+
if (pgCurrent.getHint(DISABLE_OPTIMIZED_STROKE)) {
70337033
setUniformValue(scaleLoc, 1.0f, 1.0f, 1.0f);
70347034
} else {
70357035
if (usingOrthoProjection) {

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4225,7 +4225,7 @@ public void draw(PGraphics g) {
42254225
// Or accurate 2D mode is enabled, which forces each
42264226
// shape to be rendered separately.
42274227
protected boolean fragmentedGroup(PGraphicsOpenGL g) {
4228-
return g.getHint(ENABLE_ACCURATE_2D) ||
4228+
return g.getHint(DISABLE_OPTIMIZED_STROKE) ||
42294229
(textures != null && 1 < textures.size()) ||
42304230
strokedTexture;
42314231
}

core/todo.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,18 @@ X also store the default composite instance and use that on blendMode(BLEND)
9191
X disable Quartz renderer to fix line blending problem from Casey
9292
X might make sketches run more slowly
9393
X fix double error report about textMode(SCREEN)
94+
X how to handle stroke/fill separation in OpenGL
95+
X hint(DISABLE_OPTIMIZED_STROKE)
96+
X http://code.google.com/p/processing/issues/detail?id=1302
97+
X change name for hint() that controls stroke/fill combo:
9498

9599
_ implement mousePressed(Event) etc
96100
_ better to do this instead of bringing back the magic event
101+
_ or implementing the magic event on Android
97102
_ add mouse wheel support to 2.0 event system
103+
_ this is fairly messy since desktop and JS behave a little differently
104+
_ wheel event should subclass mouse (since position still relevant)
105+
_ might be more effort than it's worth?
98106
_ http://code.google.com/p/processing/issues/detail?id=1423
99107

100108
andres (cleanup)
@@ -235,15 +243,12 @@ _ so that it could avoid quitting if the sketch hasn't been stopped
235243
_ or if the sketch window is foremost
236244
_ maybe a hack where a new menubar is added?
237245

238-
_ how to handle stroke/fill separation in OpenGL
239-
_ http://code.google.com/p/processing/issues/detail?id=1302
246+
_ shader syntax (Andres request)
247+
_ might also need a define inside the shader to control what type it is
240248

241249
_ createShape() not yet implemented for Java2D
242250
_ http://code.google.com/p/processing/issues/detail?id=1400
243251

244-
_ shader syntax (Andres request)
245-
_ might also need a define inside the shader to control what type it is
246-
247252
_ look into json and how it would work
248253
1) we bring back getFloatAttribute() et al., and make getFloat() be equivalent to parseFloat(xml.getContent())
249254
2) we keep getFloat() like it is, and add getFloatContent(), getIntContent() etc.
@@ -296,6 +301,7 @@ _ add "CGAffineTransformInvert: singular matrix" problem to the Wiki
296301
_ http://code.google.com/p/processing/issues/detail?id=1363
297302

298303
_ heading2D()? weird.. angle?
304+
_ http://toxiclibs.org/docs/core/toxi/geom/Vec3D.html
299305
_ http://code.google.com/p/processing/issues/detail?id=987
300306

301307
_ "translate, or this variation of it" when using text(s, x, y, z) accidentally
@@ -307,9 +313,6 @@ _ http://code.google.com/p/processing/issues/detail?id=1353
307313
_ Default Renderer slow on retina displays
308314
_ http://code.google.com/p/processing/issues/detail?id=1262
309315

310-
_ change name for hint() that controls stroke/fill combo
311-
_ hint(DISABLE_OPTIMIZED_STROKE)
312-
313316
_ hint(OPENGL_ERRORS) should be the opposite to enable the reporting, no?
314317

315318
_ fillMode(NONZERO) and fillMode(ODD) to replace sold(boolean)?

0 commit comments

Comments
 (0)