aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-28 16:19:11 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-28 16:19:11 +0000
commitd3b9fbbc48c13a1b2a664cf7e01374a44c201f51 (patch)
treef4f1ade2e1ce0953eeb0551c96603e51bfdd08e2 /samplecode
parent42aea289cbf801997b653a906a37a7f7e948b645 (diff)
Code changes for ANGLE GL interface. .gyp file changes will be delivered later.
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleApp.cpp74
-rw-r--r--samplecode/SampleApp.h2
-rw-r--r--samplecode/SampleDegenerateTwoPtRadials.cpp1
3 files changed, 66 insertions, 11 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index ddd33ede32..dc522b603a 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -130,7 +130,11 @@ static void writeTitleToPrefs(const char* title) {
class SampleWindow::DefaultDeviceManager : public SampleWindow::DeviceManager {
public:
- DefaultDeviceManager() {
+ DefaultDeviceManager()
+#if SK_ANGLE
+ : fUseAltContext(false)
+#endif
+ {
fGrRenderTarget = NULL;
fGrContext = NULL;
fGL = NULL;
@@ -146,12 +150,32 @@ public:
SkSafeUnref(fNullGrRenderTarget);
}
- virtual void init(SampleWindow* win) {
- if (!win->attachGL()) {
+ virtual void init(SampleWindow* win, bool useAltContext) {
+#if SK_ANGLE
+ fUseAltContext = useAltContext;
+#endif
+ bool result;
+
+#if SK_ANGLE
+ if (useAltContext) {
+ result = win->attachANGLE();
+ } else
+#endif
+ {
+ result = win->attachGL();
+ }
+ if (!result) {
SkDebugf("Failed to initialize GL");
}
if (NULL == fGL) {
- fGL = GrGLCreateNativeInterface();
+#if SK_ANGLE
+ if (useAltContext) {
+ fGL = GrGLCreateANGLEInterface();
+ } else
+#endif
+ {
+ fGL = GrGLCreateNativeInterface();
+ }
GrAssert(NULL == fGrContext);
fGrContext = GrContext::Create(kOpenGL_Shaders_GrEngine,
(GrPlatform3DContext) fGL);
@@ -160,7 +184,14 @@ public:
SkSafeUnref(fGrContext);
SkSafeUnref(fGL);
SkDebugf("Failed to setup 3D");
- win->detachGL();
+#if SK_ANGLE
+ if (useAltContext) {
+ win->detachANGLE();
+ } else
+#endif
+ {
+ win->detachGL();
+ }
}
if (NULL == fNullGrContext) {
const GrGLInterface* nullGL = GrGLCreateNullInterface();
@@ -231,12 +262,26 @@ public:
bm.rowBytes());
}
}
- win->presentGL();
+#if SK_ANGLE
+ if (fUseAltContext) {
+ win->presentANGLE();
+ } else
+#endif
+ {
+ win->presentGL();
+ }
}
virtual void windowSizeChanged(SampleWindow* win) {
if (fGrContext) {
- win->attachGL();
+#if SK_ANGLE
+ if (fUseAltContext) {
+ win->attachANGLE();
+ } else
+#endif
+ {
+ win->attachGL();
+ }
GrPlatformRenderTargetDesc desc;
desc.fWidth = SkScalarRound(win->width());
@@ -271,6 +316,9 @@ public:
}
}
private:
+#if SK_ANGLE
+ bool fUseAltContext;
+#endif
GrContext* fGrContext;
const GrGLInterface* fGL;
GrRenderTarget* fGrRenderTarget;
@@ -621,6 +669,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
const char* resourcePath = NULL;
fCurrIndex = -1;
+ bool useAltContext = false;
const char* const commandName = argv[0];
char* const* stop = argv + argc;
@@ -638,7 +687,14 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
fprintf(stderr, "Unknown sample \"%s\"\n", *argv);
}
}
- } else {
+ }
+#if SK_ANGLE
+ else if (strcmp(*argv, "--angle") == 0) {
+ argv++;
+ useAltContext = true;
+ }
+#endif
+ else {
usage(commandName);
}
}
@@ -769,7 +825,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
devManager->ref();
fDevManager = devManager;
}
- fDevManager->init(this);
+ fDevManager->init(this, useAltContext);
// If another constructor set our dimensions, ensure that our
// onSizeChange gets called.
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 871d47eedd..94f663feb0 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -48,7 +48,7 @@ public:
class DeviceManager : public SkRefCnt {
public:
// called at end of SampleWindow cons
- virtual void init(SampleWindow* win) = 0;
+ virtual void init(SampleWindow* win, bool useAltContext) = 0;
// called when selecting a new device type
// can disallow a device type by returning false.
diff --git a/samplecode/SampleDegenerateTwoPtRadials.cpp b/samplecode/SampleDegenerateTwoPtRadials.cpp
index 5b8f46de12..2c08a816ce 100644
--- a/samplecode/SampleDegenerateTwoPtRadials.cpp
+++ b/samplecode/SampleDegenerateTwoPtRadials.cpp
@@ -66,7 +66,6 @@ protected:
static const int DELTA_SCALE = 500;
delta /= DELTA_SCALE;
- SkRect rect;
SkScalar w = SK_Scalar1 * 500;
SkScalar h = SK_Scalar1 * 500;
SkScalar l = SK_Scalar1 * 100;