Bug 1223740 - enforce max surface size for DrawTargetSkia. r=bas

This commit is contained in:
Lee Salzman 2015-11-19 13:35:31 -05:00
parent 939265df10
commit 68e374cb22
5 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function boom() {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.shadowColor = "green";
ctx.rotate(0.9923);
ctx.transform(6, 0.13807760834183488, 256, -0.39007851257689263, 0.5767177072299453, 64);
ctx.transform(0.61, 0.08697788582345888, 6, 6, 64, 128);
ctx.scale(0.36690500480283633, 6);
ctx.shadowOffsetY = -1.7976931348623157e+308;
ctx.fillText("A",32,0.848476537933684);
}
</script>
</head>
<body onload="boom();"></body>
</html>

View File

@ -23,5 +23,6 @@ load 1099143-1.html
load 1161277-1.html
load 1183363.html
load 1190705.html
load 1223740-1.html
load 1225381-1.html
load texImage2D.html

View File

@ -830,6 +830,10 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
bool
DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
{
if (size_t(std::max(aSize.width, aSize.height)) > GetMaxSurfaceSize()) {
return false;
}
SkAlphaType alphaType = (aFormat == SurfaceFormat::B8G8R8X8) ?
kOpaque_SkAlphaType : kPremul_SkAlphaType;
@ -863,6 +867,10 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
{
MOZ_ASSERT(aGrContext, "null GrContext");
if (size_t(std::max(aSize.width, aSize.height)) > GetMaxSurfaceSize()) {
return false;
}
mGrContext = aGrContext;
mSize = aSize;
mFormat = aFormat;

View File

@ -117,6 +117,11 @@ public:
SurfaceFormat aFormat) override;
#endif
// Skia assumes that texture sizes fit in 16-bit signed integers.
static size_t GetMaxSurfaceSize() {
return 32767;
}
operator std::string() const {
std::stringstream stream;
stream << "DrawTargetSkia(" << this << ")";

View File

@ -507,7 +507,7 @@ Factory::GetMaxSurfaceSize(BackendType aType)
return DrawTargetCG::GetMaxSurfaceSize();
#endif
case BackendType::SKIA:
return INT_MAX;
return DrawTargetSkia::GetMaxSurfaceSize();
#ifdef WIN32
case BackendType::DIRECT2D:
return DrawTargetD2D::GetMaxSurfaceSize();