Fix some VS2010 warnings
Review URL: http://codereview.appspot.com/5155043




git-svn-id: http://skia.googlecode.com/svn/trunk@2380 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 2563fad..af0a122 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -103,7 +103,9 @@
                 paint.fDstBlendCoeff = kISA_BlendCoeff;
                 GrMatrix vm;
                 if (i) {
-                    vm.setRotate(90, S , S);
+                    vm.setRotate(90 * SK_Scalar1,
+                                 S * SK_Scalar1,
+                                 S * SK_Scalar1);
                 } else {
                     vm.reset();
                 }
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index 6aaa28b..e0c7b55 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -856,8 +856,8 @@
                          scale * GR_Scalar1 / src->height());
         sampler.setMatrix(sampleM);
         target->setSamplerState(kOffscreenStage, sampler);
-        GrRect rect = SkRect::MakeWH(scale * tileRect.width(),
-                                     scale * tileRect.height());
+        GrRect rect = SkRect::MakeWH(SkIntToScalar(scale * tileRect.width()),
+                                     SkIntToScalar(scale * tileRect.height()));
         target->drawSimpleRect(rect, NULL, 1 << kOffscreenStage);
         
         src = record->fOffscreen1.texture();
@@ -896,7 +896,8 @@
     sampleM.setScale(scale * GR_Scalar1 / src->width(),
                      scale * GR_Scalar1 / src->height());
     sampler.setMatrix(sampleM);
-    sampleM.setTranslate(-tileRect.fLeft, -tileRect.fTop);
+    sampleM.setTranslate(SkIntToScalar(-tileRect.fLeft),
+                         SkIntToScalar(-tileRect.fTop));
     sampler.preConcatMatrix(sampleM);
     target->setSamplerState(kOffscreenStage, sampler);
 
@@ -1506,23 +1507,23 @@
                 GrDrawTarget::AutoDeviceCoordDraw adcd(target, stageMask);
                 GrRect rect;
                 if (clipIBounds.fTop < bound.fTop) {
-                    rect.setLTRB(clipIBounds.fLeft, clipIBounds.fTop, 
-                                 clipIBounds.fRight, bound.fTop);
+                    rect.iset(clipIBounds.fLeft, clipIBounds.fTop, 
+                              clipIBounds.fRight, bound.fTop);
                     target->drawSimpleRect(rect, NULL, stageMask);
                 }
                 if (clipIBounds.fLeft < bound.fLeft) {
-                    rect.setLTRB(clipIBounds.fLeft, bound.fTop, 
-                                 bound.fLeft, bound.fBottom);
+                    rect.iset(clipIBounds.fLeft, bound.fTop, 
+                              bound.fLeft, bound.fBottom);
                     target->drawSimpleRect(rect, NULL, stageMask);
                 }
                 if (clipIBounds.fRight > bound.fRight) {
-                    rect.setLTRB(bound.fRight, bound.fTop, 
-                                 clipIBounds.fRight, bound.fBottom);
+                    rect.iset(bound.fRight, bound.fTop, 
+                              clipIBounds.fRight, bound.fBottom);
                     target->drawSimpleRect(rect, NULL, stageMask);
                 }
                 if (clipIBounds.fBottom > bound.fBottom) {
-                    rect.setLTRB(clipIBounds.fLeft, bound.fBottom, 
-                                 clipIBounds.fRight, clipIBounds.fBottom);
+                    rect.iset(clipIBounds.fLeft, bound.fBottom, 
+                              clipIBounds.fRight, clipIBounds.fBottom);
                     target->drawSimpleRect(rect, NULL, stageMask);
                 }
             }
