diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-09-29 18:08:18 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-09-29 18:08:18 +0000 |
commit | 9d12f5c11b56ef51ba2c95db721ae7e5bab27023 (patch) | |
tree | 61cce930350f9ca04a8beb8dea581033baf63b3b /src/utils | |
parent | 6f92f18b6266098a74cd90ff7b88328acc439d17 (diff) |
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
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/SkMatrix44.cpp | 22 | ||||
-rw-r--r-- | src/utils/SkNinePatch.cpp | 4 | ||||
-rw-r--r-- | src/utils/win/SkIStream.cpp | 12 | ||||
-rw-r--r-- | src/utils/win/skia_win.cpp | 388 |
4 files changed, 218 insertions, 208 deletions
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp index a57f9b117a..47478882b5 100644 --- a/src/utils/SkMatrix44.cpp +++ b/src/utils/SkMatrix44.cpp @@ -164,9 +164,9 @@ void SkMatrix44::setRotateAbout(SkMScalar x, SkMScalar y, SkMScalar z, 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 @@ void SkMatrix44::setRotateAboutUnit(SkMScalar x, SkMScalar y, SkMScalar z, 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 @@ void SkMatrix44::setConcat(const SkMatrix44& a, const SkMatrix44& b) { /////////////////////////////////////////////////////////////////////////////// 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 6ee96848a0..9729a13807 100644 --- a/src/utils/SkNinePatch.cpp +++ b/src/utils/SkNinePatch.cpp @@ -143,7 +143,7 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds, 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 @@ void SkNinePatch::DrawMesh(SkCanvas* canvas, const SkRect& bounds, 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 8c9e180b89..fce015cf21 100644 --- a/src/utils/win/SkIStream.cpp +++ b/src/utils/win/SkIStream.cpp @@ -153,7 +153,7 @@ HRESULT STDMETHODCALLTYPE SkIStream::Seek(LARGE_INTEGER liDistanceToMove 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 @@ HRESULT STDMETHODCALLTYPE SkIStream::Seek(LARGE_INTEGER liDistanceToMove 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 @@ HRESULT STDMETHODCALLTYPE SkIStream::Seek(LARGE_INTEGER liDistanceToMove } 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::Seek(LARGE_INTEGER liDistanceToMove 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::Commit(DWORD) { 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 0fbc7fc05c..2643cc8799 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; +} |