diff options
author | Lee Salzman <lsalzman@mozilla.com> | 2018-04-29 20:10:51 -0400 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-05-10 11:47:03 +0200 |
commit | 04b3d5178c893bfb794c0053e559133f413250e7 (patch) | |
tree | 08d406dbe44f89d188485a93b3f14602e6041863 /gfx | |
parent | dc7515e3d7456201d5d841a6561dd565d23eaebd (diff) | |
download | uxp-04b3d5178c893bfb794c0053e559133f413250e7.tar.gz |
Bug 1454692 - Backport some upstream Skia fixes to ESR52. r=rhunt, a=abillings
--HG--
extra : histedit_source : 0fcd64cabe6f54a2286083d6518e4e6451183a19%2C37f5e7f9dbbfc01102631c33b23329d2af5aa71b
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/skia/skia/src/core/SkMask.cpp | 7 | ||||
-rw-r--r-- | gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp | 5 | ||||
-rw-r--r-- | gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp | 9 |
3 files changed, 17 insertions, 4 deletions
diff --git a/gfx/skia/skia/src/core/SkMask.cpp b/gfx/skia/skia/src/core/SkMask.cpp index 111508074a..b40b94974c 100644 --- a/gfx/skia/skia/src/core/SkMask.cpp +++ b/gfx/skia/skia/src/core/SkMask.cpp @@ -43,7 +43,12 @@ uint8_t* SkMask::AllocImage(size_t size) { #ifdef TRACK_SKMASK_LIFETIME SkDebugf("SkMask::AllocImage %d\n", gCounter++); #endif - return (uint8_t*)sk_malloc_throw(SkAlign4(size)); + size_t aligned_size = std::numeric_limits<size_t>::max(); + size_t adjustment = 3; + if (size + adjustment > size) { + aligned_size = (size + adjustment) & ~adjustment; + } + return static_cast<uint8_t*>(sk_malloc_throw(aligned_size)); } /** We explicitly use this allocator for SkBimap pixels, so that we can diff --git a/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp b/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp index e3f30b0c1c..993e1c59dc 100644 --- a/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp +++ b/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp @@ -14,6 +14,7 @@ #include "GrResourceProvider.h" #include "GrTypes.h" +#include "SkSafeMath.h" #include "SkTraceEvent.h" #ifdef SK_DEBUG @@ -335,7 +336,7 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, SkASSERT(startVertex); size_t offset = 0; // assign to suppress warning - void* ptr = INHERITED::makeSpace(vertexSize * vertexCount, + void* ptr = INHERITED::makeSpace(SkSafeMath::Mul(vertexSize, vertexCount), vertexSize, buffer, &offset); @@ -360,7 +361,7 @@ void* GrIndexBufferAllocPool::makeSpace(int indexCount, SkASSERT(startIndex); size_t offset = 0; // assign to suppress warning - void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t), + void* ptr = INHERITED::makeSpace(SkSafeMath::Mul(indexCount, sizeof(uint16_t)), sizeof(uint16_t), buffer, &offset); diff --git a/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp index 9d73cf4f17..ec6c99c6ef 100644 --- a/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp +++ b/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp @@ -828,6 +828,13 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const { int lineCount = lines.count() / 2; int conicCount = conics.count() / 3; + int quadAndConicCount = conicCount + quadCount; + + static constexpr int kMaxLines = SK_MaxS32 / kLineSegNumVertices; + static constexpr int kMaxQuadsAndConics = SK_MaxS32 / kQuadNumVertices; + if (lineCount > kMaxLines || quadAndConicCount > kMaxQuadsAndConics) { + return; + } // do lines first if (lineCount) { @@ -899,7 +906,7 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const { ref_quads_index_buffer(target->resourceProvider())); size_t vertexStride = sizeof(BezierVertex); - int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * conicCount; + int vertexCount = kQuadNumVertices * quadAndConicCount; void *vertices = target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex); |