diff --git a/gpu/src/GrGLProgram.h b/gpu/src/GrGLProgram.h
index c186ba1..ced3e61 100644
--- a/gpu/src/GrGLProgram.h
+++ b/gpu/src/GrGLProgram.h
@@ -125,7 +125,7 @@
             uint8_t fKernelWidth;
 
             inline bool isEnabled() const {
-                return fOptFlags & kIsEnabled_OptFlagBit;
+                return 0 != (fOptFlags & kIsEnabled_OptFlagBit);
             }
             inline void setEnabled(bool newValue) {
                 if (newValue) {
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 16321d0..ffbb557 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -432,7 +432,7 @@
             probe_for_npot_render_target_support(fGL, fCaps.fNPOTTextureSupport);
     } else {
         GrAssert(expectNPOTTargets == 0 || expectNPOTTargets == 1);
-        fCaps.fNPOTRenderTargetSupport = static_cast<bool>(expectNPOTTargets);
+        fCaps.fNPOTRenderTargetSupport = (0 != expectNPOTTargets);
     }
 
     GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_SIZE, &fCaps.fMaxTextureSize);
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index ea528f8..20ecca5 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -238,7 +238,9 @@
                 }
                 pdesc.fEdgeAANumEdges = 0;
             } else {
-                pdesc.fEdgeAANumEdges = random.nextF() * this->getMaxEdges() + 1;
+                pdesc.fEdgeAANumEdges = 
+                    static_cast<int8_t>(1 + random.nextF() *
+                                        this->getMaxEdges());
                 pdesc.fEdgeAAConcave = random.nextF() > .5f;
             }
         } else {
@@ -279,7 +281,7 @@
                 stage.fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
             }
             stage.setEnabled(VertexUsesStage(s, pdesc.fVertexLayout));
-            stage.fKernelWidth = 4 * random.nextF() + 2;
+            stage.fKernelWidth = static_cast<int8_t>(4 * random.nextF() + 2);
         }
         CachedData cachedData;
         if (!program.genProgram(this->glInterface(),
@@ -562,7 +564,8 @@
         int count = fCurrDrawState.fEdgeAANumEdges;
         Edge edges[kMaxEdges];
         // Flip the edges in Y
-        float height = fCurrDrawState.fRenderTarget->height();
+        float height = 
+            static_cast<float>(fCurrDrawState.fRenderTarget->height());
         for (int i = 0; i < count; ++i) {
             edges[i] = fCurrDrawState.fEdgeAAEdges[i];
             float b = edges[i].fY;
@@ -822,7 +825,7 @@
 
     desc.fEmitsPointSize = kPoints_PrimitiveType == type;
 
-    bool requiresAttributeColors = desc.fVertexLayout & kColor_VertexLayoutBit;
+    bool requiresAttributeColors = 0 != (desc.fVertexLayout & kColor_VertexLayoutBit);
     // fColorType records how colors are specified for the program. Strip
     // the bit from the layout to avoid false negatives when searching for an
     // existing program in the cache.
diff --git a/src/animator/SkDisplayXMLParser.cpp b/src/animator/SkDisplayXMLParser.cpp
index 8a70ab4..68dc259 100644
--- a/src/animator/SkDisplayXMLParser.cpp
+++ b/src/animator/SkDisplayXMLParser.cpp
@@ -157,8 +157,8 @@
 }
 
 #if defined(SK_BUILD_FOR_WIN32)
-    #define SK_strcasecmp   stricmp
-    #define SK_strncasecmp  strnicmp
+    #define SK_strcasecmp   _stricmp
+    #define SK_strncasecmp  _strnicmp
 #else
     #define SK_strcasecmp   strcasecmp
     #define SK_strncasecmp  strncasecmp
diff --git a/src/animator/SkScriptTokenizer.cpp b/src/animator/SkScriptTokenizer.cpp
index b7c1634..6502c34 100644
--- a/src/animator/SkScriptTokenizer.cpp
+++ b/src/animator/SkScriptTokenizer.cpp
@@ -603,7 +603,7 @@
         }
         if (ch ==  '.') {
             if (fTokenLength == 0) {
-                SkScriptValue2 scriptValue;
+                SkDEBUGCODE(SkScriptValue2 scriptValue);
                 SkDEBUGCODE(scriptValue.fOperand.fObject = NULL);
                 int tokenLength = token_length(++script);
                 const char* token = script;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 66b4936..8dadc0b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -984,7 +984,8 @@
               GrIntToScalar(dstM.fBounds.fBottom));
 
     GrMatrix m;
-    m.setTranslate(-dstM.fBounds.fLeft, -dstM.fBounds.fTop);
+    m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1,
+                   -dstM.fBounds.fTop*SK_Scalar1);
     m.postIDiv(texture->width(), texture->height());
     grp->getMaskSampler(MASK_IDX)->setMatrix(m);
     
diff --git a/src/pdf/SkBitSet.cpp b/src/pdf/SkBitSet.cpp
index c10c100..b47bce2 100755
--- a/src/pdf/SkBitSet.cpp
+++ b/src/pdf/SkBitSet.cpp
@@ -67,7 +67,7 @@
 
 bool SkBitSet::isBitSet(int index) const {
     uint32_t mask = 1 << (index % 32);
-    return (*internalGet(index) & mask);
+    return 0 != (*internalGet(index) & mask);
 }
 
 bool SkBitSet::orBits(const SkBitSet& source) {
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp
index a57f9b1..4747888 100644
--- a/src/utils/SkMatrix44.cpp
+++ b/src/utils/SkMatrix44.cpp
@@ -164,9 +164,9 @@
             return;
         }
         double scale = 1 / sqrt(len2);
-        x *= scale;
-        y *= scale;
-        z *= scale;
+        x = SkDoubleToMScalar(x * scale);
+        y = SkDoubleToMScalar(y * scale);
+        z = SkDoubleToMScalar(z * scale);
     }
     this->setRotateAboutUnit(x, y, z, radians);
 }
