aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'gpu')
-rw-r--r--gpu/include/GrGLConfig.h11
-rw-r--r--gpu/include/GrUserConfig.h7
-rw-r--r--gpu/src/GrGpuGL.cpp40
-rw-r--r--gpu/src/GrGpuGLShaders2.cpp28
4 files changed, 54 insertions, 32 deletions
diff --git a/gpu/include/GrGLConfig.h b/gpu/include/GrGLConfig.h
index 7fab1b5189..b183892472 100644
--- a/gpu/include/GrGLConfig.h
+++ b/gpu/include/GrGLConfig.h
@@ -190,9 +190,14 @@
#error "unknown GR_TEXT_SCALAR type"
#endif
-// Pick a pixel config for 32bit bitmaps. Our default is GL_RGBA
-#ifndef SK_GL_32BPP_COLOR_FORMAT
- #define SK_GL_32BPP_COLOR_FORMAT GL_RGBA
+// Pick a pixel config for 32bit bitmaps. Our default is GL_RGBA (expect on
+// Windows where we match GDI's order).
+#ifndef GR_GL_32BPP_COLOR_FORMAT
+ #if GR_WIN32_BUILD
+ #define GR_GL_32BPP_COLOR_FORMAT GL_BGRA
+ #else
+ #define GR_GL_32BPP_COLOR_FORMAT GL_RGBA
+ #endif
#endif
////////////////////////////////////////////////////////////////////////////////
diff --git a/gpu/include/GrUserConfig.h b/gpu/include/GrUserConfig.h
index b0ea58c65d..860d2ccd40 100644
--- a/gpu/include/GrUserConfig.h
+++ b/gpu/include/GrUserConfig.h
@@ -31,10 +31,11 @@
//#define GR_FORCE_GLCHECKERR 1
/*
- * The default 32bit pixel config for texture upload is GL_RGBA. If your
- * bitmaps map to a different GL enum, specify that with this define.
+ * The default 32bit pixel config for texture upload is GL_RGBA on all
+ * platforms except on Windows where it is GL_BGRA. If your bitmaps map to a
+ * different GL enum, specify that with this define.
*/
-//#define SK_GL_32BPP_COLOR_FORMAT GL_RGBA
+//#define GR_GL_32BPP_COLOR_FORMAT GL_RGBA
/*
* To diagnose texture cache performance, define this to 1 if you want to see
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 87d69bc39c..2130e58bba 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -17,6 +17,14 @@
#include "GrGpuGL.h"
#include "GrMemory.h"
#include <stdio.h>
+#if GR_WIN32_BUILD
+ // need to get wglGetProcAddress
+ #undef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN 1
+ #include <windows.h>
+ #undef WIN32_LEAN_AND_MEAN
+#endif
+
static const GLuint GR_MAX_GLUINT = ~0;
static const GLint GR_INVAL_GLINT = ~0;
@@ -94,7 +102,9 @@ bool fbo_test(GrGLExts exts, int w, int h) {
GLuint testRTTex;
GR_GL(GenTextures(1, &testRTTex));
GR_GL(BindTexture(GL_TEXTURE_2D, testRTTex));
-
+ // some implementations require texture to be mip-map complete before
+ // FBO with level 0 bound as color attachment will be framebuffer complete.
+ GR_GL(TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
GR_GL(TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
GR_GL(BindTexture(GL_TEXTURE_2D, 0));
@@ -290,6 +300,18 @@ GrGpuGL::GrGpuGL() {
// Experiments to determine limitations that can't be queried. TODO: Make
// these a preprocess that generate some compile time constants.
+ // sanity check to make sure we can at least create an FBO from a POT texture
+ if (fNPOTTextureSupport < kFull_NPOTTextureType) {
+ bool npotFBOSuccess = fbo_test(fExts, 128, 128);
+ if (gPrintStartupSpew) {
+ if (!npotFBOSuccess) {
+ GrPrintf("FBO Sanity Test: FAILED\n");
+ } else {
+ GrPrintf("FBO Sanity Test: PASSED\n");
+ }
+ }
+ }
+
/* Experimentation has found that some GLs that support NPOT textures
do not support FBOs with a NPOT texture. They report "unsupported" FBO
status. I don't know how to explicitly query for this. Do an
@@ -328,18 +350,6 @@ GrGpuGL::GrGpuGL() {
}
}
- // sanity check to make sure we can at least create an FBO from a POT texture
- if (fNPOTTextureSupport < kFull_NPOTTextureType) {
- bool npotFBOSuccess = fbo_test(fExts, 128, 128);
- if (gPrintStartupSpew) {
- if (!npotFBOSuccess) {
- GrPrintf("FBO Sanity Test: FAILED\n");
- } else {
- GrPrintf("FBO Sanity Test: PASSED\n");
- }
- }
- }
-
/* The iPhone 4 has a restriction that for an FBO with texture color
attachment with height <= 8 then the width must be <= height. Here
we look for such a limitation.
@@ -1628,7 +1638,7 @@ bool GrGpuGL::canBeTexture(GrTexture::PixelConfig config,
switch (config) {
case GrTexture::kRGBA_8888_PixelConfig:
case GrTexture::kRGBX_8888_PixelConfig: // todo: can we tell it our X?
- *format = SK_GL_32BPP_COLOR_FORMAT;
+ *format = GR_GL_32BPP_COLOR_FORMAT;
*internalFormat = GL_RGBA;
*type = GL_UNSIGNED_BYTE;
break;
@@ -1714,7 +1724,7 @@ typedef void (*glProc)(void);
void get_gl_proc(const char procName[], glProc *address) {
#if GR_WIN32_BUILD
- *address = wglGetProcAddress(procName);
+ *address = (glProc)wglGetProcAddress(procName);
GrAssert(NULL != *address);
#elif GR_MAC_BUILD || GR_IOS_BUILD
GrAssert(!"Extensions don't need to be initialized!");
diff --git a/gpu/src/GrGpuGLShaders2.cpp b/gpu/src/GrGpuGLShaders2.cpp
index 2e41d56add..c7b3cb982b 100644
--- a/gpu/src/GrGpuGLShaders2.cpp
+++ b/gpu/src/GrGpuGLShaders2.cpp
@@ -96,12 +96,15 @@ struct GrGpuGLShaders2::StageDesc {
kNoPerspective_OptFlagBit = 0x1,
kIdentityMatrix_OptFlagBit = 0x2,
};
- int fOptFlags : 8;
- bool fEnabled : 8;
+ unsigned fOptFlags : 8;
+
+ unsigned fEnabled : 8;
+
enum Modulation {
kColor_Modulation,
kAlpha_Modulation,
} fModulation : 8;
+
enum CoordMapping {
kIdentity_CoordMapping,
kRadialGradient_CoordMapping,
@@ -113,13 +116,16 @@ struct GrGpuGLShaders2::StageDesc {
// must be tightly packed
struct GrGpuGLShaders2::ProgramDesc {
GrVertexLayout fVertexLayout;
+ GR_STATIC_ASSERT(2 == sizeof(GrVertexLayout)); // pack with next field
+
enum {
kNotPoints_OptFlagBit = 0x1,
kVertexColorAllOnes_OptFlagBit = 0x2,
};
// we're assuming optflags and layout pack into 32 bits
- GR_STATIC_ASSERT(2 == sizeof(GrVertexLayout));
- int fOptFlags : 16;
+ // VS 2010 seems to require short rather than just unsigned
+ // for this to pack
+ unsigned short fOptFlags : 16;
StageDesc fStages[NUM_STAGES];
@@ -389,9 +395,9 @@ void GrGpuGLShaders2::ProgramUnitTest() {
x = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_OPTS));
pdesc.fStages[s].fOptFlags = STAGE_OPTS[x];
x = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_MODULATES));
- pdesc.fStages[s].fModulation = STAGE_MODULATES[x];
+ pdesc.fStages[s].fModulation = (StageDesc::Modulation) STAGE_MODULATES[x];
x = (int)(random.nextF() * GR_ARRAY_COUNT(STAGE_COORD_MAPPINGS));
- pdesc.fStages[s].fCoordMapping = STAGE_COORD_MAPPINGS[x];
+ pdesc.fStages[s].fCoordMapping = (StageDesc::CoordMapping) STAGE_COORD_MAPPINGS[x];
}
Program program;
GenProgram(pdesc, &program);
@@ -948,8 +954,8 @@ void GrGpuGLShaders2::getProgramDesc(PrimitiveType primType, ProgramDesc* desc)
for (int i = 1; i < NUM_STAGES; ++i) {
desc->fStages[i].fEnabled = false;
desc->fStages[i].fOptFlags = 0;
- desc->fStages[i].fCoordMapping = 0;
- desc->fStages[i].fModulation = 0;
+ desc->fStages[i].fCoordMapping = (StageDesc::CoordMapping)0;
+ desc->fStages[i].fModulation = (StageDesc::Modulation)0;
}
if (primType != kPoints_PrimitiveType) {
@@ -997,7 +1003,7 @@ void GrGpuGLShaders2::getProgramDesc(PrimitiveType primType, ProgramDesc* desc)
stage.fModulation = StageDesc::kColor_Modulation;
break;
case GrSamplerState::kSweep_SampleMode:
- stage.fCoordMapping = StageDesc::StageDesc::kSweepGradient_CoordMapping;
+ stage.fCoordMapping = StageDesc::kSweepGradient_CoordMapping;
stage.fModulation = StageDesc::kColor_Modulation;
break;
default:
@@ -1006,8 +1012,8 @@ void GrGpuGLShaders2::getProgramDesc(PrimitiveType primType, ProgramDesc* desc)
}
} else {
stage.fOptFlags = 0;
- stage.fCoordMapping = 0;
- stage.fModulation = 0;
+ stage.fCoordMapping = (StageDesc::CoordMapping)0;
+ stage.fModulation = (StageDesc::Modulation)0;
}
}