diff options
author | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-09 18:25:38 +0000 |
---|---|---|
committer | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-09 18:25:38 +0000 |
commit | c9542ca3d00878a18a57af80037060d6374d5650 (patch) | |
tree | dffaa6a224392fa3806f18336ac54d3ee6a23ea5 | |
parent | 338a49fc55be8555e171419d079a1b6317060a38 (diff) |
Add swapBuffer call to SkGLContextHelper.
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/26701002
git-svn-id: http://skia.googlecode.com/svn/trunk@11682 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/gpu/gl/SkANGLEGLContext.h | 1 | ||||
-rw-r--r-- | include/gpu/gl/SkDebugGLContext.h | 1 | ||||
-rw-r--r-- | include/gpu/gl/SkGLContextHelper.h | 12 | ||||
-rw-r--r-- | include/gpu/gl/SkMesaGLContext.h | 1 | ||||
-rw-r--r-- | include/gpu/gl/SkNativeGLContext.h | 1 | ||||
-rw-r--r-- | include/gpu/gl/SkNullGLContext.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/android/SkNativeGLContext_android.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/angle/SkANGLEGLContext.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/iOS/SkNativeGLContext_iOS.mm | 2 | ||||
-rw-r--r-- | src/gpu/gl/mac/SkNativeGLContext_mac.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/mesa/SkMesaGLContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/unix/SkNativeGLContext_unix.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/win/SkNativeGLContext_win.cpp | 6 |
14 files changed, 52 insertions, 0 deletions
diff --git a/include/gpu/gl/SkANGLEGLContext.h b/include/gpu/gl/SkANGLEGLContext.h index 63765a0131..99ef4e9a99 100644 --- a/include/gpu/gl/SkANGLEGLContext.h +++ b/include/gpu/gl/SkANGLEGLContext.h @@ -22,6 +22,7 @@ public: virtual ~SkANGLEGLContext(); virtual void makeCurrent() const SK_OVERRIDE; + virtual void swapBuffers() const SK_OVERRIDE; class AutoContextRestore { public: diff --git a/include/gpu/gl/SkDebugGLContext.h b/include/gpu/gl/SkDebugGLContext.h index 2437aaeb5f..545ef40027 100644 --- a/include/gpu/gl/SkDebugGLContext.h +++ b/include/gpu/gl/SkDebugGLContext.h @@ -16,6 +16,7 @@ public: SkDebugGLContext() {}; virtual void makeCurrent() const SK_OVERRIDE {}; + virtual void swapBuffers() const SK_OVERRIDE {}; protected: virtual const GrGLInterface* createGLContext() SK_OVERRIDE; diff --git a/include/gpu/gl/SkGLContextHelper.h b/include/gpu/gl/SkGLContextHelper.h index 97d416b34a..44eb509a04 100644 --- a/include/gpu/gl/SkGLContextHelper.h +++ b/include/gpu/gl/SkGLContextHelper.h @@ -34,6 +34,18 @@ public: virtual void makeCurrent() const = 0; + /** + * The primary purpose of this function it to provide a means of scheduling + * work on the GPU (since all of the subclasses create primary buffers for + * testing that are small and not meant to be rendered to the screen). + * + * If the drawing surface provided by the platform is double buffered this + * call will cause the platform to swap which buffer is currently being + * targeted. If the current surface does not include a back buffer, this + * call has no effect. + */ + virtual void swapBuffers() const = 0; + bool hasExtension(const char* extensionName) const { SkASSERT(NULL != fGL); return fExtensions.has(extensionName); diff --git a/include/gpu/gl/SkMesaGLContext.h b/include/gpu/gl/SkMesaGLContext.h index 6470d2eef0..55235fa603 100644 --- a/include/gpu/gl/SkMesaGLContext.h +++ b/include/gpu/gl/SkMesaGLContext.h @@ -22,6 +22,7 @@ public: virtual ~SkMesaGLContext(); virtual void makeCurrent() const SK_OVERRIDE; + virtual void swapBuffers() const SK_OVERRIDE; class AutoContextRestore { public: diff --git a/include/gpu/gl/SkNativeGLContext.h b/include/gpu/gl/SkNativeGLContext.h index 27a8f09bac..a18c443165 100644 --- a/include/gpu/gl/SkNativeGLContext.h +++ b/include/gpu/gl/SkNativeGLContext.h @@ -30,6 +30,7 @@ public: virtual ~SkNativeGLContext(); virtual void makeCurrent() const SK_OVERRIDE; + virtual void swapBuffers() const SK_OVERRIDE; class AutoContextRestore { public: diff --git a/include/gpu/gl/SkNullGLContext.h b/include/gpu/gl/SkNullGLContext.h index 4f2639c8d7..df7812b98f 100644 --- a/include/gpu/gl/SkNullGLContext.h +++ b/include/gpu/gl/SkNullGLContext.h @@ -17,6 +17,8 @@ public: virtual void makeCurrent() const SK_OVERRIDE {}; + virtual void swapBuffers() const SK_OVERRIDE {}; + protected: virtual const GrGLInterface* createGLContext() SK_OVERRIDE; diff --git a/src/gpu/gl/android/SkNativeGLContext_android.cpp b/src/gpu/gl/android/SkNativeGLContext_android.cpp index 8811ddae9d..dda7d9d3fa 100644 --- a/src/gpu/gl/android/SkNativeGLContext_android.cpp +++ b/src/gpu/gl/android/SkNativeGLContext_android.cpp @@ -165,3 +165,9 @@ void SkNativeGLContext::makeCurrent() const { SkDebugf("Could not set the context.\n"); } } + +void SkNativeGLContext::swapBuffers() const { + if (!eglSwapBuffers(fDisplay, fSurface)) { + SkDebugf("Could not complete eglSwapBuffers.\n"); + } +} diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp index fea27622a0..2600ec4634 100644 --- a/src/gpu/gl/angle/SkANGLEGLContext.cpp +++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp @@ -105,3 +105,9 @@ void SkANGLEGLContext::makeCurrent() const { SkDebugf("Could not set the context.\n"); } } + +void SkANGLEGLContext::swapBuffers() const { + if (!eglSwapBuffers(fDisplay, fSurface)) { + SkDebugf("Could not complete eglSwapBuffers.\n"); + } +} diff --git a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm index 46bd03a2c3..a276fd05da 100644 --- a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm +++ b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm @@ -60,3 +60,5 @@ void SkNativeGLContext::makeCurrent() const { SkDebugf("Could not set the context.\n"); } } + +void SkNativeGLContext::swapBuffers() const { }
\ No newline at end of file diff --git a/src/gpu/gl/mac/SkNativeGLContext_mac.cpp b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp index 2c43c3d2d4..df316d7ed1 100644 --- a/src/gpu/gl/mac/SkNativeGLContext_mac.cpp +++ b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp @@ -39,6 +39,7 @@ const GrGLInterface* SkNativeGLContext::createGLContext() { #if MAC_OS_X_VERSION_10_7 kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core, #endif + kCGLPFADoubleBuffer, (CGLPixelFormatAttribute)0 }; CGLPixelFormatObj pixFormat; @@ -74,3 +75,7 @@ const GrGLInterface* SkNativeGLContext::createGLContext() { void SkNativeGLContext::makeCurrent() const { CGLSetCurrentContext(fContext); } + +void SkNativeGLContext::swapBuffers() const { + CGLFlushDrawable(fContext); +} diff --git a/src/gpu/gl/mesa/SkMesaGLContext.cpp b/src/gpu/gl/mesa/SkMesaGLContext.cpp index 2be0c13036..0199d12c19 100644 --- a/src/gpu/gl/mesa/SkMesaGLContext.cpp +++ b/src/gpu/gl/mesa/SkMesaGLContext.cpp @@ -104,3 +104,5 @@ void SkMesaGLContext::makeCurrent() const { } } } + +void SkMesaGLContext::swapBuffers() const { } diff --git a/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp b/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp index 59ed2bf86a..69a74caf8a 100644 --- a/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp +++ b/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp @@ -32,3 +32,6 @@ const GrGLInterface* SkNativeGLContext::createGLContext() { void SkNativeGLContext::makeCurrent() const { } + +void SkNativeGLContext::swapBuffers() const { +} diff --git a/src/gpu/gl/unix/SkNativeGLContext_unix.cpp b/src/gpu/gl/unix/SkNativeGLContext_unix.cpp index e6fae8ed7b..c4bd6f937d 100644 --- a/src/gpu/gl/unix/SkNativeGLContext_unix.cpp +++ b/src/gpu/gl/unix/SkNativeGLContext_unix.cpp @@ -285,3 +285,7 @@ void SkNativeGLContext::makeCurrent() const { SkDebugf("Could not set the context.\n"); } } + +void SkNativeGLContext::swapBuffers() const { + glXSwapBuffers(fDisplay, fGlxPixmap); +} diff --git a/src/gpu/gl/win/SkNativeGLContext_win.cpp b/src/gpu/gl/win/SkNativeGLContext_win.cpp index 4c736994fe..d8777274bc 100644 --- a/src/gpu/gl/win/SkNativeGLContext_win.cpp +++ b/src/gpu/gl/win/SkNativeGLContext_win.cpp @@ -112,3 +112,9 @@ void SkNativeGLContext::makeCurrent() const { SkDebugf("Could not create rendering context.\n"); } } + +void SkNativeGLContext::swapBuffers() const { + if (!SwapBuffers(fDeviceContext)) { + SkDebugf("Could not complete SwapBuffers.\n"); + } +} |