@@ -187,9 +187,17 @@
     double zxC = z * xC;
 
     // if you're looking at wikipedia, remember that we're column major.
-    this->set3x3(x * xC + c,    xyC + zs,       zxC - ys,
-                 xyC - zs,      y * yC + c,     yzC + xs,
-                 zxC + ys,      yzC - xs,       z * zC + c);
+    this->set3x3(SkDoubleToMScalar(x * xC + c),     // scale x
+                 SkDoubleToMScalar(xyC + zs),       // skew x
+                 SkDoubleToMScalar(zxC - ys),       // trans x
+
+                 SkDoubleToMScalar(xyC - zs),       // skew y
+                 SkDoubleToMScalar(y * yC + c),     // scale y
+                 SkDoubleToMScalar(yzC + xs),       // trans y
+
+                 SkDoubleToMScalar(zxC + ys),       // persp x
+                 SkDoubleToMScalar(yzC - xs),       // persp y
+                 SkDoubleToMScalar(z * zC + c));    // persp 2
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -211,7 +219,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 static inline SkMScalar det2x2(double m00, double m01, double m10, double m11) {
-    return m00 * m11 - m10 * m01;
+    return SkDoubleToMScalar(m00 * m11 - m10 * m01);
 }
 
 static inline double det3x3(double m00, double m01, double m02,
diff --git a/src/utils/SkNinePatch.cpp b/src/utils/SkNinePatch.cpp
index 6ee9684..9729a13 100644
--- a/src/utils/SkNinePatch.cpp
+++ b/src/utils/SkNinePatch.cpp
@@ -143,7 +143,7 @@
         stretchX = (bounds.width() - SkIntToScalar(fixed)) / numXStretch;
         if (stretchX < 0) {
             // reuse stretchX, but keep it negative as a signal
-            stretchX = -bitmap.width() / fixed;
+            stretchX = -SkIntToScalar(bitmap.width()) / fixed;
         }
     }
     
@@ -156,7 +156,7 @@
         stretchY = (bounds.height() - SkIntToScalar(fixed)) / numYStretch;
         if (stretchY < 0) {
             // reuse stretchY, but keep it negative as a signal
-            stretchY = -bitmap.height() / fixed;
+            stretchY = -SkIntToScalar(bitmap.height()) / fixed;
         }
     }
     
