aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/views/SkOSWindow_Win.h4
-rw-r--r--include/xml/SkXMLParser.h2
-rw-r--r--samplecode/SampleApp.cpp6
-rw-r--r--src/effects/SkGradientShader.cpp2
-rw-r--r--src/ports/SkFontHost_win.cpp7
-rw-r--r--src/ports/SkTime_win.cpp2
-rw-r--r--src/utils/SkParse.cpp2
-rw-r--r--src/utils/SkParsePath.cpp4
-rw-r--r--src/utils/win/SkOSWindow_Win.cpp213
-rw-r--r--src/views/SkWindow.cpp2
10 files changed, 233 insertions, 11 deletions
diff --git a/include/views/SkOSWindow_Win.h b/include/views/SkOSWindow_Win.h
index 6d821dbb46..0a70f75fd3 100644
--- a/include/views/SkOSWindow_Win.h
+++ b/include/views/SkOSWindow_Win.h
@@ -29,8 +29,8 @@ public:
static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
- static bool WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- static bool SkOSWindow::QuitOnDeactivate(HWND hWnd);
+ bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ static bool QuitOnDeactivate(HWND hWnd);
enum {
SK_WM_SkEvent = WM_APP + 1000,
diff --git a/include/xml/SkXMLParser.h b/include/xml/SkXMLParser.h
index ddad2732d8..7eccb02747 100644
--- a/include/xml/SkXMLParser.h
+++ b/include/xml/SkXMLParser.h
@@ -92,6 +92,7 @@ private:
void reportError(void* parser);
};
+#if 0
class SkXMLPullParser {
public:
SkXMLPullParser();
@@ -157,5 +158,6 @@ private:
struct Impl;
Impl* fImpl;
};
+#endif
#endif
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 84ce0d2d05..3947bdc832 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -11,7 +11,7 @@
#include "SampleCode.h"
-SkView* create_overview(int, const SkViewFactory*);
+extern SkView* create_overview(int, const SkViewFactory[]);
//#define SK_SUPPORT_GL
@@ -503,7 +503,7 @@ bool SampleWindow::onEvent(const SkEvent& evt) {
static void cleanup_for_filename(SkString* name) {
char* str = name->writable_str();
- for (int i = 0; i < name->size(); i++) {
+ for (size_t i = 0; i < name->size(); i++) {
switch (str[i]) {
case ':': str[i] = '-'; break;
case '/': str[i] = '-'; break;
@@ -741,7 +741,9 @@ void get_preferred_size(int* x, int* y, int* width, int* height) {
void application_init() {
// setenv("ANDROID_ROOT", "../../../data", 0);
+#ifdef SK_BUILD_FOR_MAC
setenv("ANDROID_ROOT", "/android/device/data", 0);
+#endif
SkGraphics::Init();
SkEvent::Init();
}
diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp
index f0850172ec..5a3a80ab16 100644
--- a/src/effects/SkGradientShader.cpp
+++ b/src/effects/SkGradientShader.cpp
@@ -490,7 +490,7 @@ static inline int SkFixedToFFFF(SkFixed x) {
}
static inline U16CPU bitsTo16(unsigned x, const unsigned bits) {
- SkASSERT(x < (1 << bits));
+ SkASSERT(x < (1U << bits));
if (6 == bits) {
return (x << 10) | (x << 4) | (x >> 2);
}
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 994b1b7ab4..4533d3c0e4 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -173,7 +173,8 @@ static const LOGFONT* get_default_font() {
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
- memcpy(&gDefaultFont, &(ncm.lfMessageFont), sizeof(LOGFONT));
+// lfMessageFont is garbage on my XP, so skip for now
+// memcpy(&gDefaultFont, &(ncm.lfMessageFont), sizeof(LOGFONT));
return &gDefaultFont;
}
@@ -248,8 +249,8 @@ SkScalerContext_Windows::SkScalerContext_Windows(const SkDescriptor* desc) : SkS
SetBkMode(ddc, TRANSPARENT);
// Perform the dpi adjustment.
- LONG lfHeight = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72);
- lf.lfHeight = lfHeight;
+ SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72);
+ lf.lfHeight = SkScalarRound(height);
font = CreateFontIndirect(&lf);
savefont = (HFONT)SelectObject(ddc, font);
}
diff --git a/src/ports/SkTime_win.cpp b/src/ports/SkTime_win.cpp
index 5194b028cb..49bb37d387 100644
--- a/src/ports/SkTime_win.cpp
+++ b/src/ports/SkTime_win.cpp
@@ -42,5 +42,5 @@ SkMSec SkTime::GetMSecs()
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
__int64 t = li.QuadPart; /* In 100-nanosecond intervals */
- return t / 10000; /* In milliseconds */
+ return (SkMSec)(t / 10000); /* In milliseconds */
}
diff --git a/src/utils/SkParse.cpp b/src/utils/SkParse.cpp
index df6691092b..69808a34c4 100644
--- a/src/utils/SkParse.cpp
+++ b/src/utils/SkParse.cpp
@@ -211,7 +211,7 @@ const char* SkParse::FindScalar(const char str[], SkScalar* value) {
str = skip_ws(str);
#ifdef SK_SCALAR_IS_FLOAT
char* stop;
- float v = ::strtof(str, &stop);
+ float v = (float)strtod(str, &stop);
if (str == stop) {
return NULL;
}
diff --git a/src/utils/SkParsePath.cpp b/src/utils/SkParsePath.cpp
index 2e8921d03e..6b3afca051 100644
--- a/src/utils/SkParsePath.cpp
+++ b/src/utils/SkParsePath.cpp
@@ -183,7 +183,11 @@ bool SkParsePath::FromSVGString(const char data[], SkPath* result) {
static void write_scalar(SkWStream* stream, SkScalar value) {
#ifdef SK_SCALAR_IS_FLOAT
char buffer[64];
+#ifdef SK_BUILD_FOR_WIN32
+ int len = sprintf(buffer, "%g", value);
+#else
int len = snprintf(buffer, sizeof(buffer), "%g", value);
+#endif
char* stop = buffer + len;
#else
char buffer[SkStrAppendScalar_MaxSize];
diff --git a/src/utils/win/SkOSWindow_Win.cpp b/src/utils/win/SkOSWindow_Win.cpp
new file mode 100644
index 0000000000..376c3bdfda
--- /dev/null
+++ b/src/utils/win/SkOSWindow_Win.cpp
@@ -0,0 +1,213 @@
+#include "SkTypes.h"
+
+#if defined(SK_BUILD_FOR_WIN)
+
+#include "SkWindow.h"
+#include "SkCanvas.h"
+#include "SkOSMenu.h"
+#include "SkTime.h"
+
+#include "SkGraphics.h"
+
+static SkOSWindow* gCurrOSWin;
+
+SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
+}
+
+static SkKey winToskKey(WPARAM vk) {
+ static const struct {
+ WPARAM fVK;
+ SkKey fKey;
+ } gPair[] = {
+ { VK_BACK, kBack_SkKey },
+ { VK_CLEAR, kBack_SkKey },
+ { VK_RETURN, kOK_SkKey },
+ { VK_UP, kUp_SkKey },
+ { VK_DOWN, kDown_SkKey },
+ { VK_LEFT, kLeft_SkKey },
+ { VK_RIGHT, kRight_SkKey }
+ };
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gPair); i++) {
+ if (gPair[i].fVK == vk) {
+ return gPair[i].fKey;
+ }
+ }
+ return kNONE_SkKey;
+}
+
+bool SkOSWindow::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
+ switch (message) {
+ case WM_KEYDOWN: {
+ SkKey key = winToskKey(wParam);
+ if (kNONE_SkKey != key) {
+ this->handleKey(key);
+ return true;
+ }
+ } break;
+ case WM_KEYUP: {
+ SkKey key = winToskKey(wParam);
+ if (kNONE_SkKey != key) {
+ this->handleKeyUp(key);
+ return true;
+ }
+ } break;
+ case WM_UNICHAR:
+ this->handleChar(lParam);
+ return true;
+ case WM_SIZE:
+ this->resize(lParam & 0xFFFF, lParam >> 16);
+ break;
+ case WM_PAINT: {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hWnd, &ps);
+ this->doPaint(hdc);
+ EndPaint(hWnd, &ps);
+ return true;
+ } break;
+ }
+ return false;
+}
+
+void SkOSWindow::doPaint(void* ctx) {
+ this->update(NULL);
+
+ HDC hdc = (HDC)ctx;
+ const SkBitmap& bitmap = this->getBitmap();
+
+ BITMAPINFO bmi;
+ memset(&bmi, 0, sizeof(bmi));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = bitmap.width();
+ bmi.bmiHeader.biHeight = -bitmap.height(); // top-down image
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biSizeImage = 0;
+
+ //
+ // Do the SetDIBitsToDevice.
+ //
+ bitmap.lockPixels();
+ int iRet = SetDIBitsToDevice(hdc,
+ 0, 0,
+ bitmap.width(), bitmap.height(),
+ 0, 0,
+ 0, bitmap.height(),
+ bitmap.getPixels(),
+ &bmi,
+ DIB_RGB_COLORS);
+ bitmap.unlockPixels();
+}
+
+#if 0
+void SkOSWindow::updateSize()
+{
+ RECT r;
+ GetWindowRect((HWND)this->getHWND(), &r);
+ this->resize(r.right - r.left, r.bottom - r.top);
+}
+#endif
+
+void SkOSWindow::onHandleInval(const SkIRect& r) {
+ RECT rect;
+ rect.left = r.fLeft;
+ rect.top = r.fTop;
+ rect.right = r.fRight;
+ rect.bottom = r.fBottom;
+ InvalidateRect((HWND)this->getHWND(), &rect, false);
+}
+
+void SkOSWindow::onAddMenu(const SkOSMenu* sk_menu)
+{
+}
+
+
+enum {
+ 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,
+ SK_Mac3Key = 0x55,
+ SK_Mac4Key = 0x56,
+ SK_Mac5Key = 0x57,
+ SK_Mac6Key = 0x58,
+ SK_Mac7Key = 0x59,
+ SK_Mac8Key = 0x5b,
+ SK_Mac9Key = 0x5c
+};
+
+static SkKey raw2key(uint32_t raw)
+{
+ static const struct {
+ uint32_t 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 },
+ { SK_Mac3Key, k3_SkKey },
+ { SK_Mac4Key, k4_SkKey },
+ { SK_Mac5Key, k5_SkKey },
+ { SK_Mac6Key, k6_SkKey },
+ { 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;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+void SkEvent::SignalNonEmptyQueue()
+{
+// post_skmacevent();
+// SkDebugf("signal nonempty\n");
+}
+
+//static void sk_timer_proc(TMTask* rec)
+//{
+// SkEvent::ServiceQueueTimer();
+// SkDebugf("timer task fired\n");
+//}
+
+void SkEvent::SignalQueueTimer(SkMSec delay)
+{
+#if 0
+ if (gTMTaskPtr)
+ {
+ RemoveTimeTask((QElem*)gTMTaskPtr);
+ DisposeTimerUPP(gTMTaskPtr->tmAddr);
+ gTMTaskPtr = nil;
+ }
+ if (delay)
+ {
+ gTMTaskPtr = &gTMTaskRec;
+ memset(gTMTaskPtr, 0, sizeof(gTMTaskRec));
+ gTMTaskPtr->tmAddr = NewTimerUPP(sk_timer_proc);
+ OSErr err = InstallTimeTask((QElem*)gTMTaskPtr);
+// SkDebugf("installtimetask of %d returned %d\n", delay, err);
+ PrimeTimeTask((QElem*)gTMTaskPtr, delay);
+ }
+#endif
+}
+
+#endif
+
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index c8403d46ae..b63b81a1c0 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -95,7 +95,7 @@ bool SkWindow::handleInval(const SkRect& r)
r.round(&ir);
fDirtyRgn.op(ir, SkRegion::kUnion_Op);
-#ifdef SK_BUILD_FOR_WIN32
+#ifdef SK_BUILD_FOR_WIN32xxxx
if (!fWaitingOnInval)
{
fWaitingOnInval = true;