gfx::Color is currently misused in many places. The DrawTargets expect
the color space to be in device space, e.g. what we are actually going
to draw using. Everything sitting above generally deals with sRGB, as
specified in CSS. Sometimes we missed the conversion from sRGB to device
space when issuing draw calls, and similarly sometimes we converted the
color to device space twice.
This patch splits the type in two. sRGBColor and DeviceColor now
represent sRGB and device color spaces respectively. DrawTarget only
accepts DeviceColor, and one can get a DeviceColor from an sRGBColor via
the ToDeviceColor helper API. The reftests now pass with color
management enabled for everything (e.g. CSS) instead of just tagged
raster images.
There will be a follow up patch to enable color management everywhere by
default on all supported platforms.
Differential Revision: https://phabricator.services.mozilla.com/D64771
--HG--
extra : moz-landing-system : lando
Only the parent process ever respects the renderroot attribute, so we can
add some extra early-exit checks for this. This also adds a bit of safety
for the next patch, to avoid inadvertently exposing renderroot stuff to
web content.
Also, the GetRenderRootForElement function is only ever called by the
GetRenderRootForFrame function, so let's scope it down to avoid doing
unnecessary work.
Differential Revision: https://phabricator.services.mozilla.com/D37504
--HG--
extra : moz-landing-system : lando
I wasn't able to produce a situation in which this change matters, so
I'm not certain that it's necessary, but it seems to be the correct
thing to do given the problem fixed in nsGfxScrollFrame.cpp.
Differential Revision: https://phabricator.services.mozilla.com/D31864
--HG--
extra : moz-landing-system : lando
`gfxUtils::WriteAsPNG()` is the only user of `nsIPresShell` in `gfx`, but
nobody calls it. So, we can get rid of it with `nsIPresShell` reference.
Differential Revision: https://phabricator.services.mozilla.com/D29310
--HG--
extra : moz-landing-system : lando
YUVColorSpace is inseparable from the bit depth as the matrix coefficients to be calculated need the bit depth information.
So let's put the two types together. gfx namespace also makes more sense as that's where we find IntRect, IntSize and other.
The extent of the changes highlight how much similar data structures are duplicated across the code, to the point it's scary.
Differential Revision: https://phabricator.services.mozilla.com/D25347
--HG--
extra : moz-landing-system : lando
ImageEncoder::ExtractDataInternal takes a `const nsAString&` for its
options, but flattens it into a null-terminated `nsString` so callees
can take a `char16_t*`. But nearly all of those callees eventually wind
up calling ImageEncoder::GetInputStream, which just constructs an
`nsDependentString` from the passed character pointer.
There's no reason to do all this extra work. We can just pass the
original options reference all the way through the stack and avoid
needless conversions.
Differential Revision: https://phabricator.services.mozilla.com/D26353
--HG--
extra : moz-landing-system : lando
We don't have lossy currentcolor in the style system anymore, except for a
single property -moz-font-smoothing-background-color.
I could've converted it into a proper StyleColor and thread down all the
necessary information to the font metrics code.
But it doesn't really seem worth it given it's not exposed to the web, so I just
did the simplest thing, which is making currentcolor compute to transparent to
that specific property.
This patch also removes the stores_complex_colors_lossily code and related,
since now we always can cache computed colors.
Differential Revision: https://phabricator.services.mozilla.com/D26187
--HG--
extra : moz-landing-system : lando
We don't have lossy currentcolor in the style system anymore, except for a
single property -moz-font-smoothing-background-color.
I could've converted it into a proper StyleColor and thread down all the
necessary information to the font metrics code.
But it doesn't really seem worth it given it's not exposed to the web, so I just
did the simplest thing, which is making currentcolor compute to transparent to
that specific property.
This patch also removes the stores_complex_colors_lossily code and related,
since now we always can cache computed colors.
Differential Revision: https://phabricator.services.mozilla.com/D26187
--HG--
extra : moz-landing-system : lando
This is a large patch that contains all of the core changes for
renderroot splitting.
Differential Revision: https://phabricator.services.mozilla.com/D20701
--HG--
extra : moz-landing-system : lando
This is a large patch that contains all of the core changes for
renderroot splitting.
Differential Revision: https://phabricator.services.mozilla.com/D20701
--HG--
extra : moz-landing-system : lando
gfxUtils::EncodeSourceSurface no longer uses a stringly-typed API to create a
`imgIEncoder` for the relevant MIME type. Instead, we now use an enum class and
switch on it to create the encoder.
Depends on D14816
Differential Revision: https://phabricator.services.mozilla.com/D14817
--HG--
extra : moz-landing-system : lando
The code in ComputeSuitableScaleForAnimation feeds its double-based
computation results into GetSuitableScale, which takes and returns
floats. Also the double-based computation that it's doing involves
calling UpdateMinMaxScale a bunch which explicitly uses the float
variant of std::min and std::max. And all of this is used from
ChooseScaleAndSetTransform which does other things like call a
"RoundToFloatPrecision" function, and casts the final values to
floats before setting the layer's prescale. So let's just use
floats all the way through.
MozReview-Commit-ID: BE3WC5hv89d
--HG--
extra : rebase_source : 987d9d69ec2a200ed68c59bae5fae1115713a94c
These functions need to survive the gfxRect purge as they are used in a
few places.
MozReview-Commit-ID: 1jGNlmAvV49
--HG--
extra : rebase_source : 0becc3b969063b5797502a3414dfd6573e82eee0
This is a largely uninteresting patch that just uses the DisplayListBuilder
directly. A wonderful cleanup patch will come after this. One of the more
interesting pieces is the use of PushBuiltDisplayList. This is needed for
handling empty transactions. See https://github.com/servo/webrender/pull/934
for more info.
This allows the GLContextProviderWGL to be created on the compositor
thread, which is something we need for webrender integration.
MozReview-Commit-ID: DtBe9nUTdK7
--HG--
extra : rebase_source : b31973542beca75255b64f350f47df16435a60e3
While fixing non-unified-build errors in dom/canvas, I started hitting a
static_assert that we were calling IsPowerOfTwo with a signed type. It
turns out we have at least three copies of IsPowerOfTwo() in the tree.
Let's drop the non-mfbt ones.
MozReview-Commit-ID: 1fwQw0CrgiE
This patch:
- Makes the following substitutions (plus necessary namespace qualifiers:
gfxImageFormat::ARGB32 --> SurfaceFormat::A8R8G8B8_UINT32
gfxImageFormat::RGB24 --> SurfaceFormat::X8R8G8B8_UINT32
gfxImageFormat::A8 --> SurfaceFormat::A8
gfxImageFormat::RGB16_565 --> SurfaceFormat::R5G6B5_UINT16
gfxImageFormat::Unknown --> SurfaceFormat::UNKNOWN
- Changes gfxImageFormat to be a typedef to gfx::SurfaceFormat. This will be
removed soon.
- Removes gfxCairoFormatToImageFormat() and gfxImageFormatToCairoFormat() and
replace calls to them with CairoFormatToGfxFormat() and
GfxFormatToCairoFormat().
- Removes ParamTraits<gfxImageFormat>.
- Add namespace qualifiers to SurfaceFormat instances where necessary.
--HG--
extra : rebase_source : f56e92b1593957a9e4e00171100bc7605816e696
This patch started life as making ImageEncoder.cpp:EncodingRunnable not
use nsAutoArrayPtr, but the API effects rippled out from there. On the
whole, I think using UniquePtr throughout has made the code clearer.
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout. The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.
CLOSED TREE makes big refactorings like this a piece of cake.
# The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
xargs perl -p -i -e '
s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
s/nsRefPtr ?</RefPtr</g; # handle declarations and variables
'
# Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h
# Handle nsRefPtr.h itself, a couple places that define constructors
# from nsRefPtr, and code generators specially. We do this here, rather
# than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
# things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
mfbt/nsRefPtr.h \
xpcom/glue/nsCOMPtr.h \
xpcom/base/OwningNonNull.h \
ipc/ipdl/ipdl/lower.py \
ipc/ipdl/ipdl/builtin.py \
dom/bindings/Codegen.py \
python/lldbutils/lldbutils/utils.py
# In our indiscriminate substitution above, we renamed
# nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'
if [ -d .git ]; then
git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi
--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
This commit was generated using the following script, executed at the
top level of a typical source code checkout.
# Don't modify select files in mfbt/ because it's not worth trying to
# tease out the dependencies currently.
#
# Don't modify anything in media/gmp-clearkey/0.1/ because those files
# use their own RefPtr, defined in their own RefCounted.h.
find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
grep -v 'mfbt/RefPtr.h' | \
grep -v 'mfbt/nsRefPtr.h' | \
grep -v 'mfbt/RefCounted.h' | \
grep -v 'media/gmp-clearkey/0.1/' | \
xargs perl -p -i -e '
s/mozilla::RefPtr/nsRefPtr/g; # handle declarations in headers
s/\bRefPtr</nsRefPtr</g; # handle local variables in functions
s#mozilla/RefPtr.h#mozilla/nsRefPtr.h#; # handle #includes
s#mfbt/RefPtr.h#mfbt/nsRefPtr.h#; # handle strange #includes
'
# |using mozilla::RefPtr;| is OK; |using nsRefPtr;| is invalid syntax.
find . -name '*.cpp' -o -name '*.mm' | xargs sed -i -e '/using nsRefPtr/d'
# RefPtr.h used |byRef| for dealing with COM-style outparams.
# nsRefPtr.h uses |getter_AddRefs|.
# Fixup that mismatch.
find . -name '*.cpp' -o -name '*.h'| \
xargs perl -p -i -e 's/byRef/getter_AddRefs/g'