Skip to content

Commit 602cec3

Browse files
committed
added getEngine() to AppComponent
1 parent ad004ee commit 602cec3

File tree

10 files changed

+26
-22
lines changed

10 files changed

+26
-22
lines changed

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ public void breakShape() {
473473
@Override
474474
public void endShape(int mode) {
475475
if (shape == POINTS && stroke && vertexCount > 0) {
476-
// Matrix m = canvas.getMatrix();
477476
Matrix m = getMatrixImp();
478477
if (strokeWeight == 1 && m.isIdentity()) {
479478
if (screenPoint == null) {
@@ -519,15 +518,13 @@ public void endShape(int mode) {
519518

520519
@Override
521520
protected void clipImpl(float x1, float y1, float x2, float y2) {
522-
// canvas.save(Canvas.CLIP_SAVE_FLAG);
523521
canvas.clipRect(x1, y1, x2, y2);
524522
}
525523

526524

527525
@Override
528526
public void noClip() {
529527
canvas.clipRect(0, 0, width, height, Region.Op.REPLACE);
530-
// canvas.restore();
531528
}
532529

533530

core/src/processing/android/AppComponent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ abstract public interface AppComponent extends PConstants {
3838
public int getKind();
3939
public void setSketch(PApplet sketch);
4040
public PApplet getSketch();
41+
public ServiceEngine getEngine();
4142

4243
public void startActivity(Intent intent);
4344

core/src/processing/android/PFragment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ public PApplet getSketch() {
117117
return sketch;
118118
}
119119

120+
public ServiceEngine getEngine() {
121+
return null;
122+
}
123+
120124
public void dispose() {
121125
}
122126

core/src/processing/android/PWallpaper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public PApplet getSketch() {
9999
}
100100

101101

102-
public Engine getEngine() {
102+
public ServiceEngine getEngine() {
103103
return engine;
104104
}
105105

core/src/processing/android/PWatchFaceCanvas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public PApplet getSketch() {
110110
}
111111

112112

113-
public Engine getEngine() {
113+
public ServiceEngine getEngine() {
114114
return engine;
115115
}
116116

core/src/processing/android/PWatchFaceGLES.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public PApplet getSketch() {
108108
}
109109

110110

111-
public Engine getEngine() {
111+
public ServiceEngine getEngine() {
112112
return engine;
113113
}
114114

core/src/processing/core/PApplet.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import android.net.Uri;
4242
import android.os.Build;
4343
import android.os.Bundle;
44-
import android.service.wallpaper.WallpaperService;
4544
import android.support.annotation.LayoutRes;
4645
import android.support.v4.content.ContextCompat;
4746
import android.view.LayoutInflater;
@@ -52,6 +51,7 @@
5251
import android.view.inputmethod.InputMethodManager;
5352
import processing.a2d.PGraphicsAndroid2D;
5453
import processing.android.AppComponent;
54+
import processing.android.ServiceEngine;
5555
import processing.data.*;
5656
import processing.event.*;
5757
import processing.opengl.*;
@@ -61,7 +61,7 @@ public class PApplet extends Object implements PConstants {
6161
/**
6262
* The surface this sketch draws to.
6363
*/
64-
public PSurface surface;
64+
protected PSurface surface;
6565

6666
/**
6767
* The view group containing the surface view of the PApplet.
@@ -453,12 +453,17 @@ public PSurface getSurface() {
453453
}
454454

455455

456+
public Context getContext() {
457+
return surface.getContext();
458+
}
459+
460+
456461
public Activity getActivity() {
457462
return surface.getActivity();
458463
}
459464

460465

461-
public WallpaperService.Engine getEngine() {
466+
public ServiceEngine getEngine() {
462467
return surface.getEngine();
463468
}
464469

core/src/processing/core/PSurface.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import android.view.SurfaceView;
3737
import android.view.View;
3838
import android.view.ViewGroup;
39-
import android.service.wallpaper.WallpaperService.Engine;
4039
import processing.android.AppComponent;
40+
import processing.android.ServiceEngine;
4141

4242
/*
4343
* Holds the surface view associated with the sketch, and the rendering thread
@@ -47,7 +47,7 @@ public interface PSurface {
4747
public AppComponent getComponent();
4848
public Context getContext();
4949
public Activity getActivity();
50-
public Engine getEngine();
50+
public ServiceEngine getEngine();
5151

5252
public void dispose();
5353

core/src/processing/core/PSurfaceNone.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import processing.android.PWallpaper;
5050
import processing.android.PWatchFaceCanvas;
5151
import processing.android.PWatchFaceGLES;
52+
import processing.android.ServiceEngine;
5253

5354
/**
5455
* Base surface for Android2D and OpenGL renderers. It includes the standard rendering loop.
@@ -99,17 +100,8 @@ public Activity getActivity() {
99100

100101

101102
@Override
102-
public Engine getEngine() {
103-
if (component.getKind() == AppComponent.WALLPAPER) {
104-
return ((PWallpaper)component).getEngine();
105-
} else if (component.getKind() == AppComponent.WATCHFACE) {
106-
if (component instanceof PWatchFaceCanvas) {
107-
return ((PWatchFaceCanvas)component).getEngine();
108-
} else if (component instanceof PWatchFaceGLES) {
109-
return ((PWatchFaceGLES)component).getEngine();
110-
}
111-
}
112-
return null;
103+
public ServiceEngine getEngine() {
104+
return component.getEngine();
113105
}
114106

115107

libraries/cardboard/src/processing/cardboard/PCardboard.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import android.util.DisplayMetrics;
2929
import processing.android.AppComponent;
30+
import processing.android.ServiceEngine;
3031
import processing.core.PApplet;
3132

3233
// http://pastebin.com/6wPgFYhq
@@ -86,6 +87,10 @@ public PApplet getSketch() {
8687
return sketch;
8788
}
8889

90+
public ServiceEngine getEngine() {
91+
return null;
92+
}
93+
8994
public void init(PApplet sketch) {
9095
setSketch(sketch);
9196
if (sketch != null) {

0 commit comments

Comments
 (0)