mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Merge default into minor
--HG-- branch : minor
This commit is contained in:
@@ -264,7 +264,7 @@ QuadIndices::QuadIndices(size_t size)
|
|||||||
}
|
}
|
||||||
catch (std::bad_alloc &)
|
catch (std::bad_alloc &)
|
||||||
{
|
{
|
||||||
delete[] newbuffer;
|
delete newbuffer;
|
||||||
delete[] newindices;
|
delete[] newindices;
|
||||||
throw love::Exception("Out of memory.");
|
throw love::Exception("Out of memory.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ local ImageData = ImageData_mt.__index
|
|||||||
|
|
||||||
local tonumber, assert, error = tonumber, assert, error
|
local tonumber, assert, error = tonumber, assert, error
|
||||||
local type, pcall = type, pcall
|
local type, pcall = type, pcall
|
||||||
|
local floor = math.floor
|
||||||
|
|
||||||
local function inside(x, y, w, h)
|
local function inside(x, y, w, h)
|
||||||
return x >= 0 and x < w and y >= 0 and y < h
|
return x >= 0 and x < w and y >= 0 and y < h
|
||||||
@@ -204,6 +205,11 @@ function ImageData:_mapPixelUnsafe(func, ix, iy, iw, ih)
|
|||||||
local p = objectcache[self]
|
local p = objectcache[self]
|
||||||
local idw, idh = p.width, p.height
|
local idw, idh = p.width, p.height
|
||||||
|
|
||||||
|
ix = floor(ix)
|
||||||
|
iy = floor(iy)
|
||||||
|
iw = floor(iw)
|
||||||
|
ih = floor(ih)
|
||||||
|
|
||||||
local pixels = p.pointer
|
local pixels = p.pointer
|
||||||
local tolua = p.tolua
|
local tolua = p.tolua
|
||||||
local fromlua = p.fromlua
|
local fromlua = p.fromlua
|
||||||
@@ -221,6 +227,9 @@ function ImageData:getPixel(x, y)
|
|||||||
if type(x) ~= "number" then error("bad argument #1 to ImageData:getPixel (expected number)", 2) end
|
if type(x) ~= "number" then error("bad argument #1 to ImageData:getPixel (expected number)", 2) end
|
||||||
if type(y) ~= "number" then error("bad argument #2 to ImageData:getPixel (expected number)", 2) end
|
if type(y) ~= "number" then error("bad argument #2 to ImageData:getPixel (expected number)", 2) end
|
||||||
|
|
||||||
|
x = floor(x)
|
||||||
|
y = floor(y)
|
||||||
|
|
||||||
local p = objectcache[self]
|
local p = objectcache[self]
|
||||||
if not inside(x, y, p.width, p.height) then error("Attempt to get out-of-range pixel!", 2) end
|
if not inside(x, y, p.width, p.height) then error("Attempt to get out-of-range pixel!", 2) end
|
||||||
|
|
||||||
@@ -236,6 +245,9 @@ function ImageData:setPixel(x, y, r, g, b, a)
|
|||||||
if type(x) ~= "number" then error("bad argument #1 to ImageData:setPixel (expected number)", 2) end
|
if type(x) ~= "number" then error("bad argument #1 to ImageData:setPixel (expected number)", 2) end
|
||||||
if type(y) ~= "number" then error("bad argument #2 to ImageData:setPixel (expected number)", 2) end
|
if type(y) ~= "number" then error("bad argument #2 to ImageData:setPixel (expected number)", 2) end
|
||||||
|
|
||||||
|
x = floor(x)
|
||||||
|
y = floor(y)
|
||||||
|
|
||||||
if type(r) == "table" then
|
if type(r) == "table" then
|
||||||
local t = r
|
local t = r
|
||||||
r, g, b, a = t[1], t[2], t[3], t[4]
|
r, g, b, a = t[1], t[2], t[3], t[4]
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ local status, ffi = pcall(require, "ffi")
|
|||||||
if not status then return end
|
if not status then return end
|
||||||
|
|
||||||
local tonumber, assert, error = tonumber, assert, error
|
local tonumber, assert, error = tonumber, assert, error
|
||||||
|
local floor = math.floor
|
||||||
|
|
||||||
local float = ffi.typeof("float")
|
local float = ffi.typeof("float")
|
||||||
local datatypes = {ffi.typeof("uint8_t *"), ffi.typeof("int16_t *")}
|
local datatypes = {ffi.typeof("uint8_t *"), ffi.typeof("int16_t *")}
|
||||||
@@ -78,6 +79,8 @@ local objectcache = setmetatable({}, {
|
|||||||
function SoundData:getSample(i)
|
function SoundData:getSample(i)
|
||||||
if type(i) ~= "number" then error("bad argument #1 to SoundData:getSample (expected number)", 2) end
|
if type(i) ~= "number" then error("bad argument #1 to SoundData:getSample (expected number)", 2) end
|
||||||
|
|
||||||
|
i = floor(i)
|
||||||
|
|
||||||
local p = objectcache[self]
|
local p = objectcache[self]
|
||||||
|
|
||||||
if not (i >= 0 and i < p.size/p.bytedepth) then
|
if not (i >= 0 and i < p.size/p.bytedepth) then
|
||||||
@@ -97,6 +100,8 @@ function SoundData:setSample(i, sample)
|
|||||||
if type(i) ~= "number" then error("bad argument #1 to SoundData:setSample (expected number)", 2) end
|
if type(i) ~= "number" then error("bad argument #1 to SoundData:setSample (expected number)", 2) end
|
||||||
if type(sample) ~= "number" then error("bad argument #2 to SoundData:setSample (expected number)", 2) end
|
if type(sample) ~= "number" then error("bad argument #2 to SoundData:setSample (expected number)", 2) end
|
||||||
|
|
||||||
|
i = floor(i)
|
||||||
|
|
||||||
local p = objectcache[self]
|
local p = objectcache[self]
|
||||||
|
|
||||||
if not (i >= 0 and i < p.size/p.bytedepth) then
|
if not (i >= 0 and i < p.size/p.bytedepth) then
|
||||||
|
|||||||
Reference in New Issue
Block a user