move utils/SkEGLContext to gpu/SkGLContext, some gpu.gyp cleanup, set eol style LF on all gpu files
Review URL: http://codereview.appspot.com/5242056/ git-svn-id: http://skia.googlecode.com/svn/trunk@2474 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
1ba7137fc0
commit
e295313f01
@ -15,7 +15,7 @@
|
|||||||
#include "SkBenchmark.h"
|
#include "SkBenchmark.h"
|
||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
#include "SkColorPriv.h"
|
#include "SkColorPriv.h"
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
#include "SkGpuDevice.h"
|
#include "SkGpuDevice.h"
|
||||||
#include "SkGraphics.h"
|
#include "SkGraphics.h"
|
||||||
#include "SkImageEncoder.h"
|
#include "SkImageEncoder.h"
|
||||||
@ -416,8 +416,8 @@ int main (int argc, char * const argv[]) {
|
|||||||
GrRenderTarget* rt = NULL;
|
GrRenderTarget* rt = NULL;
|
||||||
//Don't do GL when fixed.
|
//Don't do GL when fixed.
|
||||||
#if !defined(SK_SCALAR_IS_FIXED)
|
#if !defined(SK_SCALAR_IS_FIXED)
|
||||||
SkEGLContext eglContext;
|
SkGLContext glContext;
|
||||||
if (eglContext.init(1024, 1024)) {
|
if (glContext.init(1024, 1024)) {
|
||||||
context = GrContext::CreateGLShaderContext();
|
context = GrContext::CreateGLShaderContext();
|
||||||
if (NULL != context) {
|
if (NULL != context) {
|
||||||
GrPlatformSurfaceDesc desc;
|
GrPlatformSurfaceDesc desc;
|
||||||
@ -426,7 +426,7 @@ int main (int argc, char * const argv[]) {
|
|||||||
desc.fWidth = 1024;
|
desc.fWidth = 1024;
|
||||||
desc.fHeight = 1024;
|
desc.fHeight = 1024;
|
||||||
desc.fStencilBits = 8;
|
desc.fStencilBits = 8;
|
||||||
desc.fPlatformRenderTarget = eglContext.getFBOID();
|
desc.fPlatformRenderTarget = glContext.getFBOID();
|
||||||
desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
|
desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
|
||||||
rt = static_cast<GrRenderTarget*>(context->createPlatformSurface(desc));
|
rt = static_cast<GrRenderTarget*>(context->createPlatformSurface(desc));
|
||||||
if (NULL == rt) {
|
if (NULL == rt) {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "SkColorPriv.h"
|
#include "SkColorPriv.h"
|
||||||
#include "SkData.h"
|
#include "SkData.h"
|
||||||
#include "SkDevice.h"
|
#include "SkDevice.h"
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
#include "SkGpuCanvas.h"
|
#include "SkGpuCanvas.h"
|
||||||
#include "SkGpuDevice.h"
|
#include "SkGpuDevice.h"
|
||||||
#include "SkGraphics.h"
|
#include "SkGraphics.h"
|
||||||
@ -606,9 +606,9 @@ int main(int argc, char * const argv[]) {
|
|||||||
maxH = SkMax32(size.height(), maxH);
|
maxH = SkMax32(size.height(), maxH);
|
||||||
}
|
}
|
||||||
// setup a GL context for drawing offscreen
|
// setup a GL context for drawing offscreen
|
||||||
SkEGLContext eglContext;
|
SkGLContext glContext;
|
||||||
GrRenderTarget* rt = NULL;
|
GrRenderTarget* rt = NULL;
|
||||||
if (eglContext.init(maxW, maxH)) {
|
if (glContext.init(maxW, maxH)) {
|
||||||
gGrContext = GrContext::CreateGLShaderContext();
|
gGrContext = GrContext::CreateGLShaderContext();
|
||||||
if (NULL != gGrContext) {
|
if (NULL != gGrContext) {
|
||||||
GrPlatformSurfaceDesc desc;
|
GrPlatformSurfaceDesc desc;
|
||||||
@ -617,7 +617,7 @@ int main(int argc, char * const argv[]) {
|
|||||||
desc.fWidth = maxW;
|
desc.fWidth = maxW;
|
||||||
desc.fHeight = maxH;
|
desc.fHeight = maxH;
|
||||||
desc.fStencilBits = 8;
|
desc.fStencilBits = 8;
|
||||||
desc.fPlatformRenderTarget = eglContext.getFBOID();
|
desc.fPlatformRenderTarget = glContext.getFBOID();
|
||||||
desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
|
desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
|
||||||
rt = static_cast<GrRenderTarget*>(gGrContext->createPlatformSurface(desc));
|
rt = static_cast<GrRenderTarget*>(gGrContext->createPlatformSurface(desc));
|
||||||
if (NULL == rt) {
|
if (NULL == rt) {
|
||||||
|
181
gyp/gpu.gyp
181
gyp/gpu.gyp
@ -2,6 +2,89 @@
|
|||||||
'includes': [
|
'includes': [
|
||||||
'common.gypi',
|
'common.gypi',
|
||||||
],
|
],
|
||||||
|
'target_defaults': {
|
||||||
|
'conditions': [
|
||||||
|
['skia_os != "win"', {
|
||||||
|
'sources/': [ ['exclude', '_win.(h|cpp)$'],
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
['skia_os != "mac"', {
|
||||||
|
'sources/': [ ['exclude', '_mac.(h|cpp)$'],
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
['skia_os != "linux"', {
|
||||||
|
'sources/': [ ['exclude', '_unix.(h|cpp)$'],
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
['skia_os != "ios"', {
|
||||||
|
'sources/': [ ['exclude', '_iOS.(h|cpp)$'],
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
['skia_os != "android"', {
|
||||||
|
'sources/': [ ['exclude', '_android.(h|cpp)$'],
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "android"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_ANDROID_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "mac"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_MAC_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "linux"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_LINUX_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "ios"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_IOS_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "win"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_WIN32_BUILD=1',
|
||||||
|
'GR_GL_FUNCTION_TYPE=__stdcall',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
'direct_dependent_settings': {
|
||||||
|
'conditions': [
|
||||||
|
[ 'skia_os == "android"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_ANDROID_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "mac"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_MAC_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "linux"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_LINUX_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "ios"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_IOS_BUILD=1',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
[ 'skia_os == "win"', {
|
||||||
|
'defines': [
|
||||||
|
'GR_WIN32_BUILD=1',
|
||||||
|
'GR_GL_FUNCTION_TYPE=__stdcall',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
'include_dirs': [
|
||||||
|
'../include/gpu',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
'targets': [
|
'targets': [
|
||||||
{
|
{
|
||||||
'target_name': 'skgr',
|
'target_name': 'skgr',
|
||||||
@ -24,46 +107,19 @@
|
|||||||
'../src/gpu/SkGr.cpp',
|
'../src/gpu/SkGr.cpp',
|
||||||
'../src/gpu/SkGrFontScaler.cpp',
|
'../src/gpu/SkGrFontScaler.cpp',
|
||||||
'../src/gpu/SkGrTexturePixelRef.cpp',
|
'../src/gpu/SkGrTexturePixelRef.cpp',
|
||||||
|
|
||||||
|
'../src/gpu/mac/SkGLContext_mac.cpp',
|
||||||
|
|
||||||
|
'../src/gpu/win/SkGLContext_win.cpp',
|
||||||
|
|
||||||
|
'../src/gpu/unix/SkGLContext_unix.cpp',
|
||||||
|
|
||||||
|
'../src/gpu/mesa/SkGLContext_mesa.cpp',
|
||||||
],
|
],
|
||||||
'conditions': [
|
# Removed for now
|
||||||
[ 'skia_os == "linux"', {
|
'sources!': [
|
||||||
'defines': [
|
'../src/gpu/mesa/SkGLContext_mesa.cpp',
|
||||||
'GR_LINUX_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os == "mac"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_MAC_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os == "win"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_WIN32_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
],
|
],
|
||||||
'direct_dependent_settings': {
|
|
||||||
'conditions': [
|
|
||||||
[ 'skia_os == "linux"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_LINUX_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os == "mac"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_MAC_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os == "win"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_WIN32_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
'include_dirs': [
|
|
||||||
'../include/gpu',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'gr',
|
'target_name': 'gr',
|
||||||
@ -201,6 +257,7 @@
|
|||||||
|
|
||||||
'../src/gpu/mesa/GrGLDefaultInterface_mesa.cpp',
|
'../src/gpu/mesa/GrGLDefaultInterface_mesa.cpp',
|
||||||
],
|
],
|
||||||
|
# Removed for now
|
||||||
'sources!': [
|
'sources!': [
|
||||||
'../src/gpu/mesa/GrGLDefaultInterface_mesa.cpp',
|
'../src/gpu/mesa/GrGLDefaultInterface_mesa.cpp',
|
||||||
],
|
],
|
||||||
@ -209,9 +266,6 @@
|
|||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
[ 'skia_os == "linux"', {
|
[ 'skia_os == "linux"', {
|
||||||
'defines': [
|
|
||||||
'GR_LINUX_BUILD=1',
|
|
||||||
],
|
|
||||||
'sources!': [
|
'sources!': [
|
||||||
'../src/gpu/GrGLDefaultInterface_none.cpp',
|
'../src/gpu/GrGLDefaultInterface_none.cpp',
|
||||||
],
|
],
|
||||||
@ -223,9 +277,6 @@
|
|||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
[ 'skia_os == "mac"', {
|
[ 'skia_os == "mac"', {
|
||||||
'defines': [
|
|
||||||
'GR_MAC_BUILD=1',
|
|
||||||
],
|
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
|
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
|
||||||
@ -236,53 +287,11 @@
|
|||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
[ 'skia_os == "win"', {
|
[ 'skia_os == "win"', {
|
||||||
'defines': [
|
|
||||||
'GR_WIN32_BUILD=1',
|
|
||||||
'GR_GL_FUNCTION_TYPE=__stdcall',
|
|
||||||
],
|
|
||||||
'sources!': [
|
'sources!': [
|
||||||
'../src/gpu/GrGLDefaultInterface_none.cpp',
|
'../src/gpu/GrGLDefaultInterface_none.cpp',
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
[ 'skia_os != "win"', {
|
|
||||||
'sources!': [
|
|
||||||
'../src/gpu/win/GrGLDefaultInterface_win.cpp',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os != "mac"', {
|
|
||||||
'sources!': [
|
|
||||||
'../src/gpu/mac/GrGLDefaultInterface_mac.cpp',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os != "linux"', {
|
|
||||||
'sources!': [
|
|
||||||
'../src/gpu/unix/GrGLDefaultInterface_unix.cpp',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
],
|
],
|
||||||
'direct_dependent_settings': {
|
|
||||||
'conditions': [
|
|
||||||
[ 'skia_os == "linux"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_LINUX_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os == "mac"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_MAC_BUILD=1',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
[ 'skia_os == "win"', {
|
|
||||||
'defines': [
|
|
||||||
'GR_WIN32_BUILD=1',
|
|
||||||
'GR_GL_FUNCTION_TYPE=__stdcall',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
'include_dirs': [
|
|
||||||
'../include/gpu',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
'../include/utils/SkCubicInterval.h',
|
'../include/utils/SkCubicInterval.h',
|
||||||
'../include/utils/SkCullPoints.h',
|
'../include/utils/SkCullPoints.h',
|
||||||
'../include/utils/SkDumpCanvas.h',
|
'../include/utils/SkDumpCanvas.h',
|
||||||
'../include/utils/SkEGLContext.h',
|
|
||||||
'../include/utils/SkGLCanvas.h',
|
'../include/utils/SkGLCanvas.h',
|
||||||
'../include/utils/SkInterpolator.h',
|
'../include/utils/SkInterpolator.h',
|
||||||
'../include/utils/SkLayer.h',
|
'../include/utils/SkLayer.h',
|
||||||
@ -45,7 +44,6 @@
|
|||||||
'../src/utils/SkCubicInterval.cpp',
|
'../src/utils/SkCubicInterval.cpp',
|
||||||
'../src/utils/SkCullPoints.cpp',
|
'../src/utils/SkCullPoints.cpp',
|
||||||
'../src/utils/SkDumpCanvas.cpp',
|
'../src/utils/SkDumpCanvas.cpp',
|
||||||
'../src/utils/SkEGLContext_none.cpp',
|
|
||||||
'../src/utils/SkInterpolator.cpp',
|
'../src/utils/SkInterpolator.cpp',
|
||||||
'../src/utils/SkLayer.cpp',
|
'../src/utils/SkLayer.cpp',
|
||||||
'../src/utils/SkMatrix44.cpp',
|
'../src/utils/SkMatrix44.cpp',
|
||||||
@ -63,17 +61,12 @@
|
|||||||
#mac
|
#mac
|
||||||
'../include/utils/mac/SkCGUtils.h',
|
'../include/utils/mac/SkCGUtils.h',
|
||||||
'../src/utils/mac/SkCreateCGImageRef.cpp',
|
'../src/utils/mac/SkCreateCGImageRef.cpp',
|
||||||
'../src/utils/mac/SkEGLContext_mac.cpp',
|
|
||||||
|
|
||||||
#mesa
|
|
||||||
'../src/utils/mesa/SkEGLContext_Mesa.cpp',
|
|
||||||
|
|
||||||
#sdl
|
#sdl
|
||||||
'../src/utils/SDL/SkOSWindow_SDL.cpp',
|
'../src/utils/SDL/SkOSWindow_SDL.cpp',
|
||||||
|
|
||||||
#*nix
|
#*nix
|
||||||
'../src/utils/unix/keysym2ucs.c',
|
'../src/utils/unix/keysym2ucs.c',
|
||||||
'../src/utils/unix/SkEGLContext_Unix.cpp',
|
|
||||||
'../src/utils/unix/SkOSWindow_Unix.cpp',
|
'../src/utils/unix/SkOSWindow_Unix.cpp',
|
||||||
|
|
||||||
#windows
|
#windows
|
||||||
@ -83,20 +76,15 @@
|
|||||||
'../include/utils/win/SkTScopedComPtr.h',
|
'../include/utils/win/SkTScopedComPtr.h',
|
||||||
'../src/utils/win/SkAutoCoInitialize.cpp',
|
'../src/utils/win/SkAutoCoInitialize.cpp',
|
||||||
'../src/utils/win/skia_win.cpp',
|
'../src/utils/win/skia_win.cpp',
|
||||||
'../src/utils/win/SkEGLContext_Win.cpp',
|
|
||||||
'../src/utils/win/SkHRESULT.cpp',
|
'../src/utils/win/SkHRESULT.cpp',
|
||||||
'../src/utils/win/SkIStream.cpp',
|
'../src/utils/win/SkIStream.cpp',
|
||||||
'../src/utils/win/SkOSWindow_Win.cpp',
|
'../src/utils/win/SkOSWindow_Win.cpp',
|
||||||
],
|
],
|
||||||
'sources!': [
|
'sources!': [
|
||||||
'../src/utils/mesa/SkEGLContext_Mesa.cpp',
|
|
||||||
'../src/utils/SDL/SkOSWindow_SDL.cpp',
|
'../src/utils/SDL/SkOSWindow_SDL.cpp',
|
||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
[ 'skia_os == "mac"', {
|
[ 'skia_os == "mac"', {
|
||||||
'sources!': [
|
|
||||||
'../src/utils/SkEGLContext_none.cpp',
|
|
||||||
],
|
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
'$(SDKROOT)/System/Library/Frameworks/AGL.framework',
|
'$(SDKROOT)/System/Library/Frameworks/AGL.framework',
|
||||||
@ -114,15 +102,11 @@
|
|||||||
'sources!': [
|
'sources!': [
|
||||||
'../include/utils/mac/SkCGUtils.h',
|
'../include/utils/mac/SkCGUtils.h',
|
||||||
'../src/utils/mac/SkCreateCGImageRef.cpp',
|
'../src/utils/mac/SkCreateCGImageRef.cpp',
|
||||||
'../src/utils/mac/SkEGLContext_mac.cpp',
|
|
||||||
'../src/utils/mac/skia_mac.mm',
|
'../src/utils/mac/skia_mac.mm',
|
||||||
'../src/utils/mac/SkOSWindow_Mac.mm',
|
'../src/utils/mac/SkOSWindow_Mac.mm',
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
|
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
|
||||||
'sources!': [
|
|
||||||
'../src/utils/SkEGLContext_none.cpp',
|
|
||||||
],
|
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
'-lGL',
|
'-lGL',
|
||||||
@ -135,14 +119,10 @@
|
|||||||
],
|
],
|
||||||
'sources!': [
|
'sources!': [
|
||||||
'../src/utils/unix/keysym2ucs.c',
|
'../src/utils/unix/keysym2ucs.c',
|
||||||
'../src/utils/unix/SkEGLContext_Unix.cpp',
|
|
||||||
'../src/utils/unix/SkOSWindow_Unix.cpp',
|
'../src/utils/unix/SkOSWindow_Unix.cpp',
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
[ 'skia_os == "win"', {
|
[ 'skia_os == "win"', {
|
||||||
'sources!': [
|
|
||||||
'../src/utils/SkEGLContext_none.cpp',
|
|
||||||
],
|
|
||||||
'direct_dependent_settings': {
|
'direct_dependent_settings': {
|
||||||
'include_dirs': [
|
'include_dirs': [
|
||||||
'../include/utils/win',
|
'../include/utils/win',
|
||||||
@ -159,7 +139,6 @@
|
|||||||
'../include/utils/win/SkTScopedComPtr.h',
|
'../include/utils/win/SkTScopedComPtr.h',
|
||||||
'../src/utils/win/SkAutoCoInitialize.cpp',
|
'../src/utils/win/SkAutoCoInitialize.cpp',
|
||||||
'../src/utils/win/skia_win.cpp',
|
'../src/utils/win/skia_win.cpp',
|
||||||
'../src/utils/win/SkEGLContext_Win.cpp',
|
|
||||||
'../src/utils/win/SkHRESULT.cpp',
|
'../src/utils/win/SkHRESULT.cpp',
|
||||||
'../src/utils/win/SkIStream.cpp',
|
'../src/utils/win/SkIStream.cpp',
|
||||||
'../src/utils/win/SkOSWindow_Win.cpp',
|
'../src/utils/win/SkOSWindow_Win.cpp',
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#ifndef SkEGLContext_DEFINED
|
#ifndef SkGLContext_DEFINED
|
||||||
#define SkEGLContext_DEFINED
|
#define SkGLContext_DEFINED
|
||||||
|
|
||||||
#if defined(SK_MESA)
|
#if defined(SK_MESA)
|
||||||
#include "GL/osmesa.h"
|
#include "GL/osmesa.h"
|
||||||
@ -25,10 +25,10 @@
|
|||||||
/**
|
/**
|
||||||
* Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
|
* Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
|
||||||
*/
|
*/
|
||||||
class SkEGLContext {
|
class SkGLContext {
|
||||||
public:
|
public:
|
||||||
SkEGLContext();
|
SkGLContext();
|
||||||
~SkEGLContext();
|
~SkGLContext();
|
||||||
|
|
||||||
bool init(const int width, const int height);
|
bool init(const int width, const int height);
|
||||||
|
|
@ -5,15 +5,15 @@
|
|||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
|
|
||||||
SkEGLContext::SkEGLContext()
|
SkGLContext::SkGLContext()
|
||||||
: fFBO(0) {
|
: fFBO(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkEGLContext::~SkEGLContext() {
|
SkGLContext::~SkGLContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkEGLContext::init(int width, int height) {
|
bool SkGLContext::init(int width, int height) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -5,22 +5,22 @@
|
|||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
//#include "SkTypes.h"
|
//#include "SkTypes.h"
|
||||||
#include <AGL/agl.h>
|
#include <AGL/agl.h>
|
||||||
|
|
||||||
SkEGLContext::SkEGLContext()
|
SkGLContext::SkGLContext()
|
||||||
: fFBO(0)
|
: fFBO(0)
|
||||||
, context(NULL) {
|
, context(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkEGLContext::~SkEGLContext() {
|
SkGLContext::~SkGLContext() {
|
||||||
if (this->context) {
|
if (this->context) {
|
||||||
aglDestroyContext(this->context);
|
aglDestroyContext(this->context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkEGLContext::init(int width, int height) {
|
bool SkGLContext::init(int width, int height) {
|
||||||
GLint major, minor;
|
GLint major, minor;
|
||||||
AGLContext ctx;
|
AGLContext ctx;
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
#include "SkTypes.h"
|
#include "SkTypes.h"
|
||||||
|
|
||||||
#include "GL/osmesa.h"
|
#include "GL/osmesa.h"
|
||||||
@ -15,13 +15,13 @@
|
|||||||
#define SK_GL_GET_PROC(T, F) F ## _func = (T)OSMesaGetProcAddress(#F);
|
#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");
|
#define SK_GL_GET_EXT_PROC(T, F) F ## _func = (T)OSMesaGetProcAddress(#F "EXT");
|
||||||
|
|
||||||
SkEGLContext::SkEGLContext()
|
SkGLContext::SkGLContext()
|
||||||
: fFBO(0)
|
: fFBO(0)
|
||||||
, context(NULL)
|
, context(NULL)
|
||||||
, image(NULL) {
|
, image(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkEGLContext::~SkEGLContext() {
|
SkGLContext::~SkGLContext() {
|
||||||
if (this->image)
|
if (this->image)
|
||||||
free(this->image);
|
free(this->image);
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ SkEGLContext::~SkEGLContext() {
|
|||||||
#define SK_OSMESA_COLOR_ORDER OSMESA_RGBA
|
#define SK_OSMESA_COLOR_ORDER OSMESA_RGBA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool SkEGLContext::init(const int width, const int height) {
|
bool SkGLContext::init(const int width, const int height) {
|
||||||
/* Create an RGBA-mode context */
|
/* Create an RGBA-mode context */
|
||||||
#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
|
#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
|
||||||
/* specify Z, stencil, accum sizes */
|
/* specify Z, stencil, accum sizes */
|
@ -5,7 +5,7 @@
|
|||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
#include "SkTypes.h"
|
#include "SkTypes.h"
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
@ -23,7 +23,7 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkEGLContext::SkEGLContext()
|
SkGLContext::SkGLContext()
|
||||||
: fFBO(0)
|
: fFBO(0)
|
||||||
, context(NULL)
|
, context(NULL)
|
||||||
, display(NULL)
|
, display(NULL)
|
||||||
@ -31,7 +31,7 @@ SkEGLContext::SkEGLContext()
|
|||||||
, glxPixmap(0) {
|
, glxPixmap(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkEGLContext::~SkEGLContext() {
|
SkGLContext::~SkGLContext() {
|
||||||
if (this->display) {
|
if (this->display) {
|
||||||
glXMakeCurrent(this->display, 0, 0);
|
glXMakeCurrent(this->display, 0, 0);
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ SkEGLContext::~SkEGLContext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkEGLContext::init(const int width, const int height) {
|
bool SkGLContext::init(const int width, const int height) {
|
||||||
Display *display = XOpenDisplay(0);
|
Display *display = XOpenDisplay(0);
|
||||||
this->display = display;
|
this->display = display;
|
||||||
|
|
@ -9,39 +9,39 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <GL/GL.h>
|
#include <GL/GL.h>
|
||||||
|
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
#include "SkTypes.h"
|
#include "SkTypes.h"
|
||||||
|
|
||||||
#define SK_EGL_DECLARE_PROC(F) SkEGL ## F ## Proc SkEGL ## F = NULL;
|
#define SK_GL_DECLARE_PROC(F) SkGL ## F ## Proc SkGL ## F = NULL;
|
||||||
#define SK_EGL_GET_PROC(F) SkEGL ## F = (SkEGL ## F ## Proc) \
|
#define SK_GL_GET_PROC(F) SkGL ## F = (SkGL ## F ## Proc) \
|
||||||
wglGetProcAddress("gl" #F);
|
wglGetProcAddress("gl" #F);
|
||||||
#define SK_EGL_GET_PROC_SUFFIX(F, S) SkEGL ## F = (SkEGL ## F ## Proc) \
|
#define SK_GL_GET_PROC_SUFFIX(F, S) SkGL ## F = (SkGL ## F ## Proc) \
|
||||||
wglGetProcAddress("gl" #F #S);
|
wglGetProcAddress("gl" #F #S);
|
||||||
|
|
||||||
#define SK_EGL_FRAMEBUFFER 0x8D40
|
#define SK_GL_FRAMEBUFFER 0x8D40
|
||||||
#define SK_EGL_RENDERBUFFER 0x8D41
|
#define SK_GL_RENDERBUFFER 0x8D41
|
||||||
#define SK_EGL_COLOR_ATTACHMENT0 0x8CE0
|
#define SK_GL_COLOR_ATTACHMENT0 0x8CE0
|
||||||
#define SK_EGL_DEPTH_STENCIL 0x84F9
|
#define SK_GL_DEPTH_STENCIL 0x84F9
|
||||||
#define SK_EGL_DEPTH_STENCIL_ATTACHMENT 0x821A
|
#define SK_GL_DEPTH_STENCIL_ATTACHMENT 0x821A
|
||||||
#define SK_EGL_FRAMEBUFFER_COMPLETE 0x8CD5
|
#define SK_GL_FRAMEBUFFER_COMPLETE 0x8CD5
|
||||||
|
|
||||||
#define SK_EGL_FUNCTION_TYPE __stdcall
|
#define SK_GL_FUNCTION_TYPE __stdcall
|
||||||
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLGenFramebuffersProc) (GLsizei n, GLuint *framebuffers);
|
typedef void (SK_GL_FUNCTION_TYPE *SkGLGenFramebuffersProc) (GLsizei n, GLuint *framebuffers);
|
||||||
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLBindFramebufferProc) (GLenum target, GLuint framebuffer);
|
typedef void (SK_GL_FUNCTION_TYPE *SkGLBindFramebufferProc) (GLenum target, GLuint framebuffer);
|
||||||
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLGenRenderbuffersProc) (GLsizei n, GLuint *renderbuffers);
|
typedef void (SK_GL_FUNCTION_TYPE *SkGLGenRenderbuffersProc) (GLsizei n, GLuint *renderbuffers);
|
||||||
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLBindRenderbufferProc) (GLenum target, GLuint renderbuffer);
|
typedef void (SK_GL_FUNCTION_TYPE *SkGLBindRenderbufferProc) (GLenum target, GLuint renderbuffer);
|
||||||
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLRenderbufferStorageProc) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
typedef void (SK_GL_FUNCTION_TYPE *SkGLRenderbufferStorageProc) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||||
typedef void (SK_EGL_FUNCTION_TYPE *SkEGLFramebufferRenderbufferProc) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
typedef void (SK_GL_FUNCTION_TYPE *SkGLFramebufferRenderbufferProc) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||||
typedef GLenum (SK_EGL_FUNCTION_TYPE *SkEGLCheckFramebufferStatusProc) (GLenum target);
|
typedef GLenum (SK_GL_FUNCTION_TYPE *SkGLCheckFramebufferStatusProc) (GLenum target);
|
||||||
|
|
||||||
SkEGLContext::SkEGLContext()
|
SkGLContext::SkGLContext()
|
||||||
: fFBO(0)
|
: fFBO(0)
|
||||||
, fWindow(NULL)
|
, fWindow(NULL)
|
||||||
, fDeviceContext(NULL)
|
, fDeviceContext(NULL)
|
||||||
, fGlRenderContext(0) {
|
, fGlRenderContext(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkEGLContext::~SkEGLContext() {
|
SkGLContext::~SkGLContext() {
|
||||||
if (this->fGlRenderContext) {
|
if (this->fGlRenderContext) {
|
||||||
wglDeleteContext(this->fGlRenderContext);
|
wglDeleteContext(this->fGlRenderContext);
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ SkEGLContext::~SkEGLContext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool skEGLCheckExtension(const char* ext,
|
bool skGLCheckExtension(const char* ext,
|
||||||
const char* extensionString) {
|
const char* extensionString) {
|
||||||
int extLength = strlen(ext);
|
int extLength = strlen(ext);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ bool skEGLCheckExtension(const char* ext,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkEGLContext::init(const int width, const int height) {
|
bool SkGLContext::init(const int width, const int height) {
|
||||||
HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
|
HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
|
||||||
|
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
@ -152,51 +152,51 @@ bool SkEGLContext::init(const int width, const int height) {
|
|||||||
//Setup the framebuffers
|
//Setup the framebuffers
|
||||||
const char* glExts =
|
const char* glExts =
|
||||||
reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
|
reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
|
||||||
if (!skEGLCheckExtension(
|
if (!skGLCheckExtension(
|
||||||
"GL_EXT_framebuffer_object"
|
"GL_EXT_framebuffer_object"
|
||||||
, glExts))
|
, glExts))
|
||||||
{
|
{
|
||||||
SkDebugf("GL_EXT_framebuffer_object not found.\n");
|
SkDebugf("GL_EXT_framebuffer_object not found.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SK_EGL_DECLARE_PROC(GenFramebuffers)
|
SK_GL_DECLARE_PROC(GenFramebuffers)
|
||||||
SK_EGL_DECLARE_PROC(BindFramebuffer)
|
SK_GL_DECLARE_PROC(BindFramebuffer)
|
||||||
SK_EGL_DECLARE_PROC(GenRenderbuffers)
|
SK_GL_DECLARE_PROC(GenRenderbuffers)
|
||||||
SK_EGL_DECLARE_PROC(BindRenderbuffer)
|
SK_GL_DECLARE_PROC(BindRenderbuffer)
|
||||||
SK_EGL_DECLARE_PROC(RenderbufferStorage)
|
SK_GL_DECLARE_PROC(RenderbufferStorage)
|
||||||
SK_EGL_DECLARE_PROC(FramebufferRenderbuffer)
|
SK_GL_DECLARE_PROC(FramebufferRenderbuffer)
|
||||||
SK_EGL_DECLARE_PROC(CheckFramebufferStatus)
|
SK_GL_DECLARE_PROC(CheckFramebufferStatus)
|
||||||
|
|
||||||
SK_EGL_GET_PROC_SUFFIX(GenFramebuffers, EXT)
|
SK_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT)
|
||||||
SK_EGL_GET_PROC_SUFFIX(BindFramebuffer, EXT)
|
SK_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT)
|
||||||
SK_EGL_GET_PROC_SUFFIX(GenRenderbuffers, EXT)
|
SK_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT)
|
||||||
SK_EGL_GET_PROC_SUFFIX(BindRenderbuffer, EXT)
|
SK_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT)
|
||||||
SK_EGL_GET_PROC_SUFFIX(RenderbufferStorage, EXT)
|
SK_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT)
|
||||||
SK_EGL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT)
|
SK_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT)
|
||||||
SK_EGL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT)
|
SK_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT)
|
||||||
|
|
||||||
GLuint cbID;
|
GLuint cbID;
|
||||||
GLuint dsID;
|
GLuint dsID;
|
||||||
SkEGLGenFramebuffers(1, &fFBO);
|
SkGLGenFramebuffers(1, &fFBO);
|
||||||
SkEGLBindFramebuffer(SK_EGL_FRAMEBUFFER, fFBO);
|
SkGLBindFramebuffer(SK_GL_FRAMEBUFFER, fFBO);
|
||||||
SkEGLGenRenderbuffers(1, &cbID);
|
SkGLGenRenderbuffers(1, &cbID);
|
||||||
SkEGLBindRenderbuffer(SK_EGL_RENDERBUFFER, cbID);
|
SkGLBindRenderbuffer(SK_GL_RENDERBUFFER, cbID);
|
||||||
SkEGLRenderbufferStorage(SK_EGL_RENDERBUFFER, GL_RGBA, width, height);
|
SkGLRenderbufferStorage(SK_GL_RENDERBUFFER, GL_RGBA, width, height);
|
||||||
SkEGLFramebufferRenderbuffer(SK_EGL_FRAMEBUFFER
|
SkGLFramebufferRenderbuffer(SK_GL_FRAMEBUFFER
|
||||||
, SK_EGL_COLOR_ATTACHMENT0
|
, SK_GL_COLOR_ATTACHMENT0
|
||||||
, SK_EGL_RENDERBUFFER, cbID);
|
, SK_GL_RENDERBUFFER, cbID);
|
||||||
SkEGLGenRenderbuffers(1, &dsID);
|
SkGLGenRenderbuffers(1, &dsID);
|
||||||
SkEGLBindRenderbuffer(SK_EGL_RENDERBUFFER, dsID);
|
SkGLBindRenderbuffer(SK_GL_RENDERBUFFER, dsID);
|
||||||
SkEGLRenderbufferStorage(SK_EGL_RENDERBUFFER, SK_EGL_DEPTH_STENCIL
|
SkGLRenderbufferStorage(SK_GL_RENDERBUFFER, SK_GL_DEPTH_STENCIL
|
||||||
, width, height);
|
, width, height);
|
||||||
SkEGLFramebufferRenderbuffer(SK_EGL_FRAMEBUFFER
|
SkGLFramebufferRenderbuffer(SK_GL_FRAMEBUFFER
|
||||||
, SK_EGL_DEPTH_STENCIL_ATTACHMENT
|
, SK_GL_DEPTH_STENCIL_ATTACHMENT
|
||||||
, SK_EGL_RENDERBUFFER
|
, SK_GL_RENDERBUFFER
|
||||||
, dsID);
|
, dsID);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glClearStencil(0);
|
glClearStencil(0);
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
GLenum status = SkEGLCheckFramebufferStatus(SK_EGL_FRAMEBUFFER);
|
GLenum status = SkGLCheckFramebufferStatus(SK_GL_FRAMEBUFFER);
|
||||||
return SK_EGL_FRAMEBUFFER_COMPLETE == status;
|
return SK_GL_FRAMEBUFFER_COMPLETE == status;
|
||||||
}
|
}
|
@ -8,7 +8,7 @@
|
|||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
|
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "SkEGLContext.h"
|
#include "SkGLContext.h"
|
||||||
#include "SkTLazy.h"
|
#include "SkTLazy.h"
|
||||||
|
|
||||||
using namespace skiatest;
|
using namespace skiatest;
|
||||||
@ -79,12 +79,12 @@ bool Test::run() {
|
|||||||
|
|
||||||
GrContext* GpuTest::GetContext() {
|
GrContext* GpuTest::GetContext() {
|
||||||
// preserve this order, we want gGrContext destroyed after gEGLContext
|
// preserve this order, we want gGrContext destroyed after gEGLContext
|
||||||
static SkTLazy<SkEGLContext> gEGLContext;
|
static SkTLazy<SkGLContext> gGLContext;
|
||||||
static SkAutoTUnref<GrContext> gGrContext;
|
static SkAutoTUnref<GrContext> gGrContext;
|
||||||
|
|
||||||
if (NULL == gGrContext.get()) {
|
if (NULL == gGrContext.get()) {
|
||||||
gEGLContext.init();
|
gGLContext.init();
|
||||||
if (gEGLContext.get()->init(800, 600)) {
|
if (gGLContext.get()->init(800, 600)) {
|
||||||
gGrContext.reset(GrContext::Create(kOpenGL_Shaders_GrEngine, NULL));
|
gGrContext.reset(GrContext::Create(kOpenGL_Shaders_GrEngine, NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "SkTRegistry.h"
|
#include "SkTRegistry.h"
|
||||||
|
|
||||||
class GrContext;
|
class GrContext;
|
||||||
class SkEGLContext;
|
class SkGLContext;
|
||||||
|
|
||||||
namespace skiatest {
|
namespace skiatest {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user