--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/groups/opt_out.
--
FramebufferNativeWindow *pWindow = getFBAsWindow();
if (NULL == pWindow)
return -1;
// initialize opengl and egl
const EGLint attribs[] =
{ EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_DEPTH_SIZE, 0,
EGL_NONE };
EGLint w, h, dummy;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
EGLContext context;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, 0, 0);
eglChooseConfig(display, attribs, &config, 1, &numConfigs);
surface = eglCreateWindowSurface(display, config, pWindow, NULL);
context = eglCreateContext(display, config, NULL, NULL);
eglQuerySurface(display, surface, EGL_WIDTH, &w);
eglQuerySurface(display, surface, EGL_HEIGHT, &h);
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
return NO_INIT;
mDisplay = display;
mContext = context;
mSurface = surface;
mWidth = w;
mHeight = h;
//mFlingerSurfaceControl = control;
mFlingerSurface = pWindow;
mAndroidAnimation = true;
SkCanvas *getGLBackedCanvas(GrContext **context)
{
SkCanvas *result = NULL;
GrContext *skiaContext = GrContext::CreateGLShaderContext();
GrRenderTarget* renderTarget = skiaContext->createRenderTargetFrom3DApiState();
result = new SkGpuCanvas(skiaContext, renderTarget);
if (NULL != context)
*context = skiaContext;
return result;
}
GrContext *context = NULL;
// Paint screen with green color
//glShadeModel (GL_FLAT);
glDisable (GL_DITHER);
glDisable (GL_SCISSOR_TEST);
glClearColor(0, 1, 0, 1);
glClear (GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);
SkGraphics::Init();
SkCanvas *canvas = getGLBackedCanvas(&context);
if (NULL == canvas || NULL == context)
{
LOGD("Unable to create canvas/context");
return false;
}
SkPaint textAttribs;
textAttribs.setColor(0xFF0000FF);
textAttribs.setTextSize(SkIntToScalar(24));
const nsecs_t startTime = systemTime();
int frame_count = 0;
do
{
nsecs_t now = systemTime();
double time = now - startTime;
glEnable (GL_BLEND);
canvas->drawColor(0xFF0000FF);
canvas->drawText("Hello world", strlen("Hello world"), 400, 400,
textAttribs);
canvas->drawRectCoords(300, 600, 500, 800, textAttribs);
context->flush();
EGLBoolean res = eglSwapBuffers(mDisplay, mSurface);
if (res == EGL_FALSE)
break;
frame_count++;
if (0 == (frame_count % 150))
LOGD("GLTest: Completed %d frames", frame_count);
// 12fps: don't animate too fast to preserve CPU
const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now);
if (sleepTime > 0)
usleep(sleepTime);
break;
} while (!exitPending());
Brian
I am able to create GPU based canvas and draw on it. But it is not showing up on the screen.
Below is how I am creating canvas.SkCanvas *getGLBackedCanvas(GrContext **context)
{
SkCanvas *result = NULL;
GrContext *skiaContext = GrContext::CreateGLShaderContext();
GrRenderTarget* renderTarget = skiaContext->createRenderTargetFrom3DApiState();
result = new SkGpuCanvas(skiaContext, renderTarget);
if (NULL != context)
*context = skiaContext;
return result;
}
My drawing code is belowGrContext *context = NULL;
// Paint screen with green color
//glShadeModel (GL_FLAT);
glDisable (GL_DITHER);
glDisable (GL_SCISSOR_TEST);
glClearColor(0, 1, 0, 1);
glClear (GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);
SkGraphics::Init();
SkCanvas *canvas = getGLBackedCanvas(&context);
if (NULL == canvas || NULL == context)
{
LOGD("Unable to create canvas/context");
return false;
}
SkPaint textAttribs;
textAttribs.setColor(0xFF0000FF);
textAttribs.setTextSize(SkIntToScalar(24));
const nsecs_t startTime = systemTime();
int frame_count = 0;
do
{
nsecs_t now = systemTime();
double time = now - startTime;
glEnable (GL_BLEND);
canvas->drawColor(0xFF0000FF);
canvas->drawText("Hello world", strlen("Hello world"), 400, 400,
textAttribs);
canvas->drawRectCoords(300, 600, 500, 800, textAttribs);
context->flush();
EGLBoolean res = eglSwapBuffers(mDisplay, mSurface);
if (res == EGL_FALSE)
break;
frame_count++;
if (0 == (frame_count % 150))
LOGD("GLTest: Completed %d frames", frame_count);
// 12fps: don't animate too fast to preserve CPU
const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now);
if (sleepTime > 0)
usleep(sleepTime);
break;
} while (!exitPending());
I see the following in the logs repeated when I run this program.
ERROR logcat: hd[0]: libEGL(1508): called unimplemented OpenGL ES API
I appreciate if you can provide some pointers.
Thanks
Some comments and questions inline.On Thu, Jan 23, 2014 at 6:35 PM, Joe Droider <droid...@gmail.com> wrote:
Brian
I am able to create GPU based canvas and draw on it. But it is not showing up on the screen.
Below is how I am creating canvas.SkCanvas *getGLBackedCanvas(GrContext **context)
{
SkCanvas *result = NULL;
GrContext *skiaContext = GrContext::CreateGLShaderContext();GrRenderTarget* renderTarget = skiaContext->createRenderTargetFrom3DApiState();
Just FYI: In more recent versions of Skia the createRenderTargetFrom3DApiState() function has been removed. Instead we require to caller to give us the FBO ID and additional information.
result = new SkGpuCanvas(skiaContext, renderTarget);
if (NULL != context)
*context = skiaContext;
return result;
}
My drawing code is belowGrContext *context = NULL;
// Paint screen with green color
//glShadeModel (GL_FLAT);
glDisable (GL_DITHER);
glDisable (GL_SCISSOR_TEST);
glClearColor(0, 1, 0, 1);
glClear (GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);This makes it to the screen?
SkGraphics::Init();
SkCanvas *canvas = getGLBackedCanvas(&context);
if (NULL == canvas || NULL == context)
{
LOGD("Unable to create canvas/context");
return false;
}
SkPaint textAttribs;
textAttribs.setColor(0xFF0000FF);
textAttribs.setTextSize(SkIntToScalar(24));
const nsecs_t startTime = systemTime();
int frame_count = 0;
do
{
nsecs_t now = systemTime();
double time = now - startTime;
glEnable (GL_BLEND);I doubt this is the problem but Skia doesn't expect you to change the GL state. If you do change it you should call skiaContext->resetContext(). This lets the GrContext know that it should make no assumptions about the current GL state.
I am going to try it next.
canvas->drawColor(0xFF0000FF);
canvas->drawText("Hello world", strlen("Hello world"), 400, 400,
textAttribs);
canvas->drawRectCoords(300, 600, 500, 800, textAttribs);
context->flush();
EGLBoolean res = eglSwapBuffers(mDisplay, mSurface);What does the screen look like at this point?
if (res == EGL_FALSE)
break;
frame_count++;
if (0 == (frame_count % 150))
LOGD("GLTest: Completed %d frames", frame_count);
// 12fps: don't animate too fast to preserve CPU
const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now);
if (sleepTime > 0)
usleep(sleepTime);
break;
} while (!exitPending());
I see the following in the logs repeated when I run this program.
ERROR logcat: hd[0]: libEGL(1508): called unimplemented OpenGL ES API
Interesting. In a debug build of Skia do you see any additional logging. When built in debug mode Skia should call glGetError() after every GL call it makes and print if an error is found.
I didn't see any gl errors in the logas after the above line. Android build system has different way of configuring debug build options. Let me fiddle with that.
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.