From 0e267ba5b2c2037a664f1d086fe4a1c6d6036e2c Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Tue, 25 Oct 2016 00:31:43 -0400 Subject: [PATCH] Bug 1306628 - Handle large sizes in GrResourceProvider::createBuffer. r=mchang MozReview-Commit-ID: 3ZGDmIum5OU --HG-- extra : rebase_source : 01be35ac1a6b192c4a7e30e022b3d692ad82138d --- gfx/skia/skia/src/gpu/GrResourceProvider.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gfx/skia/skia/src/gpu/GrResourceProvider.cpp b/gfx/skia/skia/src/gpu/GrResourceProvider.cpp index b63a7eaa458e..7518378ad72f 100644 --- a/gfx/skia/skia/src/gpu/GrResourceProvider.cpp +++ b/gfx/skia/skia/src/gpu/GrResourceProvider.cpp @@ -109,8 +109,11 @@ GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp } // bin by pow2 with a reasonable min - static const uint32_t MIN_SIZE = 1 << 12; - size_t allocSize = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size))); + static const size_t MIN_SIZE = 1 << 12; + size_t allocSize = size > (1u << 31) + ? size_t(SkTMin(uint64_t(SIZE_MAX), uint64_t(GrNextPow2(uint32_t(uint64_t(size) >> 32))) << 32)) + : size_t(GrNextPow2(uint32_t(size))); + allocSize = SkTMax(allocSize, MIN_SIZE); GrScratchKey key; GrBuffer::ComputeScratchKeyForDynamicVBO(allocSize, intendedType, &key);