Get rid of createRenderTargetFrom3DAPIState and associated glGets necessary to support it.

Review URL: http://codereview.appspot.com/4928041/



git-svn-id: http://skia.googlecode.com/svn/trunk@2144 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2011-08-19 17:22:05 +00:00
parent 3008519e9f
commit 971d0c8049
18 changed files with 103 additions and 302 deletions

View File

@ -5,19 +5,23 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchTimer.h"
#include "GrContext.h"
#include "GrRenderTarget.h"
#include "SkBenchmark.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkEGLContext.h"
#include "SkGpuDevice.h"
#include "SkGraphics.h"
#include "SkImageEncoder.h"
#include "SkNWayCanvas.h"
#include "SkPicture.h"
#include "SkString.h"
#include "GrContext.h"
#include "SkGpuDevice.h"
#include "SkEGLContext.h"
#include "SkBenchmark.h"
#include "BenchTimer.h"
#ifdef ANDROID
static void log_error(const char msg[]) { SkDebugf("%s", msg); }
@ -169,7 +173,8 @@ enum Backend {
};
static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
Backend backend, GrContext* context) {
Backend backend, GrContext* context,
GrRenderTarget* rt) {
SkDevice* device = NULL;
SkBitmap bitmap;
bitmap.setConfig(config, size.fX, size.fY);
@ -181,7 +186,7 @@ static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
device = new SkDevice(bitmap);
break;
case kGPU_Backend:
device = new SkGpuDevice(context, SkGpuDevice::Current3DApiRenderTarget());
device = new SkGpuDevice(context, rt);
// device->clear(0xFFFFFFFF);
break;
case kPDF_Backend:
@ -408,11 +413,27 @@ int main (int argc, char * const argv[]) {
}
GrContext* context = NULL;
GrRenderTarget* rt = NULL;
//Don't do GL when fixed.
#if !defined(SK_SCALAR_IS_FIXED)
SkEGLContext eglContext;
if (eglContext.init(1024, 1024)) {
context = GrContext::CreateGLShaderContext();
if (NULL != context) {
GrPlatformSurfaceDesc desc;
desc.reset();
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fWidth = 1024;
desc.fHeight = 1024;
desc.fStencilBits = 8;
desc.fPlatformRenderTarget = eglContext.getFBOID();
desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
rt = static_cast<GrRenderTarget*>(context->createPlatformSurface(desc));
if (NULL == rt) {
context->unref();
context = NULL;
}
}
}
#endif
@ -457,7 +478,8 @@ int main (int argc, char * const argv[]) {
continue;
}
SkDevice* device = make_device(outConfig, dim, backend, context);
SkDevice* device = make_device(outConfig, dim,
backend, context, rt);
SkCanvas canvas(device);
device->unref();
@ -516,6 +538,9 @@ int main (int argc, char * const argv[]) {
}
log_progress("\n");
}
SkSafeUnref(context);
SkSafeUnref(rt);
return 0;
}

View File

