aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-28 16:56:28 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-28 16:56:28 +0000
commitcca3c8f21b80f515a236a4b0d1e1f0b6418fcc97 (patch)
tree34fe733d141a3246497e5c6dbe2f42e073e95c4a /experimental
parent1e9c987c69a41605abfc72fb126672a14f2799a5 (diff)
Make gpu work in iOS SampleApp.
This includes updates to the GrGLInterface and changes to the DeviceManager subclass used on iOS. Review URL: https://codereview.appspot.com/6582043 git-svn-id: http://skia.googlecode.com/svn/trunk@5722 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental')
-rw-r--r--experimental/iOSSampleApp/SkSampleUIView.mm31
1 files changed, 16 insertions, 15 deletions
diff --git a/experimental/iOSSampleApp/SkSampleUIView.mm b/experimental/iOSSampleApp/SkSampleUIView.mm
index d96e550fbc..916978c587 100644
--- a/experimental/iOSSampleApp/SkSampleUIView.mm
+++ b/experimental/iOSSampleApp/SkSampleUIView.mm
@@ -19,12 +19,13 @@
class SkiOSDeviceManager : public SampleWindow::DeviceManager {
public:
- SkiOSDeviceManager() {
+ SkiOSDeviceManager(GLint layerFBO) {
#if SK_SUPPORT_GPU
fCurContext = NULL;
fCurIntf = NULL;
fCurRenderTarget = NULL;
fMSAASampleCount = 0;
+ fLayerFBO = layerFBO;
#endif
fBackend = SkOSWindow::kNone_BackEndType;
}
@@ -130,7 +131,7 @@ public:
// create a GPU device for these two
case SampleWindow::kGPU_DeviceType:
case SampleWindow::kNullGPU_DeviceType:
- if (fCurContext) {
+ if (NULL != fCurContext) {
canvas->setDevice(new SkGpuDevice(fCurContext, fCurRenderTarget))->unref();
} else {
return false;
@@ -147,23 +148,25 @@ public:
virtual void publishCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win) SK_OVERRIDE {
+ if (NULL != fCurContext) {
+ fCurContext->flush();
+ }
win->present();
}
virtual void windowSizeChanged(SampleWindow* win) SK_OVERRIDE {
#if SK_SUPPORT_GPU
- if (fCurContext) {
+ if (NULL != fCurContext) {
win->attach(fBackend, fMSAASampleCount);
+ glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO);
GrPlatformRenderTargetDesc desc;
desc.fWidth = SkScalarRound(win->width());
desc.fHeight = SkScalarRound(win->height());
desc.fConfig = kSkia8888_PM_GrPixelConfig;
+ desc.fRenderTargetHandle = fLayerFBO;
glGetIntegerv(GL_SAMPLES, &desc.fSampleCnt);
glGetIntegerv(GL_STENCIL_BITS, &desc.fStencilBits);
- GrGLint buffer;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &buffer);
- desc.fRenderTargetHandle = buffer;
SkSafeUnref(fCurRenderTarget);
fCurRenderTarget = fCurContext->createPlatformRenderTarget(desc);
@@ -190,12 +193,13 @@ public:
bool isUsingGL() const { return SkOSWindow::kNone_BackEndType != fBackend; }
private:
-
+
#if SK_SUPPORT_GPU
GrContext* fCurContext;
const GrGLInterface* fCurIntf;
GrRenderTarget* fCurRenderTarget;
- int fMSAASampleCount;
+ int fMSAASampleCount;
+ GLint fLayerFBO;
#endif
SkOSWindow::SkBackEndTypes fBackend;
@@ -338,9 +342,10 @@ static FPSState gFPS;
fRasterLayer.actions = newActions;
[newActions release];
- fDevManager = new SkiOSDeviceManager;
+ fDevManager = new SkiOSDeviceManager(fGL.fFramebuffer);
static char* kDummyArgv = "dummyExecutableName";
fWind = new SampleWindow(self, 1, &kDummyArgv, fDevManager);
+
fWind->resize(self.frame.size.width, self.frame.size.height, SKWIND_CONFIG);
}
return self;
@@ -422,17 +427,13 @@ static FPSState gFPS;
}
glViewport(0, 0, fGL.fWidth, fGL.fHeight);
-
- GrContext* ctx = fDevManager->getGrContext();
- SkASSERT(NULL != ctx);
-
+
SkCanvas canvas;
-
// if we're not "retained", then we have to always redraw everything.
// This call forces us to ignore the fDirtyRgn, and draw everywhere.
// If we are "retained", we can skip this call (as the raster case does)
fWind->forceInvalAll();
-
+
[self drawWithCanvas:&canvas];
// This application only creates a single color renderbuffer which is already bound at this point.