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

Unified Diff: src/core/SkDraw.cpp

Issue 1012763002: Test for glyphs which straddle the edge of device space. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Check full range if ranges are to be checked. Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index ef268bfed341452e3414243f5bba093d9128d888..bbe99f557077dc79e53a6d5bbf143acf740580d5 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -33,7 +33,6 @@
#include "SkDrawProcs.h"
#include "SkMatrixUtils.h"
-
//#define TRACE_BITMAP_DRAWS
@@ -1444,6 +1443,15 @@ void SkDraw::drawText_asPaths(const char text[], size_t byteLength,
//////////////////////////////////////////////////////////////////////////////
static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, const SkGlyph& glyph) {
+ // Prevent glyphs from being drawn outside of or straddling the edge of device space.
+ if ((fx >> 16) > INT_MAX - (INT16_MAX + UINT16_MAX) ||
+ (fx >> 16) < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) ||
+ (fy >> 16) > INT_MAX - (INT16_MAX + UINT16_MAX) ||
+ (fy >> 16) < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/))
+ {
+ return;
+ }
+
int left = Sk48Dot16FloorToInt(fx);
int top = Sk48Dot16FloorToInt(fy);
SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698