diff --git a/src/utils/win/SkIStream.cpp b/src/utils/win/SkIStream.cpp
index 8c9e180..fce015c 100644
--- a/src/utils/win/SkIStream.cpp
+++ b/src/utils/win/SkIStream.cpp
@@ -153,7 +153,7 @@
             hr = E_FAIL;
         } else {
             size_t skipped = this->fSkStream->skip(
-                liDistanceToMove.QuadPart
+                static_cast<size_t>(liDistanceToMove.QuadPart)
             );
             this->fLocation.QuadPart = skipped;
             if (skipped != liDistanceToMove.QuadPart) {
@@ -163,7 +163,9 @@
         break;
     }
     case STREAM_SEEK_CUR: {
-        size_t skipped = this->fSkStream->skip(liDistanceToMove.QuadPart);
+        size_t skipped = this->fSkStream->skip(
+            static_cast<size_t>(liDistanceToMove.QuadPart)
+        );
         this->fLocation.QuadPart += skipped;
         if (skipped != liDistanceToMove.QuadPart) {
             hr = E_FAIL;
@@ -176,7 +178,7 @@
         } else {
             LONGLONG skip = this->fSkStream->getLength()
                           + liDistanceToMove.QuadPart;
-            size_t skipped = this->fSkStream->skip(skip);
+            size_t skipped = this->fSkStream->skip(static_cast<size_t>(skip));
             this->fLocation.QuadPart = skipped;
             if (skipped != skip) {
                 hr = E_FAIL;
@@ -198,7 +200,7 @@
 HRESULT STDMETHODCALLTYPE SkIStream::Stat(STATSTG* pStatstg
                                         , DWORD grfStatFlag)
 {
-    if (0 == grfStatFlag & STATFLAG_NONAME) {
+    if (0 == (grfStatFlag & STATFLAG_NONAME)) {
         return STG_E_INVALIDFLAG;
     }
     pStatstg->pwcsName = NULL;
@@ -256,7 +258,7 @@
 HRESULT STDMETHODCALLTYPE SkWIStream::Stat(STATSTG* pStatstg
                                          , DWORD grfStatFlag)
 {
-    if (0 == grfStatFlag & STATFLAG_NONAME) {
+    if (0 == (grfStatFlag & STATFLAG_NONAME)) {
         return STG_E_INVALIDFLAG;
     }
     pStatstg->pwcsName = NULL;
diff --git a/src/utils/win/skia_win.cpp b/src/utils/win/skia_win.cpp
index 0fbc7fc..2643cc8 100644
--- a/src/utils/win/skia_win.cpp
+++ b/src/utils/win/skia_win.cpp
@@ -5,197 +5,197 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include <Windows.h>

-#include <tchar.h>

-#define MAX_LOADSTRING 100

-

-// Global Variables:

-HINSTANCE hInst;                            // current instance

-TCHAR szTitle[] = _T("SampleApp");          // The title bar text

-TCHAR szWindowClass[] = _T("SAMPLEAPP");    // the main window class name

-

-// Forward declarations of functions included in this code module:

-ATOM                MyRegisterClass(HINSTANCE hInstance);

-BOOL                InitInstance(HINSTANCE, int, LPTSTR);

-LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);

-INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

-

-int APIENTRY _tWinMain(HINSTANCE hInstance,

-                     HINSTANCE hPrevInstance,

-                     LPTSTR    lpCmdLine,

-                     int       nCmdShow)

-{

-    UNREFERENCED_PARAMETER(hPrevInstance);

-

-    MSG msg;

-

-    // Initialize global strings

-    MyRegisterClass(hInstance);

-

-    // Perform application initialization:

-    if (!InitInstance (hInstance, nCmdShow, lpCmdLine))

-    {

-        return FALSE;

-    }

-

-    // Main message loop:

-    while (GetMessage(&msg, NULL, 0, 0))

-    {

-        if (true)

-        {

-            TranslateMessage(&msg);

-            DispatchMessage(&msg);

-        }

-    }

-

-    return (int) msg.wParam;

-}

-

-

-

-//

-//  FUNCTION: MyRegisterClass()

-//

-//  PURPOSE: Registers the window class.

-//

-//  COMMENTS:

-//

-//    This function and its usage are only necessary if you want this code

-//    to be compatible with Win32 systems prior to the 'RegisterClassEx'

-//    function that was added to Windows 95. It is important to call this function

-//    so that the application will get 'well formed' small icons associated

-//    with it.

-//

-ATOM MyRegisterClass(HINSTANCE hInstance)

-{

-    WNDCLASSEX wcex;

-

-    wcex.cbSize = sizeof(WNDCLASSEX);

-

-    wcex.style            = CS_HREDRAW | CS_VREDRAW;

-    wcex.lpfnWndProc    = WndProc;

-    wcex.cbClsExtra        = 0;

-    wcex.cbWndExtra        = 0;

-    wcex.hInstance        = hInstance;

-    wcex.hIcon            = NULL;

-    wcex.hCursor        = NULL;

-    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);

-    wcex.lpszMenuName    = NULL;

-    wcex.lpszClassName    = szWindowClass;

-    wcex.hIconSm        = NULL;

-

-    return RegisterClassEx(&wcex);

-}

-

-#include "SkOSWindow_Win.h"

-extern SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv);

-

-static SkOSWindow* gSkWind;

-

-char* tchar_to_utf8(const TCHAR* str) {

-#ifdef _UNICODE

-    int size = WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), NULL, 0, NULL, NULL);

-    char* str8 = (char*) malloc(size+1);

-    WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), str8, size, NULL, NULL);

-    str8[size] = '\0';

-    return str8;

-#else

-    return strdup(str);

-#endif

-}

-

-//

-//   FUNCTION: InitInstance(HINSTANCE, int, LPTSTR)

-//

-//   PURPOSE: Saves instance handle and creates main window

-//

-//   COMMENTS:

-//

-//        In this function, we save the instance handle in a global variable and

-//        create and display the main program window.

-//

-

-

-BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPTSTR lpCmdLine)

