зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1540357 - Force -Werror for and fix implicit int truncation in dom/canvas. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D25495 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
51f2fbf355
Коммит
5c3e425117
|
@ -892,23 +892,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CanvasRenderingContext2D)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
CanvasRenderingContext2D::ContextState::ContextState()
|
||||
: textAlign(TextAlign::START),
|
||||
textBaseline(TextBaseline::ALPHABETIC),
|
||||
shadowColor(0),
|
||||
lineWidth(1.0f),
|
||||
miterLimit(10.0f),
|
||||
globalAlpha(1.0f),
|
||||
shadowBlur(0.0),
|
||||
dashOffset(0.0f),
|
||||
op(mozilla::gfx::CompositionOp::OP_OVER),
|
||||
fillRule(mozilla::gfx::FillRule::FILL_WINDING),
|
||||
lineCap(mozilla::gfx::CapStyle::BUTT),
|
||||
lineJoin(mozilla::gfx::JoinStyle::MITER_OR_BEVEL),
|
||||
filterString(u"none"),
|
||||
filterSourceGraphicTainted(false),
|
||||
imageSmoothingEnabled(true),
|
||||
fontExplicitLanguage(false) {}
|
||||
CanvasRenderingContext2D::ContextState::ContextState() = default;
|
||||
|
||||
CanvasRenderingContext2D::ContextState::ContextState(const ContextState& aOther)
|
||||
: fontGroup(aOther.fontGroup),
|
||||
|
|
|
@ -945,26 +945,27 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
|
|||
EnumeratedArray<Style, Style::MAX, nscolor> colorStyles;
|
||||
|
||||
nsString font;
|
||||
TextAlign textAlign;
|
||||
TextBaseline textBaseline;
|
||||
TextAlign textAlign = TextAlign::START;
|
||||
TextBaseline textBaseline = TextBaseline::ALPHABETIC;
|
||||
|
||||
nscolor shadowColor;
|
||||
nscolor shadowColor = 0;
|
||||
|
||||
mozilla::gfx::Matrix transform;
|
||||
mozilla::gfx::Point shadowOffset;
|
||||
mozilla::gfx::Float lineWidth;
|
||||
mozilla::gfx::Float miterLimit;
|
||||
mozilla::gfx::Float globalAlpha;
|
||||
mozilla::gfx::Float shadowBlur;
|
||||
mozilla::gfx::Float lineWidth = 1.0f;
|
||||
mozilla::gfx::Float miterLimit = 10.0f;
|
||||
mozilla::gfx::Float globalAlpha = 1.0f;
|
||||
mozilla::gfx::Float shadowBlur = 0.0f;
|
||||
|
||||
nsTArray<mozilla::gfx::Float> dash;
|
||||
mozilla::gfx::Float dashOffset;
|
||||
mozilla::gfx::Float dashOffset = 0.0f;
|
||||
|
||||
mozilla::gfx::CompositionOp op;
|
||||
mozilla::gfx::FillRule fillRule;
|
||||
mozilla::gfx::CapStyle lineCap;
|
||||
mozilla::gfx::JoinStyle lineJoin;
|
||||
mozilla::gfx::CompositionOp op = mozilla::gfx::CompositionOp::OP_OVER;
|
||||
mozilla::gfx::FillRule fillRule = mozilla::gfx::FillRule::FILL_WINDING;
|
||||
mozilla::gfx::CapStyle lineCap = mozilla::gfx::CapStyle::BUTT;
|
||||
mozilla::gfx::JoinStyle lineJoin = mozilla::gfx::JoinStyle::MITER_OR_BEVEL;
|
||||
|
||||
nsString filterString;
|
||||
nsString filterString = nsString(u"none");
|
||||
nsTArray<nsStyleFilter> filterChain;
|
||||
// RAII object that we obtain when we start to observer SVG filter elements
|
||||
// for rendering changes. When released we stop observing the SVG elements.
|
||||
|
@ -983,10 +984,10 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
|
|||
//
|
||||
// We keep track of this to ensure that if this gets out of sync with the
|
||||
// tainted state of the canvas itself, we update our filters accordingly.
|
||||
bool filterSourceGraphicTainted;
|
||||
bool filterSourceGraphicTainted = false;
|
||||
|
||||
bool imageSmoothingEnabled;
|
||||
bool fontExplicitLanguage;
|
||||
bool imageSmoothingEnabled = true;
|
||||
bool fontExplicitLanguage = false;
|
||||
};
|
||||
|
||||
AutoTArray<ContextState, 3> mStyleStack;
|
||||
|
|
|
@ -19,9 +19,9 @@ static __inline int32_t clamp255(int32_t v) {
|
|||
return (((255 - (v)) >> 31) | (v)) & 255;
|
||||
}
|
||||
|
||||
static __inline uint32_t Clamp(int32_t val) {
|
||||
int v = clamp0(val);
|
||||
return (uint32_t)(clamp255(v));
|
||||
static __inline uint8_t Clamp(int32_t val) {
|
||||
const auto v = clamp0(val);
|
||||
return uint8_t(clamp255(v));
|
||||
}
|
||||
|
||||
#define YG 74 /* (int8_t)(1.164 * 64 + 0.5) */
|
||||
|
@ -47,16 +47,16 @@ static __inline void YuvPixel(uint8_t y, uint8_t u, uint8_t v, uint8_t* b,
|
|||
*r = Clamp((int32_t)((u * UR + v * VR) - (BR) + y1) >> 6);
|
||||
}
|
||||
|
||||
static __inline int RGBToY(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return (66 * r + 129 * g + 25 * b + 0x1080) >> 8;
|
||||
static __inline uint8_t RGBToY(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return uint8_t((66 * r + 129 * g + 25 * b + 0x1080) >> 8);
|
||||
}
|
||||
|
||||
static __inline int RGBToU(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return (112 * b - 74 * g - 38 * r + 0x8080) >> 8;
|
||||
static __inline uint8_t RGBToU(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return uint8_t((112 * b - 74 * g - 38 * r + 0x8080) >> 8);
|
||||
}
|
||||
|
||||
static __inline int RGBToV(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return (112 * r - 94 * g - 18 * b + 0x8080) >> 8;
|
||||
static __inline uint8_t RGBToV(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return uint8_t((112 * r - 94 * g - 18 * b + 0x8080) >> 8);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -191,7 +191,7 @@ class Utils {
|
|||
uint8_t GetChannelCount() const { return mChannels; }
|
||||
|
||||
protected:
|
||||
Utils(uint32_t aChannels, ChannelPixelLayoutDataType aDataType)
|
||||
Utils(uint8_t aChannels, ChannelPixelLayoutDataType aDataType)
|
||||
: mChannels(aChannels),
|
||||
mBytesPerPixelValue(GetBytesPerPixelValue(aDataType)),
|
||||
mDataType(aDataType) {}
|
||||
|
|
|
@ -128,7 +128,7 @@ WebGLContext::WebGLContext()
|
|||
mNeedsFakeNoDepth(false),
|
||||
mNeedsFakeNoStencil(false),
|
||||
mAllowFBInvalidation(gfxPrefs::WebGLFBInvalidation()),
|
||||
mMsaaSamples(gfxPrefs::WebGLMsaaSamples()) {
|
||||
mMsaaSamples((uint8_t)gfxPrefs::WebGLMsaaSamples()) {
|
||||
mGeneration = 0;
|
||||
mInvalidated = false;
|
||||
mCapturedFrameInvalidated = false;
|
||||
|
|
|
@ -112,8 +112,8 @@ void WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b,
|
|||
const FuncScope funcScope(*this, "colorMask");
|
||||
if (IsContextLost()) return;
|
||||
|
||||
mColorWriteMask = uint8_t(bool(r)) << 0 | uint8_t(bool(g)) << 1 |
|
||||
uint8_t(bool(b)) << 2 | uint8_t(bool(a)) << 3;
|
||||
mColorWriteMask = uint8_t(bool(r) << 0) | uint8_t(bool(g) << 1) |
|
||||
uint8_t(bool(b) << 2) | uint8_t(bool(a) << 3);
|
||||
}
|
||||
|
||||
void WebGLContext::DepthMask(WebGLboolean b) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "WebGLContext.h"
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "WebGLBuffer.h"
|
||||
#include "WebGLFramebuffer.h"
|
||||
|
@ -401,7 +402,7 @@ void WebGLContext::VertexAttribAnyPointer(bool isFuncInt, GLuint index,
|
|||
}
|
||||
|
||||
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
|
||||
vd.VertexAttribPointer(isFuncInt, buffer, size, type, normalized, stride,
|
||||
vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type, normalized, stride,
|
||||
byteOffset);
|
||||
mBoundVertexArray->InvalidateCaches();
|
||||
}
|
||||
|
|
|
@ -521,9 +521,9 @@ MOZ_ALWAYS_INLINE void unpack<WebGLTexelFormat::RGB565, uint16_t, uint8_t>(
|
|||
uint8_t r = (packedValue >> 11) & 0x1F;
|
||||
uint8_t g = (packedValue >> 5) & 0x3F;
|
||||
uint8_t b = packedValue & 0x1F;
|
||||
dst[0] = (r << 3) | (r & 0x7);
|
||||
dst[1] = (g << 2) | (g & 0x3);
|
||||
dst[2] = (b << 3) | (b & 0x7);
|
||||
dst[0] = uint8_t(r << 3) | (r & 0x7);
|
||||
dst[1] = uint8_t(g << 2) | (g & 0x3);
|
||||
dst[2] = uint8_t(b << 3) | (b & 0x7);
|
||||
dst[3] = 0xFF;
|
||||
}
|
||||
|
||||
|
@ -564,10 +564,10 @@ MOZ_ALWAYS_INLINE void unpack<WebGLTexelFormat::RGBA4444, uint16_t, uint8_t>(
|
|||
uint8_t g = (packedValue >> 8) & 0x0F;
|
||||
uint8_t b = (packedValue >> 4) & 0x0F;
|
||||
uint8_t a = packedValue & 0x0F;
|
||||
dst[0] = (r << 4) | r;
|
||||
dst[1] = (g << 4) | g;
|
||||
dst[2] = (b << 4) | b;
|
||||
dst[3] = (a << 4) | a;
|
||||
dst[0] = uint8_t(r << 4) | r;
|
||||
dst[1] = uint8_t(g << 4) | g;
|
||||
dst[2] = uint8_t(b << 4) | b;
|
||||
dst[3] = uint8_t(a << 4) | a;
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -577,9 +577,9 @@ MOZ_ALWAYS_INLINE void unpack<WebGLTexelFormat::RGBA5551, uint16_t, uint8_t>(
|
|||
uint8_t r = (packedValue >> 11) & 0x1F;
|
||||
uint8_t g = (packedValue >> 6) & 0x1F;
|
||||
uint8_t b = (packedValue >> 1) & 0x1F;
|
||||
dst[0] = (r << 3) | (r & 0x7);
|
||||
dst[1] = (g << 3) | (g & 0x7);
|
||||
dst[2] = (b << 3) | (b & 0x7);
|
||||
dst[0] = uint8_t(r << 3) | (r & 0x7);
|
||||
dst[1] = uint8_t(g << 3) | (g & 0x7);
|
||||
dst[2] = uint8_t(b << 3) | (b & 0x7);
|
||||
dst[3] = (packedValue & 0x1) ? 0xFF : 0;
|
||||
}
|
||||
|
||||
|
@ -961,7 +961,7 @@ template <>
|
|||
MOZ_ALWAYS_INLINE void
|
||||
pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::None, uint8_t,
|
||||
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
|
||||
*dst = (((src[0] & 0xF8) << 8) | ((src[1] & 0xFC) << 3) |
|
||||
*dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xFC) << 3) |
|
||||
((src[2] & 0xF8) >> 3));
|
||||
}
|
||||
|
||||
|
@ -974,7 +974,7 @@ pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::Premultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = (((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
|
||||
}
|
||||
|
||||
// FIXME: this routine is lossy and must be removed.
|
||||
|
@ -987,7 +987,7 @@ pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::Unpremultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = (((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -1121,7 +1121,7 @@ template <>
|
|||
MOZ_ALWAYS_INLINE void
|
||||
pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::None, uint8_t,
|
||||
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
|
||||
*dst = (((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) | (src[2] & 0xF0) |
|
||||
*dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) | (src[2] & 0xF0) |
|
||||
(src[3] >> 4));
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::Premultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = (((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
|
||||
*dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
|
||||
(src[3] >> 4));
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::Unpremultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = (((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
|
||||
*dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
|
||||
(src[3] >> 4));
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ template <>
|
|||
MOZ_ALWAYS_INLINE void
|
||||
pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::None, uint8_t,
|
||||
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
|
||||
*dst = (((src[0] & 0xF8) << 8) | ((src[1] & 0xF8) << 3) |
|
||||
*dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xF8) << 3) |
|
||||
((src[2] & 0xF8) >> 2) | (src[3] >> 7));
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::Premultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = (((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
|
||||
(src[3] >> 7));
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1183,7 @@ pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::Unpremultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = (((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
|
||||
(src[3] >> 7));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
@ -260,7 +261,7 @@ Maybe<const WebGLTexture::CompletenessInfo> WebGLTexture::CalcCompletenessInfo(
|
|||
ret->incompleteReason = "Bad mipmap dimension or format.";
|
||||
return ret;
|
||||
}
|
||||
ret->levels = maxLevel - mBaseMipmapLevel + 1;
|
||||
ret->levels = AutoAssertCast(maxLevel - mBaseMipmapLevel + 1);
|
||||
ret->mipmapComplete = true;
|
||||
|
||||
// -
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
|
@ -269,7 +270,7 @@ class WebGLTexture final : public nsWrapperCache,
|
|||
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
||||
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
||||
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
||||
return rawTexImageTarget - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
return AutoAssertCast(rawTexImageTarget - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "gfxPrefs.h"
|
||||
#include "GLBlitHelper.h"
|
||||
#include "GLContext.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
|
@ -1124,7 +1125,7 @@ void WebGLTexture::TexStorage(TexTarget target, GLsizei levels,
|
|||
}
|
||||
|
||||
mImmutable = true;
|
||||
mImmutableLevelCount = levels;
|
||||
mImmutableLevelCount = AutoAssertCast(levels);
|
||||
ClampLevelBaseAndMax();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
// Most WebIDL typedefs are identical to their OpenGL counterparts.
|
||||
#include "GLTypes.h"
|
||||
#include "mozilla/Casting.h"
|
||||
|
||||
// Manual reflection of WebIDL typedefs that are different from their
|
||||
// OpenGL counterparts.
|
||||
|
@ -55,6 +56,30 @@ inline void* calloc(const ForbidNarrowing<size_t> n,
|
|||
return ::calloc(size_t(n), size_t(size));
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename From>
|
||||
class AutoAssertCastT final {
|
||||
const From mVal;
|
||||
|
||||
public:
|
||||
explicit AutoAssertCastT(const From val) : mVal(val) { }
|
||||
|
||||
template<typename To>
|
||||
operator To() const {
|
||||
return AssertedCast<To>(mVal);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename From>
|
||||
inline auto AutoAssertCast(const From val) {
|
||||
return detail::AutoAssertCastT<From>(val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementing WebGL (or OpenGL ES 2.0) on top of desktop OpenGL requires
|
||||
* emulating the vertex attrib 0 array when it's not enabled. Indeed,
|
||||
|
|
|
@ -217,3 +217,6 @@ LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
|
|||
|
||||
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
CXXFLAGS += ['-Wno-error=shadow', '-Wno-missing-braces']
|
||||
|
||||
if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'):
|
||||
CXXFLAGS += ['-Werror=implicit-int-conversion']
|
||||
|
|
Загрузка…
Ссылка в новой задаче