Skip to content

Commit a65fb11

Browse files
Alex SakhartchoukAndroid (Google) Code Review
authored andcommitted
Merge "Removing GL calls from librs"
2 parents e7b57be + 20c9c92 commit a65fb11

File tree

5 files changed

+50
-23
lines changed

5 files changed

+50
-23
lines changed

libs/rs/driver/rsdGL.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,37 @@ void rsdGLCheckError(const android::renderscript::Context *rsc,
478478
}
479479

480480
}
481+
482+
void rsdGLClearColor(const android::renderscript::Context *rsc,
483+
float r, float g, float b, float a) {
484+
RSD_CALL_GL(glClearColor, r, g, b, a);
485+
RSD_CALL_GL(glClear, GL_COLOR_BUFFER_BIT);
486+
}
487+
488+
void rsdGLClearDepth(const android::renderscript::Context *rsc, float v) {
489+
RSD_CALL_GL(glClearDepthf, v);
490+
RSD_CALL_GL(glClear, GL_DEPTH_BUFFER_BIT);
491+
}
492+
493+
void rsdGLFinish(const android::renderscript::Context *rsc) {
494+
RSD_CALL_GL(glFinish);
495+
}
496+
497+
void rsdGLDrawQuadTexCoords(const android::renderscript::Context *rsc,
498+
float x1, float y1, float z1, float u1, float v1,
499+
float x2, float y2, float z2, float u2, float v2,
500+
float x3, float y3, float z3, float u3, float v3,
501+
float x4, float y4, float z4, float u4, float v4) {
502+
503+
float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
504+
const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
505+
506+
RsdVertexArray::Attrib attribs[2];
507+
attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
508+
attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
509+
510+
RsdVertexArray va(attribs, 2);
511+
va.setup(rsc);
512+
513+
RSD_CALL_GL(glDrawArrays, GL_TRIANGLE_FAN, 0, 4);
514+
}

libs/rs/driver/rsdGL.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ void rsdGLCheckError(const android::renderscript::Context *rsc,
8484
const char *msg, bool isFatal = false);
8585
void rsdGLSetPriority(const android::renderscript::Context *rsc,
8686
int32_t priority);
87+
void rsdGLClearColor(const android::renderscript::Context *rsc,
88+
float r, float g, float b, float a);
89+
void rsdGLClearDepth(const android::renderscript::Context *rsc, float v);
90+
void rsdGLFinish(const android::renderscript::Context *rsc);
91+
void rsdGLDrawQuadTexCoords(const android::renderscript::Context *rsc,
92+
float x1, float y1, float z1, float u1, float v1,
93+
float x2, float y2, float z2, float u2, float v2,
94+
float x3, float y3, float z3, float u3, float v3,
95+
float x4, float y4, float z4, float u4, float v4);
8796

8897
#endif
8998

libs/rs/driver/rsdRuntimeStubs.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,19 @@ static void SC_Color(float r, float g, float b, float a) {
257257

258258
static void SC_Finish() {
259259
GET_TLS();
260-
rsrFinish(rsc, sc);
260+
rsdGLFinish(rsc);
261261
}
262262

263263
static void SC_ClearColor(float r, float g, float b, float a) {
264264
GET_TLS();
265-
rsrClearColor(rsc, sc, r, g, b, a);
265+
rsrPrepareClear(rsc, sc);
266+
rsdGLClearColor(rsc, r, g, b, a);
266267
}
267268

268269
static void SC_ClearDepth(float v) {
269270
GET_TLS();
270-
rsrClearDepth(rsc, sc, v);
271+
rsrPrepareClear(rsc, sc);
272+
rsdGLClearDepth(rsc, v);
271273
}
272274

273275
static uint32_t SC_GetWidth() {

libs/rs/rsRuntime.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ void rsrMeshComputeBoundingBox(Context *, Script *, Mesh *,
8686

8787

8888
void rsrColor(Context *, Script *, float r, float g, float b, float a);
89-
void rsrFinish(Context *, Script *);
9089
void rsrAllocationSyncAll(Context *, Script *, Allocation *);
9190

9291
void rsrAllocationCopy1DRange(Context *, Allocation *dstAlloc,
@@ -103,8 +102,7 @@ void rsrAllocationCopy2DRange(Context *, Allocation *dstAlloc,
103102
uint32_t srcXoff, uint32_t srcYoff,
104103
uint32_t srcMip, uint32_t srcFace);
105104

106-
void rsrClearColor(Context *, Script *, float r, float g, float b, float a);
107-
void rsrClearDepth(Context *, Script *, float v);
105+
void rsrPrepareClear(Context *, Script *);
108106
uint32_t rsrGetWidth(Context *, Script *);
109107
uint32_t rsrGetHeight(Context *, Script *);
110108
void rsrDrawTextAlloc(Context *, Script *, Allocation *, int x, int y);

libs/rs/rsScriptC_LibGL.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -269,25 +269,9 @@ void rsrColor(Context *rsc, Script *sc, float r, float g, float b, float a) {
269269
pf->setConstantColor(rsc, r, g, b, a);
270270
}
271271

272-
void rsrFinish(Context *rsc, Script *sc) {
273-
RSD_CALL_GL(glFinish);
274-
}
275-
276-
277-
void rsrClearColor(Context *rsc, Script *sc, float r, float g, float b, float a) {
272+
void rsrPrepareClear(Context *rsc, Script *sc) {
278273
rsc->mFBOCache.setup(rsc);
279274
rsc->setupProgramStore();
280-
281-
RSD_CALL_GL(glClearColor, r, g, b, a);
282-
RSD_CALL_GL(glClear, GL_COLOR_BUFFER_BIT);
283-
}
284-
285-
void rsrClearDepth(Context *rsc, Script *sc, float v) {
286-
rsc->mFBOCache.setup(rsc);
287-
rsc->setupProgramStore();
288-
289-
RSD_CALL_GL(glClearDepthf, v);
290-
RSD_CALL_GL(glClear, GL_DEPTH_BUFFER_BIT);
291275
}
292276

293277
uint32_t rsrGetWidth(Context *rsc, Script *sc) {

0 commit comments

Comments
 (0)