-{

-   HWND hWnd;

-

-   hInst = hInstance; // Store instance handle in our global variable

-

-   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,

-      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

-

-   if (!hWnd)

-   {

-      return FALSE;

-   }

-

-   char* argv[4096];

-   int argc = 0;

-   TCHAR exename[1024], *next;

-   int exenameLen = GetModuleFileName(NULL, exename, 1024);

-   argv[argc++] = tchar_to_utf8(exename);

-   TCHAR* arg = _tcstok_s(lpCmdLine, _T(" "), &next);

-   while (arg != NULL) {

-      argv[argc++] = tchar_to_utf8(arg);

-      arg = _tcstok_s(NULL, _T(" "), &next);

-   }

-

-   gSkWind = create_sk_window(hWnd, argc, argv);

-   for (int i = 0; i < argc; ++i) {

-      free(argv[i]);

-   }

-

-   ShowWindow(hWnd, nCmdShow);

-   UpdateWindow(hWnd);

-

-   return TRUE;

-}

-

-//

-//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)

-//

-//  PURPOSE:  Processes messages for the main window.

-//

-//  WM_COMMAND    - process the application menu

-//  WM_PAINT    - Paint the main window

-//  WM_DESTROY    - post a quit message and return

-//

-//

-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

-{

-    switch (message) {

-    case WM_COMMAND:

-        return DefWindowProc(hWnd, message, wParam, lParam);

-    case WM_DESTROY:

-        PostQuitMessage(0);

-        break;

-    default:

-        if (gSkWind->wndProc(hWnd, message, wParam, lParam)) {

-            return 0;

-        } else {

-            return DefWindowProc(hWnd, message, wParam, lParam);

-        }

-    }

-    return 0;

-}

-

-// Message handler for about box.

-INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

-{

-    UNREFERENCED_PARAMETER(lParam);

-    switch (message)

-    {

-    case WM_INITDIALOG:

-        return (INT_PTR)TRUE;

-

-    case WM_COMMAND:

-        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)

-        {

-            EndDialog(hDlg, LOWORD(wParam));

-            return (INT_PTR)TRUE;

-        }

-        break;

-    }

-    return (INT_PTR)FALSE;

-}