@ -6,8 +6,16 @@
* found in the LICENSE file.
*/
#include "gm.h"
#include "GrContext.h"
#include "GrRenderTarget.h"
#include "SkColorPriv.h"
#include "SkData.h"
#include "SkDevice.h"
#include "SkEGLContext.h"
#include "SkGpuCanvas.h"
#include "SkGpuDevice.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
@ -15,12 +23,6 @@
#include "SkStream.h"
#include "SkRefCnt.h"
#include "GrContext.h"
#include "SkGpuCanvas.h"
#include "SkGpuDevice.h"
#include "SkEGLContext.h"
#include "SkDevice.h"
#ifdef SK_SUPPORT_PDF
#include "SkPDFDevice.h"
#include "SkPDFDocument.h"
@ -228,6 +230,7 @@ static void setup_bitmap(const ConfigData& gRec, SkISize& size,
// halt.
static bool generate_image(GM* gm, const ConfigData& gRec,
GrContext* context,
GrRenderTarget* rt,
SkBitmap* bitmap) {
SkISize size (gm->getISize());
setup_bitmap(gRec, size, bitmap);
@ -239,8 +242,6 @@ static bool generate_image(GM* gm, const ConfigData& gRec,
if (NULL == context) {
return false;
}
// not a real object, so don't unref it
GrRenderTarget* rt = SkGpuDevice::Current3DApiRenderTarget();
SkGpuCanvas gc(context, rt);
gc.setDevice(new SkGpuDevice(context, rt))->unref();
gm->draw(&gc);
@ -406,14 +407,15 @@ static bool test_drawing(GM* gm,
const char readPath [],
const char diffPath [],
GrContext* context,
GrRenderTarget* rt,
SkBitmap* bitmap) {
SkDynamicMemoryWStream pdf;
if (gRec.fBackend == kRaster_Backend ||
gRec.fBackend == kGPU_Backend) {
gRec.fBackend == kGPU_Backend) {
// Early exit if we can't generate the image, but this is
// expected in some cases, so don't report a test failure.
if (!generate_image(gm, gRec, context, bitmap)) {
if (!generate_image(gm, gRec, context, rt, bitmap)) {
return true;
}
} else if (gRec.fBackend == kPDF_Backend) {
@ -555,11 +557,26 @@ int main(int argc, char * const argv[]) {
}
// setup a GL context for drawing offscreen
SkEGLContext eglContext;
GrRenderTarget* rt = NULL;
if (eglContext.init(maxW, maxH)) {
gGrContext = GrContext::CreateGLShaderContext();
if (NULL != gGrContext) {
GrPlatformSurfaceDesc desc;
desc.reset();
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fWidth = maxW;
desc.fHeight = maxH;
desc.fStencilBits = 8;
desc.fPlatformRenderTarget = eglContext.getFBOID();
desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
rt = static_cast<GrRenderTarget*>(gGrContext->createPlatformSurface(desc));
if (NULL == rt) {
gGrContext->unref();
gGrContext = NULL;
}
}
}
if (readPath) {
fprintf(stderr, "reading from %s\n", readPath);
} else if (writePath) {
@ -585,7 +602,7 @@ int main(int argc, char * const argv[]) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
bool testSuccess = test_drawing(gm, gRec[i],
writePath, readPath, diffPath, gGrContext,
&forwardRenderedBitmap);
rt, &forwardRenderedBitmap);
overallSuccess &= testSuccess;
if (doReplay && testSuccess) {

View File

@ -251,20 +251,6 @@ public:
*/
GrResource* createPlatformSurface(const GrPlatformSurfaceDesc& desc);
/**
* Reads the current target object (e.g. FBO or IDirect3DSurface9*) and
* viewport state from the underlying 3D API and wraps it in a
* GrRenderTarget. The GrRenderTarget will not attempt to delete/destroy the
* underlying object in its destructor and it is up to caller to guarantee
* that it remains valid while the GrRenderTarget is used.
*
* Will not detect that the render target is also a texture. If you need
* to also use the render target as a GrTexture use createPlatformSurface.
*
* @return the newly created GrRenderTarget
*/
GrRenderTarget* createRenderTargetFrom3DApiState();
///////////////////////////////////////////////////////////////////////////
// Matrix state

View File

@ -62,7 +62,7 @@ public:
* if client asked us to render to a target that has a pixel
* config that isn't equivalent with one of our configs.
*/
int config() const { return fConfig; }
GrPixelConfig config() const { return fConfig; }
/**
* @return the texture associated with the rendertarget, may be NULL.

View File

@ -548,10 +548,6 @@ GrResource* GrContext::createPlatformSurface(const GrPlatformSurfaceDesc& desc)
return fGpu->createPlatformSurface(desc);
}
GrRenderTarget* GrContext::createRenderTargetFrom3DApiState() {
return fGpu->createRenderTargetFrom3DApiState();
}
///////////////////////////////////////////////////////////////////////////////
bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler,

View File

@ -196,11 +196,6 @@ bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
}
}
GrRenderTarget* GrGpu::createRenderTargetFrom3DApiState() {
this->handleDirtyContext();
return this->onCreateRenderTargetFrom3DApiState();
}
GrResource* GrGpu::createPlatformSurface(const GrPlatformSurfaceDesc& desc) {
this->handleDirtyContext();
return this->onCreatePlatformSurface(desc);

View File

@ -122,17 +122,6 @@ public:
GrResource* createPlatformSurface(const GrPlatformSurfaceDesc& desc);
/**
* Reads the current target object (e.g. FBO or IDirect3DSurface9*) and
* viewport state from the underlying 3D API and wraps it in a
* GrRenderTarget. The GrRenderTarget will not attempt to delete/destroy the
* underlying object in its destructor and it is up to caller to guarantee
* that it remains valid while the GrRenderTarget is used.
*
* @return the newly created GrRenderTarget
*/
GrRenderTarget* createRenderTargetFrom3DApiState();
/**
* Creates a vertex buffer.
*
@ -427,7 +416,6 @@ protected:
const void* srcData,
size_t rowBytes) = 0;
virtual GrResource* onCreatePlatformSurface(const GrPlatformSurfaceDesc& desc) = 0;
virtual GrRenderTarget* onCreateRenderTargetFrom3DApiState() = 0;
virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size,
bool dynamic) = 0;
virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size,

View File

@ -154,11 +154,6 @@ static bool gPrintStartupSpew;
static bool fbo_test(const GrGLInterface* gl, int w, int h) {
GrGLint savedFBO;
GrGLint savedTexUnit;
GR_GL_GetIntegerv(gl, GR_GL_ACTIVE_TEXTURE, &savedTexUnit);
GR_GL_GetIntegerv(gl, GR_GL_FRAMEBUFFER_BINDING, &savedFBO);
GR_GL_CALL(gl, ActiveTexture(GR_GL_TEXTURE0 + SPARE_TEX_UNIT));
GrGLuint testFBO;
@ -182,9 +177,6 @@ static bool fbo_test(const GrGLInterface* gl, int w, int h) {
GR_GL_CALL(gl, DeleteFramebuffers(1, &testFBO));
GR_GL_CALL(gl, DeleteTextures(1, &testRTTex));
GR_GL_CALL(gl, ActiveTexture(savedTexUnit));
GR_GL_CALL(gl, BindFramebuffer(GR_GL_FRAMEBUFFER, savedFBO));
return status == GR_GL_FRAMEBUFFER_COMPLETE;
}
@ -710,193 +702,8 @@ GrResource* GrGpuGL::onCreatePlatformSurface(const GrPlatformSurfaceDesc& desc)
}
}
namespace {
static const GrGLenum kUnknownGLFormat = ~0;
GrGLenum get_fbo_color_format(const GrGLInterface* gl) {
GrGLint cbType;
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
&cbType);
GrGLint cbID;
GrGLint cbFormat;
switch (cbType) {
case GR_GL_RENDERBUFFER:
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
&cbID);
GR_GL_CALL(gl, BindRenderbuffer(GR_GL_RENDERBUFFER, cbID));
GR_GL_GetRenderbufferParameteriv(gl, GR_GL_RENDERBUFFER,
GR_GL_RENDERBUFFER_INTERNAL_FORMAT,
&cbFormat);
return cbFormat;
break;
case GR_GL_TEXTURE:
// ES doesn't have glGetTexLevelParameter
if (gl->supportsDesktop()) {
GrGLint cbLevel;
GrGLint cbFace;
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
&cbID);
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
&cbLevel);
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
&cbFace);
GrGLenum bind;
GrGLenum target;
if (cbFace) {
bind = GR_GL_TEXTURE_CUBE_MAP;
target = cbFace;
} else {
bind = GR_GL_TEXTURE_2D;
target = GR_GL_TEXTURE_2D;
}
GR_GL_CALL(gl, BindTexture(bind, cbID));
GR_GL_GetTexLevelParameteriv(gl, target, cbLevel,
GR_GL_TEXTURE_INTERNAL_FORMAT, &cbFormat);
return cbFormat;
} else {
return kUnknownGLFormat;
}
break;
default:
// we can get here with FBO 0, not a render buffer or a texture
return kUnknownGLFormat;
}
}
GrPixelConfig internal_color_format_to_config(GrGLenum iFormat) {
switch (iFormat) {
case GR_GL_RGB565:
return kRGB_565_GrPixelConfig;
case GR_GL_RGBA4:
return kRGBA_4444_GrPixelConfig;
case GR_GL_RGBA8:
case GR_GL_SRGB8_ALPHA8:
case GR_GL_SRGB_ALPHA:
case GR_GL_RGBA:
case GR_GL_BGRA:
return kRGBA_8888_GrPixelConfig;
case GR_GL_RGB8:
case GR_GL_SRGB8:
case GR_GL_SRGB:
return kRGBX_8888_GrPixelConfig;
default:
// there are many GL formats we don't have enums
// for. We should still render to them if the client
// asks us.
return kUnknown_GrPixelConfig;
}
}
GrPixelConfig get_implied_color_config(const GrGLInterface* gl,
bool arbFBOExtension) {
GrGLint rSize, bSize, gSize, aSize;
if (arbFBOExtension) {
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &rSize);
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, &gSize);
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, &bSize);
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &aSize);
} else {
GR_GL_GetIntegerv(gl, GR_GL_RED_BITS, &rSize);
GR_GL_GetIntegerv(gl, GR_GL_GREEN_BITS, &gSize);
GR_GL_GetIntegerv(gl, GR_GL_BLUE_BITS, &bSize);
GR_GL_GetIntegerv(gl, GR_GL_ALPHA_BITS, &aSize);
}
if(8 == rSize && 8 == gSize && 8 == bSize) {
if (0 == aSize) {
return kRGBX_8888_GrPixelConfig;
} else if (8 == aSize) {
return kRGBA_8888_GrPixelConfig;
}
} else if (4 == rSize && 4 == gSize && 4 == bSize && 4 == aSize) {
return kRGBA_4444_GrPixelConfig;
} else if (5 == rSize && 6 == gSize && 5 == bSize && 0 == aSize) {
return kRGB_565_GrPixelConfig;
}
return kUnknown_GrPixelConfig;
}
int get_fbo_stencil_bits(const GrGLInterface* gl, bool arbFBOExtension) {
GrGLint stencilBits;
if (arbFBOExtension) {
GR_GL_GetFramebufferAttachmentParameteriv(gl, GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
GR_GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
&stencilBits);
} else {
GR_GL_GetIntegerv(gl, GR_GL_STENCIL_BITS, &stencilBits);
}
return stencilBits;
}
}
GrRenderTarget* GrGpuGL::onCreateRenderTargetFrom3DApiState() {
GrGLRenderTarget::Desc rtDesc;
GR_GL_GetIntegerv(this->glInterface(), GR_GL_FRAMEBUFFER_BINDING,
(GrGLint*)&rtDesc.fRTFBOID);
rtDesc.fTexFBOID = rtDesc.fRTFBOID;
rtDesc.fMSColorRenderbufferID = 0;
bool arbFBO = ((kDesktop_GrGLBinding == fGLBinding) && (fGLVersion > 3.0 ||
this->hasExtension("GL_ARB_framebuffer_object")));
GrGLIRect viewport;
viewport.setFromGLViewport(this->glInterface());
int stencilBits = get_fbo_stencil_bits(this->glInterface(), arbFBO);
GR_GL_GetIntegerv(this->glInterface(), GR_GL_SAMPLES, &rtDesc.fSampleCnt);
SkAutoTUnref<GrGLStencilBuffer> sb;
if (stencilBits) {
GrGLStencilBuffer::Format format;
// we could query this but we don't really need it
format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat;
format.fPacked = false;
format.fStencilBits = stencilBits;
format.fTotalBits = stencilBits;
sb.reset(new GrGLStencilBuffer(this, 0, viewport.fWidth,
viewport.fHeight, rtDesc.fSampleCnt,
format));
}
GrGLenum fmat = get_fbo_color_format(this->glInterface());
if (kUnknownGLFormat == fmat) {
rtDesc.fConfig = get_implied_color_config(this->glInterface(), arbFBO);
} else {
rtDesc.fConfig = internal_color_format_to_config(fmat);
}
// may have to bind a texture to gets its format
this->setSpareTextureUnit();
rtDesc.fOwnIDs = false;
GrGLRenderTarget* target = new GrGLRenderTarget(this, rtDesc, viewport);
target->setStencilBuffer(sb.get());
return target;
}
///////////////////////////////////////////////////////////////////////////////
static const GrGLuint kUnknownBitCount = ~0;
void GrGpuGL::setupStencilFormats() {

View File

@ -82,7 +82,6 @@ protected:
virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size,
bool dynamic);
virtual GrResource* onCreatePlatformSurface(const GrPlatformSurfaceDesc& desc);
virtual GrRenderTarget* onCreateRenderTargetFrom3DApiState();
virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt,
int width, int height);
virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb,

View File

@ -256,8 +256,6 @@ GrGLBinding get_binding_in_use(const GrGLInterface* gl) {
GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
: GrGpuGL(gl, get_binding_in_use(gl)) {
resetContext();
f4X4DownsampleFilterSupport = true;
if (kDesktop_GrGLBinding == this->glBinding()) {
fDualSourceBlendingSupport =

View File

@ -50,13 +50,6 @@ public:
*/
SkGpuDevice(GrContext*, GrTexture*);
/**
* Magic value that can be passed to constructor. Causes
* the device to infer rendertarget from underlying 3D API (e.g. GL or D3D).
* This isn't a valid pointer, don't attempt to dereference.
*/
static GrRenderTarget* Current3DApiRenderTarget();
virtual ~SkGpuDevice();
GrContext* context() const { return fContext; }

View File

@ -23,7 +23,7 @@
#endif
/**
* Create an offscreen opengl context
* Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
*/
class SkEGLContext {
public:
@ -32,7 +32,10 @@ public:
bool init(const int width, const int height);
int getFBOID() const { return fFBO; }
private:
GLuint fFBO;
#if defined(SK_MESA)
OSMesaContext context;
GLfloat *image;

View File

@ -104,10 +104,6 @@ public:
///////////////////////////////////////////////////////////////////////////////
GrRenderTarget* SkGpuDevice::Current3DApiRenderTarget() {
return (GrRenderTarget*) -1;
}
static SkBitmap::Config grConfig2skConfig(GrPixelConfig config, bool* isOpaque) {
switch (config) {
case kAlpha_8_GrPixelConfig:
@ -130,13 +126,7 @@ static SkBitmap::Config grConfig2skConfig(GrPixelConfig config, bool* isOpaque)
}
static SkBitmap make_bitmap(GrContext* context, GrRenderTarget* renderTarget) {
SkAutoTUnref<GrRenderTarget> rtunref;
if (SkGpuDevice::Current3DApiRenderTarget() == renderTarget) {
renderTarget = context->createRenderTargetFrom3DApiState();
rtunref.reset(renderTarget);
}
GrTexture* texture = renderTarget->asTexture();
GrPixelConfig config = texture ? texture->config() : kRGBA_8888_GrPixelConfig;
GrPixelConfig config = renderTarget->config();
bool isOpaque;
SkBitmap bitmap;
@ -168,16 +158,12 @@ void SkGpuDevice::initFromRenderTarget(GrContext* context,
fRenderTarget = NULL;
fNeedClear = false;
if (Current3DApiRenderTarget() == renderTarget) {
fRenderTarget = fContext->createRenderTargetFrom3DApiState();
} else {
GrAssert(NULL != renderTarget);
fRenderTarget = renderTarget;
fRenderTarget->ref();
// if this RT is also a texture, hold a ref on it
fTexture = fRenderTarget->asTexture();
SkSafeRef(fTexture);
}
GrAssert(NULL != renderTarget);
fRenderTarget = renderTarget;
fRenderTarget->ref();
// if this RT is also a texture, hold a ref on it
fTexture = fRenderTarget->asTexture();
SkSafeRef(fTexture);
SkGrRenderTargetPixelRef* pr = new SkGrRenderTargetPixelRef(fRenderTarget);
this->setPixelRef(pr, 0)->unref();

View File

@ -7,7 +7,8 @@
*/
#include "SkEGLContext.h"
SkEGLContext::SkEGLContext() {
SkEGLContext::SkEGLContext()
: fFBO(0) {
}
SkEGLContext::~SkEGLContext() {

View File

@ -9,7 +9,9 @@
//#include "SkTypes.h"
#include <AGL/agl.h>
SkEGLContext::SkEGLContext() : context(NULL) {
SkEGLContext::SkEGLContext()
: fFBO(0)
, context(NULL) {
}
SkEGLContext::~SkEGLContext() {
@ -53,11 +55,10 @@ bool SkEGLContext::init(int width, int height) {
// Now create our FBO render target
GLuint fboID;
GLuint cbID;
GLuint dsID;
glGenFramebuffersEXT(1, &fboID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
glGenFramebuffersEXT(1, &fFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFBO);
glGenRenderbuffers(1, &cbID);
glBindRenderbuffer(GL_RENDERBUFFER, cbID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, width, height);

View File

@ -15,7 +15,10 @@
#define SK_GL_GET_PROC(T, F) F ## _func = (T)OSMesaGetProcAddress(#F);
#define SK_GL_GET_EXT_PROC(T, F) F ## _func = (T)OSMesaGetProcAddress(#F "EXT");
SkEGLContext::SkEGLContext() : context(NULL), image(NULL) {
SkEGLContext::SkEGLContext()
: fFBO(0)
, context(NULL)
, image(NULL) {
}
SkEGLContext::~SkEGLContext() {
@ -110,11 +113,10 @@ bool SkEGLContext::init(const int width, const int height) {
return false;
}
GLuint fboID;
GLuint cbID;
GLuint dsID;
glGenFramebuffers_func(1, &fboID);
glBindFramebuffer_func(GL_FRAMEBUFFER, fboID);
glGenFramebuffers_func(1, &fFBO);
glBindFramebuffer_func(GL_FRAMEBUFFER, fFBO);
glGenRenderbuffers_func(1, &cbID);
glBindRenderbuffer_func(GL_RENDERBUFFER, cbID);

View File

@ -23,7 +23,12 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
return 0;
}
SkEGLContext::SkEGLContext() : context(NULL), display(NULL), pixmap(0), glxPixmap(0) {
SkEGLContext::SkEGLContext()
: fFBO(0)
, context(NULL)
, display(NULL)
, pixmap(0)
, glxPixmap(0) {
}
SkEGLContext::~SkEGLContext() {
@ -249,11 +254,10 @@ bool SkEGLContext::init(const int width, const int height) {
SK_GL_GET_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbufferEXT)
SK_GL_GET_PROC(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatusEXT)
GLuint fboID;
GLuint cbID;
GLuint dsID;
glGenFramebuffersEXT(1, &fboID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
glGenFramebuffersEXT(1, &fFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFBO);
glGenRenderbuffersEXT(1, &cbID);
glBindRenderbufferEXT(GL_RENDERBUFFER, cbID);
glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA, width, height);

View File

@ -34,8 +34,9 @@ typedef void (SK_EGL_FUNCTION_TYPE *SkEGLRenderbufferStorageProc) (GLenum target
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLFramebufferRenderbufferProc) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef GLenum (SK_EGL_FUNCTION_TYPE *SkEGLCheckFramebufferStatusProc) (GLenum target);
SkEGLContext::SkEGLContext() :
fWindow(NULL)
SkEGLContext::SkEGLContext()
: fFBO(0)
, fWindow(NULL)
, fDeviceContext(NULL)
, fGlRenderContext(0) {
}
@ -174,11 +175,10 @@ bool SkEGLContext::init(const int width, const int height) {
SK_EGL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT)
SK_EGL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT)
GLuint fboID;
GLuint cbID;
GLuint dsID;
SkEGLGenFramebuffers(1, &fboID);
SkEGLBindFramebuffer(SK_EGL_FRAMEBUFFER, fboID);
SkEGLGenFramebuffers(1, &fFBO);
SkEGLBindFramebuffer(SK_EGL_FRAMEBUFFER, fFBO);
SkEGLGenRenderbuffers(1, &cbID);
SkEGLBindRenderbuffer(SK_EGL_RENDERBUFFER, cbID);
SkEGLRenderbufferStorage(SK_EGL_RENDERBUFFER, GL_RGBA, width, height);