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
This commit is contained in:
parent
6f92f18b62
commit
9d12f5c11b
@ -103,7 +103,9 @@ protected:
|
||||
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();
|
||||
}
|
||||
|
@ -856,8 +856,8 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
|
||||
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 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
|
||||
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 @@ void GrContext::drawPath(const GrPaint& paint, const GrPath& path,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
uint8_t fKernelWidth;
|
||||
|
||||
inline bool isEnabled() const {
|
||||
return fOptFlags & kIsEnabled_OptFlagBit;
|
||||
return 0 != (fOptFlags & kIsEnabled_OptFlagBit);
|
||||
}
|
||||
inline void setEnabled(bool newValue) {
|
||||
if (newValue) {
|
||||
|
@ -432,7 +432,7 @@ void GrGpuGL::initCaps() {
|
||||
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);
|
||||
|
@ -238,7 +238,9 @@ bool GrGpuGLShaders::programUnitTest() {
|
||||
}
|
||||
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 @@ bool GrGpuGLShaders::programUnitTest() {
|
||||
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 @@ void GrGpuGLShaders::flushEdgeAAData() {
|
||||
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 @@ void GrGpuGLShaders::buildProgram(GrPrimitiveType type) {
|
||||
|
||||
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.
|
||||
|
@ -157,8 +157,8 @@ bool SkDisplayXMLParser::onAddAttributeLen(const char attrName[], const char att
|
||||
}
|
||||
|
||||
#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
|
||||
|
@ -603,7 +603,7 @@ scalarCommon:
|
||||
}
|
||||
if (ch == '.') {
|
||||
if (fTokenLength == 0) {
|
||||
SkScriptValue2 scriptValue;
|
||||
SkDEBUGCODE(SkScriptValue2 scriptValue);
|
||||
SkDEBUGCODE(scriptValue.fOperand.fObject = NULL);
|
||||
int tokenLength = token_length(++script);
|
||||
const char* token = script;
|
||||
|
@ -984,7 +984,8 @@ static bool drawWithMaskFilter(GrContext* context, const SkPath& path,
|
||||
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);
|
||||
|
||||
|
@ -67,7 +67,7 @@ void SkBitSet::setBit(int index, bool value) {
|
||||
|
||||
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) {
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -174,7 +174,6 @@ bool SkWindow::update(SkIRect* updateArea, SkCanvas* canvas)
|
||||
#endif
|
||||
|
||||
SkCanvas rasterCanvas;
|
||||
SkDevice* device;
|
||||
|
||||
if (NULL == canvas) {
|
||||
canvas = &rasterCanvas;
|
||||
|
Loading…
Reference in New Issue
Block a user