+#include <Windows.h>
+#include <tchar.h>
+#define MAX_LOADSTRING 100
+
+// Global Variables:
+HINSTANCE hInst;                            // current instance
+TCHAR szTitle[] = _T("SampleApp");          // The title bar text
+TCHAR szWindowClass[] = _T("SAMPLEAPP");    // the main window class name
+
+// Forward declarations of functions included in this code module:
+ATOM                MyRegisterClass(HINSTANCE hInstance);
+BOOL                InitInstance(HINSTANCE, int, LPTSTR);
+LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
+
+int APIENTRY _tWinMain(HINSTANCE hInstance,
+                     HINSTANCE hPrevInstance,
+                     LPTSTR    lpCmdLine,
+                     int       nCmdShow)
+{
+    UNREFERENCED_PARAMETER(hPrevInstance);
+
+    MSG msg;
+
+    // Initialize global strings
+    MyRegisterClass(hInstance);
+
+    // Perform application initialization:
+    if (!InitInstance (hInstance, nCmdShow, lpCmdLine))
+    {
+        return FALSE;
+    }
+
+    // Main message loop:
+    while (GetMessage(&msg, NULL, 0, 0))
+    {
+        if (true)
+        {
+            TranslateMessage(&msg);
+            DispatchMessage(&msg);
+        }
+    }
+
+    return (int) msg.wParam;
+}
+
+
+
+//
+//  FUNCTION: MyRegisterClass()
+//
+//  PURPOSE: Registers the window class.
+//
+//  COMMENTS:
+//
+//    This function and its usage are only necessary if you want this code
+//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
+//    function that was added to Windows 95. It is important to call this function
+//    so that the application will get 'well formed' small icons associated
+//    with it.
+//
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+    WNDCLASSEX wcex;
+
+    wcex.cbSize = sizeof(WNDCLASSEX);
+
+    wcex.style            = CS_HREDRAW | CS_VREDRAW;
+    wcex.lpfnWndProc    = WndProc;
+    wcex.cbClsExtra        = 0;
+    wcex.cbWndExtra        = 0;
+    wcex.hInstance        = hInstance;
+    wcex.hIcon            = NULL;
+    wcex.hCursor        = NULL;
+    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
+    wcex.lpszMenuName    = NULL;
+    wcex.lpszClassName    = szWindowClass;
+    wcex.hIconSm        = NULL;
+
+    return RegisterClassEx(&wcex);
+}
+
+#include "SkOSWindow_Win.h"
+extern SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv);
+
+static SkOSWindow* gSkWind;
+
+char* tchar_to_utf8(const TCHAR* str) {
+#ifdef _UNICODE
+    int size = WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), NULL, 0, NULL, NULL);
+    char* str8 = (char*) malloc(size+1);
+    WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), str8, size, NULL, NULL);
+    str8[size] = '\0';
+    return str8;
+#else
+    return _strdup(str);
+#endif
+}
+
+//
+//   FUNCTION: InitInstance(HINSTANCE, int, LPTSTR)
+//
+//   PURPOSE: Saves instance handle and creates main window
+//
+//   COMMENTS:
+//
+//        In this function, we save the instance handle in a global variable and
+//        create and display the main program window.
+//
+
+
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPTSTR lpCmdLine)
+{
+   HWND hWnd;
+
+   hInst = hInstance; // Store instance handle in our global variable
+
+   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+   if (!hWnd)
+   {
+      return FALSE;
+   }
+
+   char* argv[4096];
+   int argc = 0;
+   TCHAR exename[1024], *next;
+   int exenameLen = GetModuleFileName(NULL, exename, 1024);
+   argv[argc++] = tchar_to_utf8(exename);
+   TCHAR* arg = _tcstok_s(lpCmdLine, _T(" "), &next);
+   while (arg != NULL) {
+      argv[argc++] = tchar_to_utf8(arg);
+      arg = _tcstok_s(NULL, _T(" "), &next);
+   }
+
+   gSkWind = create_sk_window(hWnd, argc, argv);
+   for (int i = 0; i < argc; ++i) {
+      free(argv[i]);
+   }
+
+   ShowWindow(hWnd, nCmdShow);
+   UpdateWindow(hWnd);
+
+   return TRUE;
+}
+
+//
+//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
+//
+//  PURPOSE:  Processes messages for the main window.
+//
+//  WM_COMMAND    - process the application menu
+//  WM_PAINT    - Paint the main window
+//  WM_DESTROY    - post a quit message and return
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message) {
+    case WM_COMMAND:
+        return DefWindowProc(hWnd, message, wParam, lParam);
+    case WM_DESTROY:
+        PostQuitMessage(0);
+        break;
+    default:
+        if (gSkWind->wndProc(hWnd, message, wParam, lParam)) {
+            return 0;
+        } else {
+            return DefWindowProc(hWnd, message, wParam, lParam);
+        }
+    }
+    return 0;
+}
+
+// Message handler for about box.
+INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    UNREFERENCED_PARAMETER(lParam);
+    switch (message)
+    {
+    case WM_INITDIALOG:
+        return (INT_PTR)TRUE;
+
+    case WM_COMMAND:
+        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+        {
+            EndDialog(hDlg, LOWORD(wParam));
+            return (INT_PTR)TRUE;
+        }
+        break;
+    }
+    return (INT_PTR)FALSE;
+}
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index f6054df..c952a61 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -174,7 +174,6 @@
 #endif
 
 		SkCanvas	rasterCanvas;
-        SkDevice*   device;
 
         if (NULL == canvas) {
             canvas = &rasterCanvas;