Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / skia / ext / vector_platform_device_emf_win.cc
index f77fbc8..1dd59d3 100644 (file)
@@ -73,7 +73,7 @@ SkBaseDevice* VectorPlatformDeviceEmf::create(HDC dc, int width, int height) {
   HGDIOBJ selected_bitmap = GetCurrentObject(dc, OBJ_BITMAP);
   bool succeeded = false;
   if (selected_bitmap != NULL) {
-    BITMAP bitmap_data;
+    BITMAP bitmap_data = {0};
     if (GetObject(selected_bitmap, sizeof(BITMAP), &bitmap_data) ==
         sizeof(BITMAP)) {
       // The context has a bitmap attached. Attach our SkBitmap to it.
@@ -117,10 +117,6 @@ HDC VectorPlatformDeviceEmf::BeginPlatformPaint() {
   return hdc_;
 }
 
-uint32_t VectorPlatformDeviceEmf::getDeviceCapabilities() {
-  return SkBitmapDevice::getDeviceCapabilities() | kVector_Capability;
-}
-
 void VectorPlatformDeviceEmf::drawPaint(const SkDraw& draw,
                                         const SkPaint& paint) {
   // TODO(maruel):  Bypass the current transformation matrix.
@@ -398,7 +394,7 @@ bool SkGDIFontSetup::useGDI(HDC hdc, const SkPaint& paint) {
     fSavedTextColor = GetTextColor(hdc);
     SetTextColor(hdc, skia::SkColorToCOLORREF(paint.getColor()));
 
-    LOGFONT lf;
+    LOGFONT lf = {0};
     SkLOGFONTFromTypeface(paint.getTypeface(), &lf);
     lf.lfHeight = -SkScalarRoundToInt(paint.getTextSize());
     fNewFont = CreateFontIndirect(&lf);
@@ -445,7 +441,7 @@ SK_API void SetSkiaEnsureTypefaceCharactersAccessible(
 
 void EnsureTypefaceCharactersAccessible(
     const SkTypeface& typeface, const wchar_t* text, unsigned int text_length) {
-  LOGFONT lf;
+  LOGFONT lf = {0};
   SkLOGFONTFromTypeface(&typeface, &lf);
   g_skia_ensure_typeface_characters_accessible(lf, text, text_length);
 }
@@ -461,7 +457,7 @@ bool EnsureExtTextOut(HDC hdc, int x, int y, UINT options, const RECT * lprect,
                                          characters);
       success = ExtTextOut(hdc, x, y, options, lprect, text, characters, lpDx);
       if (!success) {
-        LOGFONT lf;
+        LOGFONT lf = {0};
         SkLOGFONTFromTypeface(typeface, &lf);
         VLOG(1) << "SkFontHost::EnsureTypefaceCharactersAccessible FAILED for "
                 << " FaceName = " << lf.lfFaceName
@@ -524,9 +520,9 @@ void VectorPlatformDeviceEmf::drawPosText(const SkDraw& draw,
   SkGDIFontSetup setup;
   bool useDrawText = true;
 
-  if (2 == scalarsPerPos
-      && SkPaint::kUTF8_TextEncoding != paint.getTextEncoding()
-      && setup.useGDI(hdc_, paint)) {
+  if (scalarsPerPos == 2 && len >= 2 &&
+      SkPaint::kUTF8_TextEncoding != paint.getTextEncoding() &&
+      setup.useGDI(hdc_, paint)) {
     int startX = SkScalarRoundToInt(pos[0]);
     int startY = SkScalarRoundToInt(pos[1] + getAscent(paint));
     const int count = len >> 1;
@@ -536,6 +532,7 @@ void VectorPlatformDeviceEmf::drawPosText(const SkDraw& draw,
       advances[i] = SkScalarRoundToInt(pos[2] - pos[0]);
       pos += 2;
     }
+    advances[count - 1] = 0;
     useDrawText = !EnsureExtTextOut(hdc_, startX, startY,
         getTextOutOptions(paint), 0, reinterpret_cast<const wchar_t*>(text),
         count, advances, paint.getTypeface());
@@ -700,12 +697,21 @@ void VectorPlatformDeviceEmf::LoadClipRegion() {
   LoadClippingRegionToDC(hdc_, clip_region_, t);
 }
 
+#ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
 SkBaseDevice* VectorPlatformDeviceEmf::onCreateCompatibleDevice(
     SkBitmap::Config config, int width, int height, bool isOpaque,
     Usage /*usage*/) {
   SkASSERT(config == SkBitmap::kARGB_8888_Config);
   return VectorPlatformDeviceEmf::CreateDevice(width, height, isOpaque, NULL);
 }
+#endif
+
+SkBaseDevice* VectorPlatformDeviceEmf::onCreateDevice(const SkImageInfo& info,
+                                                      Usage /*usage*/) {
+  SkASSERT(info.colorType() == kPMColor_SkColorType);
+  return VectorPlatformDeviceEmf::CreateDevice(
+      info.width(), info.height(), info.isOpaque(), NULL);
+}
 
 bool VectorPlatformDeviceEmf::CreateBrush(bool use_brush, COLORREF color) {
   SkASSERT(previous_brush_ == NULL);
@@ -760,7 +766,7 @@ bool VectorPlatformDeviceEmf::CreatePen(bool use_pen,
   }
 
   // Load a custom pen.
-  LOGBRUSH brush;
+  LOGBRUSH brush = {0};
   brush.lbStyle = BS_SOLID;
   brush.lbColor = color;
   brush.lbHatch = 0;
@@ -892,8 +898,7 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap,
 
   // Create a BMP v4 header that we can serialize. We use the shared "V3"
   // fillter to fill the stardard items, then add in the "V4" stuff we want.
-  BITMAPV4HEADER bitmap_header;
-  memset(&bitmap_header, 0, sizeof(BITMAPV4HEADER));
+  BITMAPV4HEADER bitmap_header = {0};
   FillBitmapInfoHeader(src_size_x, src_size_y,
                        reinterpret_cast<BITMAPINFOHEADER*>(&bitmap_header));
   bitmap_header.bV4Size = sizeof(BITMAPV4HEADER);
@@ -925,7 +930,7 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap,
   }
 
   HDC dc = BeginPlatformPaint();
-  BITMAPINFOHEADER hdr;
+  BITMAPINFOHEADER hdr = {0};
   FillBitmapInfoHeader(src_size_x, src_size_y, &hdr);
   if (is_translucent) {
     // The image must be loaded as a bitmap inside a device context.