Create GPU-less build of Skia.
git-svn-id: http://skia.googlecode.com/svn/trunk@4912 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index ed76743..f3e96e0 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -8,7 +8,9 @@
#include "SkBitmap.h"
#include "SkBlurImageFilter.h"
#include "SkColorPriv.h"
+#if SK_SUPPORT_GPU
#include "GrContext.h"
+#endif
SkBlurImageFilter::SkBlurImageFilter(SkFlattenableReadBuffer& buffer)
: INHERITED(buffer) {
@@ -184,8 +186,13 @@
}
GrTexture* SkBlurImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& rect) {
+#if SK_SUPPORT_GPU
return src->getContext()->gaussianBlur(src, false, rect,
fSigma.width(), fSigma.height());
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+#endif
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkBlurImageFilter)
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 9971c56..98c294c 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -9,6 +9,8 @@
#include "SkBitmap.h"
#include "SkColorPriv.h"
#include "SkTypes.h"
+
+#if SK_SUPPORT_GPU
#include "GrProgramStageFactory.h"
#include "effects/GrSingleTextureEffect.h"
#include "gl/GrGLProgramStage.h"
@@ -21,6 +23,7 @@
// For brevity
typedef GrGLUniformManager::UniformHandle UniformHandle;
static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle;
+#endif
namespace {
@@ -29,6 +32,7 @@
const SkScalar gOneHalf = SkFloatToScalar(0.5f);
const SkScalar gOneQuarter = SkFloatToScalar(0.25f);
+#if SK_SUPPORT_GPU
void setUniformPoint3(const GrGLUniformManager& uman, UniformHandle uni, const SkPoint3& point) {
GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(GrGLfloat));
uman.set3fv(uni, 0, 1, &point.fX);
@@ -44,6 +48,7 @@
int height) {
setUniformPoint3(uman, uni, SkPoint3(point.fX, height-point.fY, point.fZ));
}
+#endif
// Shift matrix components to the left, as we advance pixels to the right.
inline void shiftMatrixLeft(int m[9]) {
@@ -298,6 +303,7 @@
SkScalar fShininess;
};
+#if SK_SUPPORT_GPU
class GrLightingEffect : public GrSingleTextureEffect {
public:
@@ -437,6 +443,11 @@
UniformHandle fConeScaleUni;
UniformHandle fSUni;
};
+#else
+
+class GrGLLight;
+
+#endif
};
@@ -493,7 +504,14 @@
SkPoint3 lightColor(const SkPoint3&) const { return color(); }
virtual LightType type() const { return kDistant_LightType; }
const SkPoint3& direction() const { return fDirection; }
- virtual GrGLLight* createGLLight() const SK_OVERRIDE;
+ virtual GrGLLight* createGLLight() const SK_OVERRIDE {
+#if SK_SUPPORT_GPU
+ return SkNEW(GrGLDistantLight);
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+#endif
+ }
virtual bool isEqual(const SkLight& other) const SK_OVERRIDE {
if (other.type() != kDistant_LightType) {
return false;
@@ -538,7 +556,12 @@
virtual LightType type() const { return kPoint_LightType; }
const SkPoint3& location() const { return fLocation; }
virtual GrGLLight* createGLLight() const SK_OVERRIDE {
+#if SK_SUPPORT_GPU
return SkNEW(GrGLPointLight);
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+#endif
}
virtual bool isEqual(const SkLight& other) const SK_OVERRIDE {
if (other.type() != kPoint_LightType) {
@@ -603,7 +626,12 @@
return color() * scale;
}
virtual GrGLLight* createGLLight() const SK_OVERRIDE {
+#if SK_SUPPORT_GPU
return SkNEW(GrGLSpotLight);
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+#endif
}
virtual LightType type() const { return kSpot_LightType; }
const SkPoint3& location() const { return fLocation; }
@@ -790,11 +818,16 @@
bool SkDiffuseLightingImageFilter::asNewCustomStage(GrCustomStage** stage,
GrTexture* texture) const {
+#if SK_SUPPORT_GPU
if (stage) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
*stage = SkNEW_ARGS(GrDiffuseLightingEffect, (texture, light(), scale, kd()));
}
return true;
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
+#endif
}
///////////////////////////////////////////////////////////////////////////////
@@ -854,15 +887,21 @@
bool SkSpecularLightingImageFilter::asNewCustomStage(GrCustomStage** stage,
GrTexture* texture) const {
+#if SK_SUPPORT_GPU
if (stage) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
*stage = SkNEW_ARGS(GrSpecularLightingEffect, (texture, light(), scale, ks(), shininess()));
}
return true;
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return false;
+#endif
}
///////////////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
class GrGLLightingEffect : public GrGLProgramStage {
public:
GrGLLightingEffect(const GrProgramStageFactory& factory,
@@ -1176,10 +1215,6 @@
setUniformPoint3(uman, fColorUni, light->color() * SkScalarInvert(SkIntToScalar(255)));
}
-GrGLLight* SkDistantLight::createGLLight() const {
- return SkNEW(GrGLDistantLight);
-}
-
///////////////////////////////////////////////////////////////////////////////
void GrGLDistantLight::setupVariables(GrGLShaderBuilder* builder) {
@@ -1299,6 +1334,8 @@
out->appendf("lightColor(%s)", surfaceToLight);
}
+#endif
+
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 3c2e385..b0fc289 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -8,8 +8,10 @@
#include "SkMorphologyImageFilter.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
+#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrTexture.h"
+#endif
SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer)
: INHERITED(buffer) {
@@ -213,15 +215,25 @@
}
GrTexture* SkDilateImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& rect) {
+#if SK_SUPPORT_GPU
return src->getContext()->applyMorphology(src, rect,
GrContext::kDilate_MorphologyType,
radius());
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+#endif
}
GrTexture* SkErodeImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& rect) {
+#if SK_SUPPORT_GPU
return src->getContext()->applyMorphology(src, rect,
GrContext::kErode_MorphologyType,
radius());
+#else
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+#endif
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDilateImageFilter)
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 0dfb186..e415c62 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -671,6 +671,10 @@
///////////////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+
+#include "SkGr.h"
+
GrGLGradientStage::GrGLGradientStage(const GrProgramStageFactory& factory)
: INHERITED(factory) { }
@@ -728,3 +732,4 @@
return fTexture;
}
+#endif
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index af15ecd..9e80fd3 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -18,9 +18,6 @@
#include "SkTemplates.h"
#include "SkBitmapCache.h"
#include "SkShader.h"
-#include "GrSamplerState.h"
-#include "SkGr.h"
-#include "gl/GrGLProgramStage.h"
#ifndef SK_DISABLE_DITHER_32BIT_GRADIENT
#define USE_DITHER_32BIT_GRADIENT
@@ -192,6 +189,10 @@
///////////////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+
+#include "gl/GrGLProgramStage.h"
+
class GrSamplerState;
class GrProgramStageFactory;
@@ -262,3 +263,5 @@
#endif
+#endif
+
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 9d4ee6d..cd44d3f 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -472,6 +472,8 @@
}
}
+#if SK_SUPPORT_GPU
+
/////////////////////////////////////////////////////////////////////
class GrGLLinearGradient : public GrGLGradientStage {
@@ -541,3 +543,12 @@
return SkNEW_ARGS(GrLinearGradient, (context, *this, sampler));
}
+#else
+
+GrCustomStage* SkLinearGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+}
+
+#endif
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index be2e46f..32083dc 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -471,6 +471,8 @@
/////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+
class GrGLRadialGradient : public GrGLGradientStage {
public:
@@ -541,3 +543,12 @@
return SkNEW_ARGS(GrRadialGradient, (context, *this, sampler));
}
+#else
+
+GrCustomStage* SkRadialGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+}
+
+#endif
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index b4e013a..1daaa7d 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -380,6 +380,8 @@
/////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+
class GrGLSweepGradient : public GrGLGradientStage {
public:
@@ -448,3 +450,12 @@
return SkNEW_ARGS(GrSweepGradient, (context, *this, sampler));
}
+#else
+
+GrCustomStage* SkSweepGradient::asNewCustomStage(GrContext* context,
+ GrSamplerState* sampler) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+}
+
+#endif
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index ae20cae..9fe180a 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -315,6 +315,8 @@
/////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+
// For brevity
typedef GrGLUniformManager::UniformHandle UniformHandle;
static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle;
@@ -659,3 +661,12 @@
return SkNEW_ARGS(GrConical2Gradient, (context, *this, sampler));
}
+#else
+
+GrCustomStage* SkTwoPointConicalGradient::asNewCustomStage(
+ GrContext* context, GrSamplerState* sampler) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+}
+
+#endif
\ No newline at end of file
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index 582c435..06e27fe 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -347,6 +347,8 @@
/////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
+
// For brevity
typedef GrGLUniformManager::UniformHandle UniformHandle;
static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle;
@@ -630,3 +632,12 @@
return SkNEW_ARGS(GrRadial2Gradient, (context, *this, sampler));
}
+#else
+
+GrCustomStage* SkTwoPointRadialGradient::asNewCustomStage(
+ GrContext* context, GrSamplerState* sampler) const {
+ SkDEBUGFAIL("Should not call in GPU-less build");
+ return NULL;
+}
+
+#endif
diff --git a/src/views/mac/SkNSView.h b/src/views/mac/SkNSView.h
index bf6e67c..8b83b34 100644
--- a/src/views/mac/SkNSView.h
+++ b/src/views/mac/SkNSView.h
@@ -24,13 +24,17 @@
NSString* fTitle;
SkOSWindow* fWind;
+#if SK_SUPPORT_GPU
NSOpenGLContext* fGLContext;
+#endif
id<SkNSViewOptionsDelegate> fOptionsDelegate;
}
@property (nonatomic, readonly) SkOSWindow *fWind;
@property (nonatomic, retain) NSString* fTitle;
+#if SK_SUPPORT_GPU
@property (nonatomic, retain) NSOpenGLContext* fGLContext;
+#endif
@property (nonatomic, assign) id<SkNSViewOptionsDelegate> fOptionsDelegate;
- (id)initWithDefaults;
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index dfb646d..92a357d 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -6,14 +6,18 @@
* found in the LICENSE file.
*/
-#import "SkNSView.h"s
+#import "SkNSView.h"
#include "SkCanvas.h"
#include "SkCGUtils.h"
#include "SkEvent.h"
//#define FORCE_REDRAW
@implementation SkNSView
-@synthesize fWind, fTitle, fOptionsDelegate, fGLContext;
+@synthesize fWind, fTitle, fOptionsDelegate;
+
+#if SK_SUPPORT_GPU
+@synthesize fGLContext;
+#endif
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
@@ -42,6 +46,7 @@
fWind->setVisibleP(true);
fWind->resize((int) self.frame.size.width, (int) self.frame.size.height,
SkBitmap::kARGB_8888_Config);
+ [self attach:SkOSWindow::kNone_BackEndType withMSAASampleCount:0];
}
}
@@ -56,8 +61,10 @@
- (void)resizeSkView:(NSSize)newSize {
if (NULL != fWind && (fWind->width() != newSize.width || fWind->height() != newSize.height)) {
fWind->resize((int) newSize.width, (int) newSize.height);
+#if SK_SUPPORT_GPU
glClear(GL_STENCIL_BUFFER_BIT);
[fGLContext update];
+#endif
}
}
@@ -68,7 +75,9 @@
- (void)dealloc {
delete fWind;
+#if SK_SUPPORT_GPU
self.fGLContext = nil;
+#endif
self.fTitle = nil;
[super dealloc];
}
@@ -115,13 +124,13 @@
#include "SkKey.h"
enum {
- SK_MacReturnKey = 36,
- SK_MacDeleteKey = 51,
- SK_MacEndKey = 119,
- SK_MacLeftKey = 123,
- SK_MacRightKey = 124,
- SK_MacDownKey = 125,
- SK_MacUpKey = 126,
+ SK_MacReturnKey = 36,
+ SK_MacDeleteKey = 51,
+ SK_MacEndKey = 119,
+ SK_MacLeftKey = 123,
+ SK_MacRightKey = 124,
+ SK_MacDownKey = 125,
+ SK_MacUpKey = 126,
SK_Mac0Key = 0x52,
SK_Mac1Key = 0x53,
SK_Mac2Key = 0x54,
@@ -136,17 +145,17 @@
static SkKey raw2key(UInt32 raw)
{
- static const struct {
- UInt32 fRaw;
- SkKey fKey;
- } gKeys[] = {
- { SK_MacUpKey, kUp_SkKey },
- { SK_MacDownKey, kDown_SkKey },
- { SK_MacLeftKey, kLeft_SkKey },
- { SK_MacRightKey, kRight_SkKey },
- { SK_MacReturnKey, kOK_SkKey },
- { SK_MacDeleteKey, kBack_SkKey },
- { SK_MacEndKey, kEnd_SkKey },
+ static const struct {
+ UInt32 fRaw;
+ SkKey fKey;
+ } gKeys[] = {
+ { SK_MacUpKey, kUp_SkKey },
+ { SK_MacDownKey, kDown_SkKey },
+ { SK_MacLeftKey, kLeft_SkKey },
+ { SK_MacRightKey, kRight_SkKey },
+ { SK_MacReturnKey, kOK_SkKey },
+ { SK_MacDeleteKey, kBack_SkKey },
+ { SK_MacEndKey, kEnd_SkKey },
{ SK_Mac0Key, k0_SkKey },
{ SK_Mac1Key, k1_SkKey },
{ SK_Mac2Key, k2_SkKey },
@@ -157,12 +166,12 @@
{ SK_Mac7Key, k7_SkKey },
{ SK_Mac8Key, k8_SkKey },
{ SK_Mac9Key, k9_SkKey }
- };
+ };
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++)
- if (gKeys[i].fRaw == raw)
- return gKeys[i].fKey;
- return kNONE_SkKey;
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++)
+ if (gKeys[i].fRaw == raw)
+ return gKeys[i].fKey;
+ return kNONE_SkKey;
}
- (void)keyDown:(NSEvent *)event {
@@ -222,8 +231,8 @@
}
///////////////////////////////////////////////////////////////////////////////
+#if SK_SUPPORT_GPU
#include <OpenGL/OpenGL.h>
-
namespace {
CGLContextObj createGLContext(int msaaSampleCount) {
GLint major, minor;
@@ -266,46 +275,75 @@
return ctx;
}
}
+#endif
- (void)viewDidMoveToWindow {
[super viewDidMoveToWindow];
+#if SK_SUPPORT_GPU
//Attaching view to fGLContext requires that the view to be part of a window,
//and that the NSWindow instance must have a CoreGraphics counterpart (or
//it must NOT be deferred or should have been on screen at least once)
if ([fGLContext view] != self && nil != self.window) {
[fGLContext setView:self];
}
+#endif
}
-- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType
- withMSAASampleCount:(int) sampleCount {
- if (nil == fGLContext) {
- CGLContextObj ctx = createGLContext(sampleCount);
- fGLContext = [[NSOpenGLContext alloc] initWithCGLContextObj:ctx];
- CGLReleaseContext(ctx);
- if (NULL == fGLContext) {
- return false;
+- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType withMSAASampleCount:(int) sampleCount {
+#if SK_SUPPORT_GPU
+ if (SkOSWindow::kNativeGL_BackEndType == attachType) {
+ [self setWantsLayer:NO];
+ self.layer = nil;
+ if (nil == fGLContext) {
+ CGLContextObj ctx = createGLContext(sampleCount);
+ fGLContext = [[NSOpenGLContext alloc] initWithCGLContextObj:ctx];
+ CGLReleaseContext(ctx);
+ if (NULL == fGLContext) {
+ return false;
+ }
+ [fGLContext setView:self];
}
- [fGLContext setView:self];
+
+ [fGLContext makeCurrentContext];
+
+ glViewport(0, 0, (int) self.bounds.size.width, (int) self.bounds.size.width);
+ glClearColor(0, 0, 0, 0);
+ glClearStencil(0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ return true;
}
-
- [fGLContext makeCurrentContext];
-
- glViewport(0, 0, (int) self.bounds.size.width, (int) self.bounds.size.width);
- glClearColor(0, 0, 0, 0);
- glClearStencil(0);
- glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- return true;
+#endif
+ if (SkOSWindow::kNone_BackEndType == attachType) {
+ [self detach];
+ [self setLayer:[CALayer layer]];
+ [self setWantsLayer:YES];
+ return true;
+ }
+ return false;
}
- (void)detach {
+#if SK_SUPPORT_GPU
[fGLContext release];
fGLContext = nil;
+#endif
}
+#include "SkCGUtils.h"
+
- (void)present {
+#if SK_SUPPORT_GPU
if (nil != fGLContext) {
[fGLContext flushBuffer];
+ return;
}
+#endif
+ const SkBitmap& bmp = fWind->getBitmap();
+ SkASSERT(self.layer);
+ // FIXME: This causes the layer to flicker during animation. Making a copy of the CGImage does
+ // not help.
+ CGImageRef img = SkCreateCGImageRef(bmp);
+ self.layer.contents = (id) img;
+ CGImageRelease(img);
}
@end
diff --git a/src/views/mac/SkOSWindow_Mac.mm b/src/views/mac/SkOSWindow_Mac.mm
index a5d3fef..3e499ba 100644
--- a/src/views/mac/SkOSWindow_Mac.mm
+++ b/src/views/mac/SkOSWindow_Mac.mm
@@ -19,7 +19,9 @@
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
fInvalEventIsPending = false;
+#if SK_SUPPORT_GPU
fGLContext = NULL;
+#endif
fNotifier = [[SkEventNotifier alloc] init];
}
SkOSWindow::~SkOSWindow() {
@@ -38,7 +40,9 @@
fInvalEventIsPending = false;
const SkIRect& r = this->getDirtyBounds();
[(SkNSView*)fHWND postInvalWithRect:&r];
+#if SK_SUPPORT_GPU
[(NSOpenGLContext*)fGLContext update];
+#endif
return true;
}
if ([(SkNSView*)fHWND onHandleEvent:evt]) {
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp
index 2f8e015..88a0a36 100644
--- a/src/views/win/SkOSWindow_win.cpp
+++ b/src/views/win/SkOSWindow_win.cpp
@@ -38,19 +38,22 @@
PostMessage(gEventTarget, WM_EVENT_CALLBACK, 0, 0);
}
-SkOSWindow::SkOSWindow(void* hWnd)
- : fHWND(hWnd)
+SkOSWindow::SkOSWindow(void* hWnd) {
+ fHWND = hWnd;
+#if SK_SUPPORT_GPU
#if SK_ANGLE
- , fDisplay(EGL_NO_DISPLAY)
- , fContext(EGL_NO_CONTEXT)
- , fSurface(EGL_NO_SURFACE)
+ fDisplay = EGL_NO_DISPLAY;
+ fContext = EGL_NO_CONTEXT;
+ fSurface = EGL_NO_SURFACE;
#endif
- , fHGLRC(NULL)
- , fAttached(kNone_BackEndType) {
+ fHGLRC = NULL;
+#endif
+ fAttached = kNone_BackEndType;
gEventTarget = (HWND)hWnd;
}
SkOSWindow::~SkOSWindow() {
+#if SK_SUPPORT_GPU
if (NULL != fHGLRC) {
wglDeleteContext((HGLRC)fHGLRC);
}
@@ -69,7 +72,8 @@
eglTerminate(fDisplay);
fDisplay = EGL_NO_DISPLAY;
}
-#endif
+#endif // SK_ANGLE
+#endif // SK_SUPPORT_GPU
}
static SkKey winToskKey(WPARAM vk) {
@@ -305,6 +309,7 @@
}
}
+#if SK_SUPPORT_GPU
HGLRC create_gl(HWND hwnd, int msaaSampleCount) {
HDC dc = GetDC(hwnd);
@@ -563,7 +568,8 @@
eglSwapBuffers(fDisplay, fSurface);
}
-#endif
+#endif // SK_ANGLE
+#endif // SK_SUPPORT_GPU
// return true on success
bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount) {
@@ -578,6 +584,7 @@
case kNone_BackEndType:
// nothing to do
break;
+#if SK_SUPPORT_GPU
case kNativeGL_BackEndType:
result = attachGL(msaaSampleCount);
break;
@@ -585,7 +592,8 @@
case kANGLE_BackEndType:
result = attachANGLE(msaaSampleCount);
break;
-#endif
+#endif // SK_ANGLE
+#endif // SK_SUPPORT_GPU
default:
SkASSERT(false);
result = false;
@@ -604,6 +612,7 @@
case kNone_BackEndType:
// nothing to do
break;
+#if SK_SUPPORT_GPU
case kNativeGL_BackEndType:
detachGL();
break;
@@ -611,7 +620,8 @@
case kANGLE_BackEndType:
detachANGLE();
break;
-#endif
+#endif // SK_ANGLE
+#endif // SK_SUPPORT_GPU
default:
SkASSERT(false);
break;
@@ -624,6 +634,7 @@
case kNone_BackEndType:
// nothing to do
return;
+#if SK_SUPPORT_GPU
case kNativeGL_BackEndType:
presentGL();
break;
@@ -631,7 +642,8 @@
case kANGLE_BackEndType:
presentANGLE();
break;
-#endif
+#endif // SK_ANGLE
+#endif // SK_SUPPORT_GPU
default:
SkASSERT(false);
break;