summaryrefslogtreecommitdiffstats
path: root/gfx
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-05-10 11:50:47 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-05-10 11:50:47 +0200
commitbece236d81a519a51ae36ccac911365b2d94fedc (patch)
tree08d406dbe44f89d188485a93b3f14602e6041863 /gfx
parentb98c4ed80b389400df2792a49147d191e5bb9921 (diff)
parent04b3d5178c893bfb794c0053e559133f413250e7 (diff)
downloadUXP-bece236d81a519a51ae36ccac911365b2d94fedc.tar
UXP-bece236d81a519a51ae36ccac911365b2d94fedc.tar.gz
UXP-bece236d81a519a51ae36ccac911365b2d94fedc.tar.lz
UXP-bece236d81a519a51ae36ccac911365b2d94fedc.tar.xz
UXP-bece236d81a519a51ae36ccac911365b2d94fedc.zip
Merge branch 'ported-upstream'
Diffstat (limited to 'gfx')
-rw-r--r--gfx/skia/skia/src/core/SkMask.cpp7
-rw-r--r--gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp5
-rw-r--r--gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp9
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 111508074..b40b94974 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 e3f30b0c1..993e1c59d 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 9d73cf4f1..ec6c99c6e 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);