Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: skia/ext/vector_platform_device_emf_win.cc

Issue 122443005: replace deprecated SkScalarRound/Floor/Ceil calls with more explicit variants (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/ext/skia_utils_win.cc ('k') | skia/skia_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia/ext/vector_platform_device_emf_win.h" 5 #include "skia/ext/vector_platform_device_emf_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Draw the calculated path. 195 // Draw the calculated path.
196 drawPath(draw, path_modified, paint_no_effet); 196 drawPath(draw, path_modified, paint_no_effet);
197 return; 197 return;
198 } 198 }
199 199
200 if (!ApplyPaint(paint)) { 200 if (!ApplyPaint(paint)) {
201 return; 201 return;
202 } 202 }
203 HDC dc = BeginPlatformPaint(); 203 HDC dc = BeginPlatformPaint();
204 if (!Rectangle(dc, SkScalarRound(rect.fLeft), 204 if (!Rectangle(dc, SkScalarRoundToInt(rect.fLeft),
205 SkScalarRound(rect.fTop), 205 SkScalarRoundToInt(rect.fTop),
206 SkScalarRound(rect.fRight), 206 SkScalarRoundToInt(rect.fRight),
207 SkScalarRound(rect.fBottom))) { 207 SkScalarRoundToInt(rect.fBottom))) {
208 SkASSERT(false); 208 SkASSERT(false);
209 } 209 }
210 EndPlatformPaint(); 210 EndPlatformPaint();
211 Cleanup(); 211 Cleanup();
212 } 212 }
213 213
214 void VectorPlatformDeviceEmf::drawRRect(const SkDraw& draw, const SkRRect& rr, 214 void VectorPlatformDeviceEmf::drawRRect(const SkDraw& draw, const SkRRect& rr,
215 const SkPaint& paint) { 215 const SkPaint& paint) {
216 SkPath path; 216 SkPath path;
217 path.addRRect(rr); 217 path.addRRect(rr);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 SkASSERT(!fUseGDIHasBeenCalled); 393 SkASSERT(!fUseGDIHasBeenCalled);
394 SkDEBUGCODE(fUseGDIHasBeenCalled = true;) 394 SkDEBUGCODE(fUseGDIHasBeenCalled = true;)
395 395
396 fUseGDI = gdiCanHandleText(paint); 396 fUseGDI = gdiCanHandleText(paint);
397 if (fUseGDI) { 397 if (fUseGDI) {
398 fSavedTextColor = GetTextColor(hdc); 398 fSavedTextColor = GetTextColor(hdc);
399 SetTextColor(hdc, skia::SkColorToCOLORREF(paint.getColor())); 399 SetTextColor(hdc, skia::SkColorToCOLORREF(paint.getColor()));
400 400
401 LOGFONT lf; 401 LOGFONT lf;
402 SkLOGFONTFromTypeface(paint.getTypeface(), &lf); 402 SkLOGFONTFromTypeface(paint.getTypeface(), &lf);
403 lf.lfHeight = -SkScalarRound(paint.getTextSize()); 403 lf.lfHeight = -SkScalarRoundToInt(paint.getTextSize());
404 fNewFont = CreateFontIndirect(&lf); 404 fNewFont = CreateFontIndirect(&lf);
405 fSavedFont = (HFONT)::SelectObject(hdc, fNewFont); 405 fSavedFont = (HFONT)::SelectObject(hdc, fNewFont);
406 fHDC = hdc; 406 fHDC = hdc;
407 } 407 }
408 return fUseGDI; 408 return fUseGDI;
409 } 409 }
410 410
411 SkGDIFontSetup::~SkGDIFontSetup() { 411 SkGDIFontSetup::~SkGDIFontSetup() {
412 if (fUseGDI) { 412 if (fUseGDI) {
413 ::SelectObject(fHDC, fSavedFont); 413 ::SelectObject(fHDC, fSavedFont);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 SkScalar x, 481 SkScalar x,
482 SkScalar y, 482 SkScalar y,
483 const SkPaint& paint) { 483 const SkPaint& paint) {
484 SkGDIFontSetup setup; 484 SkGDIFontSetup setup;
485 bool useDrawPath = true; 485 bool useDrawPath = true;
486 486
487 if (SkPaint::kUTF8_TextEncoding != paint.getTextEncoding() 487 if (SkPaint::kUTF8_TextEncoding != paint.getTextEncoding()
488 && setup.useGDI(hdc_, paint)) { 488 && setup.useGDI(hdc_, paint)) {
489 UINT options = getTextOutOptions(paint); 489 UINT options = getTextOutOptions(paint);
490 UINT count = byteLength >> 1; 490 UINT count = byteLength >> 1;
491 useDrawPath = !EnsureExtTextOut(hdc_, SkScalarRound(x), 491 useDrawPath = !EnsureExtTextOut(hdc_, SkScalarRoundToInt(x),
492 SkScalarRound(y + getAscent(paint)), options, 0, 492 SkScalarRoundToInt(y + getAscent(paint)), options, 0,
493 reinterpret_cast<const wchar_t*>(text), count, NULL, 493 reinterpret_cast<const wchar_t*>(text), count, NULL,
494 paint.getTypeface()); 494 paint.getTypeface());
495 } 495 }
496 496
497 if (useDrawPath) { 497 if (useDrawPath) {
498 SkPath path; 498 SkPath path;
499 paint.getTextPath(text, byteLength, x, y, &path); 499 paint.getTextPath(text, byteLength, x, y, &path);
500 drawPath(draw, path, paint); 500 drawPath(draw, path, paint);
501 } 501 }
502 } 502 }
(...skipping 17 matching lines...) Expand all
520 const SkScalar pos[], 520 const SkScalar pos[],
521 SkScalar constY, 521 SkScalar constY,
522 int scalarsPerPos, 522 int scalarsPerPos,
523 const SkPaint& paint) { 523 const SkPaint& paint) {
524 SkGDIFontSetup setup; 524 SkGDIFontSetup setup;
525 bool useDrawText = true; 525 bool useDrawText = true;
526 526
527 if (2 == scalarsPerPos 527 if (2 == scalarsPerPos
528 && SkPaint::kUTF8_TextEncoding != paint.getTextEncoding() 528 && SkPaint::kUTF8_TextEncoding != paint.getTextEncoding()
529 && setup.useGDI(hdc_, paint)) { 529 && setup.useGDI(hdc_, paint)) {
530 int startX = SkScalarRound(pos[0]); 530 int startX = SkScalarRoundToInt(pos[0]);
531 int startY = SkScalarRound(pos[1] + getAscent(paint)); 531 int startY = SkScalarRoundToInt(pos[1] + getAscent(paint));
532 const int count = len >> 1; 532 const int count = len >> 1;
533 SkAutoSTMalloc<64, INT> storage(count); 533 SkAutoSTMalloc<64, INT> storage(count);
534 INT* advances = storage.get(); 534 INT* advances = storage.get();
535 for (int i = 0; i < count - 1; ++i) { 535 for (int i = 0; i < count - 1; ++i) {
536 advances[i] = SkScalarRound(pos[2] - pos[0]); 536 advances[i] = SkScalarRoundToInt(pos[2] - pos[0]);
537 pos += 2; 537 pos += 2;
538 } 538 }
539 useDrawText = !EnsureExtTextOut(hdc_, startX, startY, 539 useDrawText = !EnsureExtTextOut(hdc_, startX, startY,
540 getTextOutOptions(paint), 0, reinterpret_cast<const wchar_t*>(text), 540 getTextOutOptions(paint), 0, reinterpret_cast<const wchar_t*>(text),
541 count, advances, paint.getTypeface()); 541 count, advances, paint.getTypeface());
542 } 542 }
543 543
544 if (useDrawText) { 544 if (useDrawText) {
545 size_t (*bytesPerCodePoint)(const char*); 545 size_t (*bytesPerCodePoint)(const char*);
546 switch (paint.getTextEncoding()) { 546 switch (paint.getTextEncoding()) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 // Begin/end contours with a half square extension. 853 // Begin/end contours with a half square extension.
854 pen_style |= PS_ENDCAP_SQUARE; 854 pen_style |= PS_ENDCAP_SQUARE;
855 break; 855 break;
856 default: 856 default:
857 SkASSERT(false); 857 SkASSERT(false);
858 break; 858 break;
859 } 859 }
860 860
861 return CreatePen(use_pen, 861 return CreatePen(use_pen,
862 SkColorToCOLORREF(paint.getColor()), 862 SkColorToCOLORREF(paint.getColor()),
863 SkScalarRound(paint.getStrokeWidth()), 863 SkScalarRoundToInt(paint.getStrokeWidth()),
864 paint.getStrokeMiter(), 864 paint.getStrokeMiter(),
865 pen_style); 865 pen_style);
866 } 866 }
867 867
868 void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, 868 void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap,
869 int x, int y, 869 int x, int y,
870 const SkPaint& paint) { 870 const SkPaint& paint) {
871 unsigned char alpha = paint.getAlpha(); 871 unsigned char alpha = paint.getAlpha();
872 if (alpha == 0) 872 if (alpha == 0)
873 return; 873 return;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 pixels, 985 pixels,
986 reinterpret_cast<const BITMAPINFO*>(&hdr), 986 reinterpret_cast<const BITMAPINFO*>(&hdr),
987 DIB_RGB_COLORS, 987 DIB_RGB_COLORS,
988 SRCCOPY); 988 SRCCOPY);
989 } 989 }
990 EndPlatformPaint(); 990 EndPlatformPaint();
991 Cleanup(); 991 Cleanup();
992 } 992 }
993 993
994 } // namespace skia 994 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/skia_utils_win.cc ('k') | skia/skia_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698