Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: cmake/example.cpp

Issue 1315753009: CMake builds on Ubuntu now too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ARGV -> ARGN Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cmake/CMakeLists.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cmake/example.cpp
diff --git a/cmake/example.cpp b/cmake/example.cpp
index ea10bed759ccb94497809eaad5772dc3873cc1b4..2fc91d52205d9c1badbb8245069365f3919598d0 100644
--- a/cmake/example.cpp
+++ b/cmake/example.cpp
@@ -18,10 +18,11 @@
#include <iostream>
#include <memory>
+// These setup_gl_context() are not meant to represent good form.
+// They are just quick hacks to get us going.
#if defined(__APPLE__)
#include <OpenGL/OpenGL.h>
- static void setup_gl_context() {
- // This is not meant to represent good form. It's just a quick hack to get us going.
+ static bool setup_gl_context() {
CGLPixelFormatAttribute attributes[] = { (CGLPixelFormatAttribute)0 };
CGLPixelFormatObj format;
GLint npix;
@@ -30,6 +31,11 @@
CGLCreateContext(format, nullptr, &context);
CGLSetCurrentContext(context);
CGLReleasePixelFormat(format);
+ return true;
+ }
+#else
+ static bool setup_gl_context() {
+ return false;
}
#endif
@@ -53,10 +59,10 @@ static std::shared_ptr<SkSurface> create_opengl_surface(int w, int h) {
}
int main(int, char**) {
- setup_gl_context();
+ bool gl_ok = setup_gl_context();
srand(time(nullptr));
- std::shared_ptr<SkSurface> surface = (rand() % 2) ? create_raster_surface(320, 240)
- : create_opengl_surface(320, 240);
+ std::shared_ptr<SkSurface> surface = (gl_ok && rand() % 2) ? create_opengl_surface(320, 240)
+ : create_raster_surface(320, 240);
// Create a left-to-right green-to-purple gradient shader.
SkPoint pts[] = { {0,0}, {320,240} };
« no previous file with comments | « cmake/CMakeLists.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698