platform/upstream/libSkiaSharp.git
8 years agoRemove uniform color for GrDistanceFieldGeoProc
joshualitt [Thu, 10 Dec 2015 15:29:54 +0000 (07:29 -0800)]
Remove uniform color for GrDistanceFieldGeoProc

BUG=skia:

Review URL: https://codereview.chromium.org/1512533003

8 years agoadd path ops presentations to skia.org
caryclark [Thu, 10 Dec 2015 14:29:44 +0000 (06:29 -0800)]
add path ops presentations to skia.org

TBR=hcm@google.com
NOTRY=true
DOCS_PREVIEW= https://skia.org/?cl=1518453003

Review URL: https://codereview.chromium.org/1518453003

8 years agoMake NVPR a GL context option instead of a GL context
kkinnunen [Thu, 10 Dec 2015 14:28:13 +0000 (06:28 -0800)]
Make NVPR a GL context option instead of a GL context

Make NVPR a GL context option instead of a GL context.
This may enable NVPR to be run with command buffer
interface.

No functionality change in DM or nanobench. NVPR can
only be run with normal GL APIs.

BUG=skia:2992

Committed: https://skia.googlesource.com/skia/+/eeebdb538d476c1bfc8b63a946094ca1b505ecd1

Committed: https://skia.googlesource.com/skia/+/64492c43c3faee7ab0f69b1c84e0267616f85e52

Review URL: https://codereview.chromium.org/1448883002

8 years agoUse a pseudo-extension CHROMIUM_framebuffer_mixed_samples
kkinnunen [Thu, 10 Dec 2015 09:21:59 +0000 (01:21 -0800)]
Use a pseudo-extension CHROMIUM_framebuffer_mixed_samples

Use the pseudo-extension CHROMIUM_framebuffer_mixed_samples when
run with Chromium command buffer. The extension exposes
NV_framebuffer_mixed_samples subset that Skia needs in order to
use NV_path_rendering with mixed samples.

BUG=506765

Review URL: https://codereview.chromium.org/1507373004

8 years agoPopulate NVPR functions when run with command buffer
kkinnunen [Thu, 10 Dec 2015 06:58:34 +0000 (22:58 -0800)]
Populate NVPR functions when run with command buffer

Populate the NV_path_rendering functions provided by
CHROMIUM_path_rendering when the tools are being run with
command buffer API.

BUG=skia:2992

Review URL: https://codereview.chromium.org/1510163003

8 years agoDo elliptical clips in normalized space on devices with a "real" mediump
bsalomon [Thu, 10 Dec 2015 01:14:40 +0000 (17:14 -0800)]
Do elliptical clips in normalized space on devices with a "real" mediump

BUG=chromium:477684

Review URL: https://codereview.chromium.org/1517573002

8 years agoMake "alpha only" be a property of GrTextureProducer
bsalomon [Thu, 10 Dec 2015 01:06:02 +0000 (17:06 -0800)]
Make "alpha only" be a property of GrTextureProducer

Review URL: https://codereview.chromium.org/1507973005

8 years agoUse BRGA as internal format on later iOS
jvanverth [Thu, 10 Dec 2015 00:54:35 +0000 (16:54 -0800)]
Use BRGA as internal format on later iOS

BUG=skia:2733

Review URL: https://codereview.chromium.org/1504333007

8 years agoanother memcpy -> sk_careful_memcpy
mtklein [Thu, 10 Dec 2015 00:20:25 +0000 (16:20 -0800)]
another memcpy -> sk_careful_memcpy

https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/3791/steps/dm/logs/stdio

This is getting tedious.

TBR=herb@google.com,reed@google.com
No API changes.

BUG=skia:

Review URL: https://codereview.chromium.org/1510223003

8 years agoadd support for capped hairlines
caryclark [Wed, 9 Dec 2015 22:04:46 +0000 (14:04 -0800)]
add support for  capped hairlines

Extend the ends of hairline and haircurve segments when the paint is set to square or round, and the line or curve is at the start or end of a contour.

R=reed@google.com
BUG=skia:4599

Review URL: https://codereview.chromium.org/1491843006

8 years agoSilence libjpeg warnings in SkImageDecoder
scroggo [Wed, 9 Dec 2015 21:40:34 +0000 (13:40 -0800)]
Silence libjpeg warnings in SkImageDecoder

We just did the same for libpng (see crrev.com/1512043002), so we
might as well do this here.

SkImageDecoder is deprecated, and SkCodec already has a way to turn
off its messages.

BUG=skia:1649

Review URL: https://codereview.chromium.org/1505953007

8 years agoAnother undefined shift caught by -fsanitize=shift.
mtklein [Wed, 9 Dec 2015 21:32:58 +0000 (13:32 -0800)]
Another undefined shift caught by -fsanitize=shift.

left was -16

I didn't see any warning about fTop, but seems simplest to fix that too.

BUG=skia:

Review URL: https://codereview.chromium.org/1505993007

8 years agoAnother memcpy -> sk_careful_memcpy
mtklein [Wed, 9 Dec 2015 21:15:07 +0000 (13:15 -0800)]
Another memcpy -> sk_careful_memcpy

https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/3787/steps/dm/logs/stdio

dst is null.
TBR=herb@google.com

BUG=skia:

Review URL: https://codereview.chromium.org/1507113007

8 years agono need for newlines in DM Errors
mtklein [Wed, 9 Dec 2015 21:02:26 +0000 (13:02 -0800)]
no need for newlines in DM Errors

This should fix some odd formatting problems in the logs, e.g.

    Note tally:
    583x   (skipped: Cannot convert to requested color type.
    )
    4x     (--blacklist _ image decode 4bpp-pixeldata-cropped.bmp)

~~~>

    Note tally:
    583x   (skipped: Cannot convert to requested color type.)
    4x     (--blacklist _ image decode 4bpp-pixeldata-cropped.bmp)

BUG=skia:

Review URL: https://codereview.chromium.org/1508223006

8 years agoFix compile error with GOOGLE3 define.
benjaminwagner [Wed, 9 Dec 2015 20:51:20 +0000 (12:51 -0800)]
Fix compile error with GOOGLE3 define.

BUG=skia:

Review URL: https://codereview.chromium.org/1509023004

8 years agoRewrite drawBitmap/ImageNine on top of GrTextureProducer
bsalomon [Wed, 9 Dec 2015 20:50:56 +0000 (12:50 -0800)]
Rewrite drawBitmap/ImageNine on top of GrTextureProducer

Review URL: https://codereview.chromium.org/1504723004

8 years agoMake skia_sanitizer work on Macs too.
mtklein [Wed, 9 Dec 2015 20:39:01 +0000 (12:39 -0800)]
Make skia_sanitizer work on Macs too.

This is of course limited by what the compiler suppports.
-fsanitize=address seems to work OK.

BUG=skia:

Review URL: https://codereview.chromium.org/1512853005

8 years agoRemove no-op code in SkAlphaRuns::add
scroggo [Wed, 9 Dec 2015 20:33:21 +0000 (12:33 -0800)]
Remove no-op code in SkAlphaRuns::add

The old code says

        runs += x + 1;
        alpha += x + 1;
        x = 0;
        lastAlpha += x; // we don't want the +1

The last line does nothing. Remove this unnecessary line.

BUG=skia:401

Review URL: https://codereview.chromium.org/1506253002

8 years agoFix problem with flag unknown to clang. This negates an earlier -Werror causing warni...
herb [Wed, 9 Dec 2015 20:27:31 +0000 (12:27 -0800)]
Fix problem with flag unknown to clang. This negates an earlier -Werror causing warnings to be errors.

BUG=skia:

Review URL: https://codereview.chromium.org/1515653002

8 years agoSilence libpng warnings in SkImageDecoder
msarett [Wed, 9 Dec 2015 20:12:56 +0000 (12:12 -0800)]
Silence libpng warnings in SkImageDecoder

BUG=skia:

Review URL: https://codereview.chromium.org/1512043002

8 years agoubsan shift fixes
caryclark [Wed, 9 Dec 2015 20:02:30 +0000 (12:02 -0800)]
ubsan shift fixes

Use an inline function that does a normal shift. When built for the sanitizer, add casts so that the shift is unsigned.

Also make a few fixes to do unsigned shifts or avoid the shift altogether; and add an argument spec to some macros.

R=reed@google.com,mtklein@google.com
BUG=skia:4633

Review URL: https://codereview.chromium.org/1503423003

8 years agoSkBitmap::installPixels(const SkPixmap&);
halcanary [Wed, 9 Dec 2015 19:36:59 +0000 (11:36 -0800)]
SkBitmap::installPixels(const SkPixmap&);

Review URL: https://codereview.chromium.org/1505333002

8 years agoPrevent overflow in length() in GLCircularRRectEffect
bsalomon [Wed, 9 Dec 2015 18:33:51 +0000 (10:33 -0800)]
Prevent overflow in length() in GLCircularRRectEffect

BUG=chromium:477684

Review URL: https://codereview.chromium.org/1517483002

8 years agoSkBitmap::getColor repsects swizzle
halcanary [Wed, 9 Dec 2015 18:21:59 +0000 (10:21 -0800)]
SkBitmap::getColor repsects swizzle

Review URL: https://codereview.chromium.org/1510253002

8 years agoSplit big rrect aa effect up into separate images
bsalomon [Wed, 9 Dec 2015 18:17:35 +0000 (10:17 -0800)]
Split big rrect aa effect up into separate images

Needed to enlarge radii to surface bugs without exceeding max texture size on low end devices.

BUG=chromium:477684

Review URL: https://codereview.chromium.org/1508003008

8 years agoFix filter primitive bounds computations.
senorblanco [Wed, 9 Dec 2015 18:11:43 +0000 (10:11 -0800)]
Fix filter primitive bounds computations.

Make each filter responsible for expanding its destination
bounds. Previously, we were using a union of all
intermediate bounds sizes via join() calls in many image
filters' computeFastBounds(), due to the fact that those
filters could only produce bitmaps the same size as their
inputs. Now, we compute optimal bounds for each filter as
follows:

1) Pass the (unmodified) clip bounds to the root node
of the DAG in the first recursive call to onFilterImage()
as the Context's fClipBounds.

2) Reverse-map the clip: when recursing up the DAG in
filterInput[GPU](), apply filter-specific expansion to the
clip by calling calling onFilterNodeBounds(... kReverse).
This allows upstream nodes to have a clip that respects the
current node's requirements. This is done via helper
function mapContext().

3) Forward-map the source bitmap: just prior to applying
the crop rect in applyCropRect(), we determine the filter's
preferred bounds by mapping the source bitmap bounds
forwards via onFilterNodeBounds(..., kForward).

NOTE: GMs affected by this change:
fast_slow_blurimagefilter: fast and slow paths now produce the same result
spritebitmap: drawSprite() and drawBitmap() paths now produce the same result
filterfastbounds: fast bounds are optimized; all drop-shadow results now appear
apply-filter: snug and not-snug cases give same results
dropshadowimagefilter: drawSprite() results now show shadows
draw-with-filter: no artifacts on erode edges; blur edges no longer clipped
displacement, imagefiltersbase, imagefiltersclipped, imagefilterscropexpand, imagefiltersscaled, matriximagefilter,
resizeimagefilter, localmatriximagefilter, testimagefilters: fixed incorrect clipping
imagefilterstransformed, morphology: no artifacts on erode edges

BUG=skia:1062,skia:3194,skia:3939,skia:4337,skia:4526

Review URL: https://codereview.chromium.org/1308703007

8 years agofix a couple flaky nonnull attribute ubsan warnings
mtklein [Wed, 9 Dec 2015 18:02:14 +0000 (10:02 -0800)]
fix a couple flaky nonnull attribute ubsan warnings

Errors this should fix:
  https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/3779/steps/dm/logs/stdio
  https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/3779/steps/nanobench/logs/stdio

CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot

TBR=reed@google.com
No API changes.

BUG=skia:

Review URL: https://codereview.chromium.org/1504313005

8 years agoFix bug with GrAtlasTextContext color regen
joshualitt [Wed, 9 Dec 2015 17:26:44 +0000 (09:26 -0800)]
Fix bug with GrAtlasTextContext color regen

BUG=skia:

Review URL: https://codereview.chromium.org/1513723002

8 years agoDM: tally notes at the end rather than showing them as they finish.
mtklein [Wed, 9 Dec 2015 16:37:35 +0000 (08:37 -0800)]
DM: tally notes at the end rather than showing them as they finish.

This should make the (veto) and (skipped: ) both less verbose and easier to grok.

Looks like this'll bring the log files down from ~50M to ~1.5M.

BUG=skia:

Review URL: https://codereview.chromium.org/1516563002

8 years agoBoost GrGLConicEffect's variables to all high precision
robertphillips [Wed, 9 Dec 2015 15:54:24 +0000 (07:54 -0800)]
Boost GrGLConicEffect's variables to all high precision

BUG=555779

Committed: https://skia.googlesource.com/skia/+/624c59a1c7af38eb83e803f345a6f3e225475a08

Review URL: https://codereview.chromium.org/1513483002

8 years agotry stifling integer overflow error
mtklein [Wed, 9 Dec 2015 15:24:10 +0000 (07:24 -0800)]
try stifling integer overflow error

first time we've done this, let's see if it works!

BUG=skia:4667

Looks ok now.  Red ASAN bot is different errors.

Review URL: https://codereview.chromium.org/1507063007

8 years agoCap filtering to kMedium_SkFilterQuality when downsampling
fmalita [Wed, 9 Dec 2015 15:18:16 +0000 (07:18 -0800)]
Cap filtering to kMedium_SkFilterQuality when downsampling

R=reed@google.com

Review URL: https://codereview.chromium.org/1510673002

8 years agoRevert of Boost GrGLConicEffect's variables to all high precision (patchset #1 id...
robertphillips [Wed, 9 Dec 2015 15:09:21 +0000 (07:09 -0800)]
Revert of Boost GrGLConicEffect's variables to all high precision (patchset #1 id:1 of https://codereview.chromium.org/1513483002/ )

Reason for revert:
Broke build

Original issue's description:
> Boost GrGLConicEffect's variables to all high precision
>
> BUG=555779
>
> Committed: https://skia.googlesource.com/skia/+/624c59a1c7af38eb83e803f345a6f3e225475a08

TBR=egdaniel@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=555779

Review URL: https://codereview.chromium.org/1514553002

8 years agoRevert of Make NVPR a GL context option instead of a GL context (patchset #9 id:16000...
borenet [Wed, 9 Dec 2015 15:03:51 +0000 (07:03 -0800)]
Revert of Make NVPR a GL context option instead of a GL context (patchset #9 id:160001 of https://codereview.chromium.org/1448883002/ )

Reason for revert:
"Could not create surface" on Linux GTX660 bots

Original issue's description:
> Make NVPR a GL context option instead of a GL context
>
> Make NVPR a GL context option instead of a GL context.
> This may enable NVPR to be run with command buffer
> interface.
>
> No functionality change in DM or nanobench. NVPR can
> only be run with normal GL APIs.
>
> BUG=skia:2992
>
> Committed: https://skia.googlesource.com/skia/+/eeebdb538d476c1bfc8b63a946094ca1b505ecd1
>
> Committed: https://skia.googlesource.com/skia/+/64492c43c3faee7ab0f69b1c84e0267616f85e52

TBR=mtklein@google.com,bsalomon@google.com,jvanverth@google.com,scroggo@google.com,kkinnunen@nvidia.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:2992

Review URL: https://codereview.chromium.org/1513703002

8 years agoA small text cleanup
joshualitt [Wed, 9 Dec 2015 14:42:52 +0000 (06:42 -0800)]
A small text cleanup

BUG=skia:

Review URL: https://codereview.chromium.org/1508853005

8 years agoBoost GrGLConicEffect's variables to all high precision
robertphillips [Wed, 9 Dec 2015 14:28:06 +0000 (06:28 -0800)]
Boost GrGLConicEffect's variables to all high precision

BUG=555779

Review URL: https://codereview.chromium.org/1513483002

8 years agoAttempt to land cache purge again [and regen bot logs if still failing]
bsalomon [Wed, 9 Dec 2015 14:27:59 +0000 (06:27 -0800)]
Attempt to land cache purge again [and regen bot logs if still failing]

TBR=

Review URL: https://codereview.chromium.org/1510103002

8 years agoRevert of default SkPixelSerializer (patchset #2 id:20001 of https://codereview.chrom...
halcanary [Wed, 9 Dec 2015 11:56:02 +0000 (03:56 -0800)]
Revert of default SkPixelSerializer (patchset #2 id:20001 of https://codereview.chromium.org/1507123002/ )

Reason for revert:
I was overconfident.

Original issue's description:
> default SkPixelSerializer
>
> Add SkImageEncoder::EncodeData(const SkPixmap&, ...) function.
>
> Add SkImageEncoder::CreatePixelSerializer() to return a
> PixelSerializer that calls into SkImageEncoder::EncodeData.
>
> SkImage::encode() make use of SkImageEncoder::CreatePixelSerializer.
>
> Committed: https://skia.googlesource.com/skia/+/b0bd1516bff3f5afcbfd615e805867531657811b
>
> Committed: https://skia.googlesource.com/skia/+/808ce2886d732b1055f89c8fb0f1b11b47fcb0ce

TBR=reed@google.com,scroggo@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1511183002

8 years agoUse correct config variable in command buffer gl context
kkinnunen [Wed, 9 Dec 2015 07:52:40 +0000 (23:52 -0800)]
Use correct config variable in command buffer gl context

Use correct config variable in command buffer gl context.
Before, the fConfig was errorneously used to initialize the
local variable. eglChooseConfig would update the local variable
and the fConfig member variable would never be updated.

Also add error checks to all initialization function calls.

BUG=skia:

Review URL: https://codereview.chromium.org/1505233002

8 years agodefault SkPixelSerializer
halcanary [Wed, 9 Dec 2015 03:02:36 +0000 (19:02 -0800)]
default SkPixelSerializer

Add SkImageEncoder::EncodeData(const SkPixmap&, ...) function.

Add SkImageEncoder::CreatePixelSerializer() to return a
PixelSerializer that calls into SkImageEncoder::EncodeData.

SkImage::encode() make use of SkImageEncoder::CreatePixelSerializer.

Committed: https://skia.googlesource.com/skia/+/b0bd1516bff3f5afcbfd615e805867531657811b

Review URL: https://codereview.chromium.org/1507123002

8 years ago[SkDebugger] Show more text blob details
fmalita [Wed, 9 Dec 2015 02:59:18 +0000 (18:59 -0800)]
[SkDebugger] Show more text blob details

 * run count
 * glyph count (per run)
 * run paint (per run)

R=robertphillips@google.com

Review URL: https://codereview.chromium.org/1507033003

8 years agoRemove spew in GrDefaultPathRenderer
joshualitt [Wed, 9 Dec 2015 02:58:48 +0000 (18:58 -0800)]
Remove spew in GrDefaultPathRenderer

TBR=bsalomon@google.com
BUG=skia:

Review URL: https://codereview.chromium.org/1509913003

8 years agoMake SkCodec support peek() and read()
scroggo [Wed, 9 Dec 2015 02:54:13 +0000 (18:54 -0800)]
Make SkCodec support peek() and read()

- Update SkCodec's dox to point out that some of the data must be
  read twice in order to decode
- Add an accessor that reports how much is needed for reading twice
- Make SkCodec default to use peek()
  If an input stream supports peek()ing, peek() instead of reading.
  This way the stream need not implement rewind()
- Make SkCodec use read() + rewind() as a backup
  So that streams without peek() implemented can still function
  properly (assuming they can rewind).
- read everything we may need to determine the format once
  In SkCodec::NewFromStream, peek()/read() 14 bytes, which is enough
  to read all of the types we support. Pass the buffer to each subtype,
  which will have enough info to determine whether it is the right
  type. This simplifies the code and results in less reading and
  rewinding.
  - NOTE: SkWbmpCodec needs the following number of bytes for the header
    + 1 (type)
    + 1 (reserved)
    + 3 (width - bytes needed to support up to 0xFFFF)
    + 3 (height - bytes needed to support up to 0xFFFF)
    = 8
- in SkWebpCodec, support using read + rewind as a backup if peek does
  not work.

A change in Android will add peek() to JavaInputStreamAdapter.

BUG=skia:3257

Review URL: https://codereview.chromium.org/1472123002

8 years agoMove texture drawing utility method to SkGpuDevice
jvanverth [Wed, 9 Dec 2015 02:53:44 +0000 (18:53 -0800)]
Move texture drawing utility method to SkGpuDevice

BUG=skia:4542

Review URL: https://codereview.chromium.org/1506203002

8 years agoAdd RTTI to all sanitizers.
herb [Wed, 9 Dec 2015 02:49:04 +0000 (18:49 -0800)]
Add RTTI to all sanitizers.

BUG=skia:

Review URL: https://codereview.chromium.org/1510843003

8 years agoRemove staging for SkImageDecoder::Peeker
scroggo [Wed, 9 Dec 2015 02:48:38 +0000 (18:48 -0800)]
Remove staging for SkImageDecoder::Peeker

Will no longer be needed once ag/817367 lands - Android will be
inheriting directly from SkPngChunkReader, so no need for the
intermediate.

BUG=skia:4574

Review URL: https://codereview.chromium.org/1470913004

8 years agoDisable sanitizers with a blacklist.
mtklein [Tue, 8 Dec 2015 22:26:17 +0000 (14:26 -0800)]
Disable sanitizers with a blacklist.

We think this might be more flexible.  It allows, e.g, function-level blacklisting,
and here an easy one-stop-shop blacklist for all of third_party/externals.

BUG=skia:

CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot
NOTREECHECKS=true

Review URL: https://codereview.chromium.org/1509733003

8 years agoAdd sk_careful_memcpy to catch undefined behavior in memcpy.
mtklein [Tue, 8 Dec 2015 19:55:17 +0000 (11:55 -0800)]
Add sk_careful_memcpy to catch undefined behavior in memcpy.

It's undefined behavior to pass null as src or dst to memcpy, even if len is 0.
This currently triggers -fsanitize=attribute-nonnull warnings, but also can
lead to very unexpected code generation with GCC.

sk_careful_memcpy() checks len first before calling memcpy(),
which prevents that weird undefined situation.

This allows me to mark all sanitizers as no-recover, i.e. make-the-bots-red fatal.

CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot

BUG=skia:4641
NOTREECHECKS=true

Review URL: https://codereview.chromium.org/1510683002

8 years agoRevert of default SkPixelSerializer (patchset #1 id:1 of https://codereview.chromium...
reed [Tue, 8 Dec 2015 18:59:13 +0000 (10:59 -0800)]
Revert of default SkPixelSerializer (patchset #1 id:1 of https://codereview.chromium.org/1507123002/ )

Reason for revert:
Breaking DEPS roll (linker error)

Original issue's description:
> default SkPixelSerializer
>
> Add SkImageEncoder::EncodeData(const SkPixmap&, ...) function.
>
> Add SkImageEncoder::CreatePixelSerializer() to return a
> PixelSerializer that calls into SkImageEncoder::EncodeData.
>
> SkImage::encode() make use of SkImageEncoder::CreatePixelSerializer.
>
> Committed: https://skia.googlesource.com/skia/+/b0bd1516bff3f5afcbfd615e805867531657811b

TBR=scroggo@google.com,halcanary@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1505203003

8 years agoStop wrapping images backed by generators as bitmaps in SkGpuDevice (except when...
bsalomon [Tue, 8 Dec 2015 18:53:43 +0000 (10:53 -0800)]
Stop wrapping images backed by generators as bitmaps in SkGpuDevice (except when tiling)

Review URL: https://codereview.chromium.org/1510903002

8 years agospin off remaining integer overflow fixes
mtklein [Tue, 8 Dec 2015 18:53:01 +0000 (10:53 -0800)]
spin off remaining integer overflow fixes

  - Carmack rsqrt uses an int where it wants a uint32_t.
  - turn off all santizers (including signed-integer-overflow) in third_party/externals/sftntly.

CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot

BUG=skia:4635

Review URL: https://codereview.chromium.org/1511643002

8 years agoImprove nvpr glyph batching
cdalton [Tue, 8 Dec 2015 18:48:31 +0000 (10:48 -0800)]
Improve nvpr glyph batching

Batches together path range draws whose view matrices differ by a
simple translation by pre-translating the individual path transforms
during the copy.

BUG=skia:

Review URL: https://codereview.chromium.org/1507203002

8 years agoAllow LCD text to batch across colorchanges. This will always use
joshualitt [Tue, 8 Dec 2015 18:47:55 +0000 (10:47 -0800)]
Allow LCD text to batch across colorchanges.  This will always use
color vertices, even when we can't batch across color changes

BUG=skia:

Review URL: https://codereview.chromium.org/1502253003

8 years agodefault SkPixelSerializer
halcanary [Tue, 8 Dec 2015 18:29:58 +0000 (10:29 -0800)]
default SkPixelSerializer

Add SkImageEncoder::EncodeData(const SkPixmap&, ...) function.

Add SkImageEncoder::CreatePixelSerializer() to return a
PixelSerializer that calls into SkImageEncoder::EncodeData.

SkImage::encode() make use of SkImageEncoder::CreatePixelSerializer.

Review URL: https://codereview.chromium.org/1507123002

8 years agoRemove drawPathsFromRange from GrDrawContext
cdalton [Tue, 8 Dec 2015 18:20:32 +0000 (10:20 -0800)]
Remove drawPathsFromRange from GrDrawContext

Replaces drawPathsFromRange with a more general drawPathBatch method.
While this still isn't perfect, it's a step in the right direction that
removes the need for path range draws to fit in a public API.

BUG=skia:

Review URL: https://codereview.chromium.org/1506823004

8 years agosimplify the way we disable sanitizers for yasm
mtklein [Tue, 8 Dec 2015 18:04:42 +0000 (10:04 -0800)]
simplify the way we disable sanitizers for yasm

seems to work fine

CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot

BUG=skia:

Review URL: https://codereview.chromium.org/1505013003

8 years agoEnable gpudft on GalaxyS3
joshualitt [Tue, 8 Dec 2015 17:14:01 +0000 (09:14 -0800)]
Enable gpudft on GalaxyS3

BUG=skia:

Review URL: https://codereview.chromium.org/1509193002

8 years agoLoosen check for zero vectors in GrPathUtils::convert_noninflect_cubic_to_quads
robertphillips [Tue, 8 Dec 2015 13:19:12 +0000 (05:19 -0800)]
Loosen check for zero vectors in GrPathUtils::convert_noninflect_cubic_to_quads

In the repro case the conic in question has a replicated control point at the end. These points end up being slightly different by the time they get to convert_noninflect_cubic_to_quads so the initial checks for a zero vector don't fire. The following checks, in the constrainWithinTangents path, do fire however leading to a premature termination of conversion to quads.

BUG=skia:4611

Review URL: https://codereview.chromium.org/1504983003

8 years agoZero length lines may have caps, but do not need joins.
caryclark [Tue, 8 Dec 2015 12:29:45 +0000 (04:29 -0800)]
Zero length lines may have caps, but do not need joins.

Check to see if the point is preceeded or followed
by a line with a computable tangent before adding the join.

R=reed@google.com
BUG=566075

Review URL: https://codereview.chromium.org/1504043002

8 years agoMake NVPR a GL context option instead of a GL context
kkinnunen [Tue, 8 Dec 2015 09:24:40 +0000 (01:24 -0800)]
Make NVPR a GL context option instead of a GL context

Make NVPR a GL context option instead of a GL context.
This may enable NVPR to be run with command buffer
interface.

No functionality change in DM or nanobench. NVPR can
only be run with normal GL APIs.

BUG=skia:2992

Committed: https://skia.googlesource.com/skia/+/eeebdb538d476c1bfc8b63a946094ca1b505ecd1

Review URL: https://codereview.chromium.org/1448883002

8 years agoUse correct fill type and bounds for NVPR paths that are stroked with Skia
kkinnunen [Tue, 8 Dec 2015 07:39:01 +0000 (23:39 -0800)]
Use correct fill type and bounds for NVPR paths that are stroked with Skia

When using NVPR, sometimes paths must be stroked by Skia and then drawn
with fill using NVPR. In these cases, use the fill type and bounds of
the stroked path, not the original path.

Fixes degeneratesegments for nvprmsaa backends.

BUG=skia:4608

Review URL: https://codereview.chromium.org/1504753003

8 years agoSkPNGImageEncoder encodes all SkColorTypes
halcanary [Mon, 7 Dec 2015 22:07:31 +0000 (14:07 -0800)]
SkPNGImageEncoder encodes all SkColorTypes

Review URL: https://codereview.chromium.org/1506663002

8 years agoRemove SK_IGNORE_GL_TEXTURE_TARGET from skia_for_chromium_defines.gypi
bsalomon [Mon, 7 Dec 2015 22:05:31 +0000 (14:05 -0800)]
Remove SK_IGNORE_GL_TEXTURE_TARGET from skia_for_chromium_defines.gypi

This has been added to Chrome's SkUserConfig.h

Review URL: https://codereview.chromium.org/1503173003

8 years agofix funky formatting in SkNVRefCnt
mtklein [Mon, 7 Dec 2015 21:37:00 +0000 (13:37 -0800)]
fix funky formatting in SkNVRefCnt

BUG=skia:
TBR=reed@google.com
No API change.

Review URL: https://codereview.chromium.org/1505023002

8 years agoWhen was SkPDiff last used?
mtklein [Mon, 7 Dec 2015 21:27:32 +0000 (13:27 -0800)]
When was SkPDiff last used?

BUG=skia:1451,skia:1463,skia:1798,skia:1859,skia:2710,skia:2711,skia:2712,skia:2713

Review URL: https://codereview.chromium.org/1502173003

8 years agoMake GrAtlasTextBlob non-virtual
joshualitt [Mon, 7 Dec 2015 21:26:31 +0000 (13:26 -0800)]
Make GrAtlasTextBlob non-virtual

BUG=skia:

Review URL: https://codereview.chromium.org/1503213003

8 years agoMinor code cleanups in SkCanvas.
senorblanco [Mon, 7 Dec 2015 20:51:30 +0000 (12:51 -0800)]
Minor code cleanups in SkCanvas.

Since the SK_SAVE_LAYER_BOUNDS_ARE_FILTERED path is long gone from
SkCanvas, remove or localize some temporary variables.

Cleanup only; no user-visible changes.

BUG=skia:

Review URL: https://codereview.chromium.org/1508823002

8 years agoSkPixelSerializer: support indexed pixels
halcanary [Mon, 7 Dec 2015 20:42:24 +0000 (12:42 -0800)]
SkPixelSerializer: support indexed pixels

By taking a SkPixmap, SkPixelSerializer::encode() can now handle colortables.

Review URL: https://codereview.chromium.org/1501303002

8 years agoadd signed-integer-overflow to yasm exceptions
mtklein [Mon, 7 Dec 2015 20:33:13 +0000 (12:33 -0800)]
add signed-integer-overflow to yasm exceptions

BUG=skia:4635

CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot

Review URL: https://codereview.chromium.org/1509613002

8 years agoA small cleanup of GrAtlasTextContext
joshualitt [Mon, 7 Dec 2015 20:26:12 +0000 (12:26 -0800)]
A small cleanup of GrAtlasTextContext

BUG=skia:

Review URL: https://codereview.chromium.org/1502323002

8 years agofix coincident fuzzer
caryclark [Mon, 7 Dec 2015 20:18:02 +0000 (12:18 -0800)]
fix coincident fuzzer

This fuzzer has very large Y values that cause the
points to sort incorrectly by t. Exit out as soon
as this is detected.

TBR=reed@google.com
BUG=561121

Review URL: https://codereview.chromium.org/1507803002

8 years agoSimplify D1G so that it can inline DrawOneGlyph, and fix a bug in codegen
herb [Mon, 7 Dec 2015 20:12:29 +0000 (12:12 -0800)]
Simplify D1G so that it can inline DrawOneGlyph, and fix a bug in codegen
that only happens on ARM64 using GCC 4.9.

Review URL: https://codereview.chromium.org/1507633004

8 years agoSkImageShaderFactoryToName SkAlphaThresholdFilterFactoryToName
halcanary [Mon, 7 Dec 2015 20:02:33 +0000 (12:02 -0800)]
SkImageShaderFactoryToName SkAlphaThresholdFilterFactoryToName

https://gold.skia.org/diff?test=image-shader&left=8807a80c69a5d565821432fe6a7b74ec&top=80222191bf0768b0fc62c8e05b58fb5f

https://gold.skia.org/diff?test=imagealphathreshold&left=fc3fbbfbd1b1e7ec1c33c00c6c22b9a8&top=493096aac6f44b91cd6522c6049d5a56

BUG=skia:4613

Review URL: https://codereview.chromium.org/1499443002

8 years agoAllow SkStream::peek() to partially succeed
scroggo [Mon, 7 Dec 2015 19:37:13 +0000 (11:37 -0800)]
Allow SkStream::peek() to partially succeed

If the stream can peek less than requested, peek that amount. Return
the number of bytes peeked.

This simplifies crrev.com/1472123002. For a stream that is smaller than
14 bytes, it can successfully peek, meaning the client will not need to
fall back to read() + rewind(), which may fail if the stream can peek
but not rewind.

This CL revives code from patch set 3 of crrev.com/1044953002, where I
initially introduced peek() (including tests).

Add a test for SkFrontBufferedStream that verifies that peeking does
not make rewind() fail (i.e. by reading past the internal buffer).

BUG=skia:3257

Review URL: https://codereview.chromium.org/1490923005

8 years agoStart objectifying GrAtlasTextBlob
joshualitt [Mon, 7 Dec 2015 19:32:50 +0000 (11:32 -0800)]
Start objectifying GrAtlasTextBlob

BUG=skia:

Review URL: https://codereview.chromium.org/1503193002

8 years agoclang/win: Let SK_TRACEHR not produce -Wunused-value warnings in release builds.
thakis [Mon, 7 Dec 2015 18:41:36 +0000 (10:41 -0800)]
clang/win: Let SK_TRACEHR not produce -Wunused-value warnings in release builds.

Fixes warnings like:
..\..\third_party\skia\include\utils\win\SkHRESULT.h(51,23) :  note: expanded from macro 'HRNM'
                      ^~~~~~~~~~~~~~~~~~~~~~~~~
..\..\third_party\skia\include\utils\win\SkHRESULT.h(26,20) :  note: expanded from macro 'HR_GENERAL'
        SK_TRACEHR(_hr, _msg);\
                   ^~~
..\..\third_party\skia\include\utils\win\SkHRESULT.h(20,31) :  note: expanded from macro 'SK_TRACEHR'
                              ^~~

BUG=chromium:505318
TBR=reed
This is a trivial implementation change.

Review URL: https://codereview.chromium.org/1503463004

8 years agoFix up signed-integer-overflow warnings
tomhudson [Mon, 7 Dec 2015 18:38:05 +0000 (10:38 -0800)]
Fix up signed-integer-overflow warnings

When checking whether a matrix was a pure scale, we subtracted
0x3f800000 from the diagonals; if the diagonal value was already
very negative, we'd underflow. Replace subtraction with XOR.

When dealing with repeating tiled bitmaps, when the bitmap was
very large, we'd multiply an offset by 65535, possibly causing
underflow. Throw in a cast to long (casting to unsigned also
silences the warning and wouldn't involve extension, but I can't
convince myself that it's correct).

BUG=skia:4635
R=mtklein@google.com

Review URL: https://codereview.chromium.org/1504933002

8 years agoAdd SkTileImageFilter sample to filterfastbounds GM.
senorblanco [Mon, 7 Dec 2015 18:36:30 +0000 (10:36 -0800)]
Add SkTileImageFilter sample to filterfastbounds GM.

NOTE: will affect pixel results for filterfastbounds GM.

BUG=skia:3194

Review URL: https://codereview.chromium.org/1500373004

8 years agoAlways use high precision on NDS transform
joel.liang [Mon, 7 Dec 2015 18:33:00 +0000 (10:33 -0800)]
Always use high precision on NDS transform

To fix the Chrome fillRect issue on Galaxy S6.
We should use high precision for position related calculation.

BUG=chromium:552999

Review URL: https://codereview.chromium.org/1500393002

8 years agoSkAlphaThresholdFilter.h allow flattening
halcanary [Mon, 7 Dec 2015 18:29:54 +0000 (10:29 -0800)]
SkAlphaThresholdFilter.h allow flattening

Motivation:  allows this:

    #include "SkAlphaThresholdFilter.h"
    void init() {
      SkAlphaThresholdFilter::InitializeFlattenables();
    }

BUG=skia:4613

Review URL: https://codereview.chromium.org/1500373003

8 years agoPin result in SkATan2_255
robertphillips [Mon, 7 Dec 2015 17:54:02 +0000 (09:54 -0800)]
Pin result in SkATan2_255

BUG=555544

Review URL: https://codereview.chromium.org/1506913002

8 years agoadd gm to exercise large sigmas
reed [Mon, 7 Dec 2015 17:28:34 +0000 (09:28 -0800)]
add gm to exercise large sigmas

BUG=skia:4437
TBR=

Review URL: https://codereview.chromium.org/1503143002

8 years agobetter NEON div255
mtklein [Mon, 7 Dec 2015 16:21:11 +0000 (08:21 -0800)]
better NEON div255

We were doing (x+127)/255 = ((x+128) + (x+128)>>8)>>8 in three instructions:
    1) x += 128
    2) shift x right 8 bits
    3) add x and x>>8 together, then shift right more 8 bits

Now do it as two instructions:
    1) shift (x+128) right 8 bits
    2) add x and (x+128)>>8 and 128 all together, then shift right 8 more bits

On ARM this will be a 5-10% speedup for SrcATop, DstATop, Xor, Multiply, Difference, HardLight, Darken, and Lighten xfermodes.  When we have a mask (e.g. text), *all* xfermodes except Plus will get a similar boost.

This should mean now that (a*b).div255() is the same speed as a.approxMulDiv255(b) on both x86 and ARM, and of course it's perfect instead of approximate.  So we should eliminate approxMulDiv255(), but I'll leave it to another CL, as it'll need Blink rebaselines.

This CL should not change GMs or Blink.
https://gold.skia.org/search2?issue=1502843002&unt=true&query=source_type%3Dgm&master=false

BUG=skia:
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot;client.skia.android:Test-Android-GCC-Nexus9-CPU-Denver-Arm64-Debug-Trybot,Test-Android-GCC-Nexus5-CPU-NEON-Arm7-Release-Trybot

Review URL: https://codereview.chromium.org/1502843002

8 years agoMatrix convolution bounds fix; affectsTransparentBlack fixes.
senorblanco [Mon, 7 Dec 2015 15:48:34 +0000 (07:48 -0800)]
Matrix convolution bounds fix; affectsTransparentBlack fixes.

Because the convolution kernel is (currently) applied in device space,
there's no way to know which object-space pixels will be touched. So
return false from canComputeFastBounds().

The results from the matrixconvolution GM were actually wrong, since
they were showing edge differences on the clip boundaries, where they
should really only show on crop boundaries. I added a crop to the GM
to keep the results the same (which are useful to test the different
convolution tile modes).

While I was at it, SkImageFilter::affectsTransparentBlack() was
inapplicable on most things except color filters, and its use on
leaf nodes was confusing. So I removed it, and made
SkImageFilter::canComputeFastBounds() virtual instead.

BUG=skia:4630

Review URL: https://codereview.chromium.org/1500923004

8 years agoAdd transfer buffer to GLCaps
jvanverth [Mon, 7 Dec 2015 15:36:44 +0000 (07:36 -0800)]
Add transfer buffer to GLCaps

Adds a check for PBO/transfer buffer support to GrGLCaps,
and uses that to pick the correct buffer type.

BUG=skia:4604

Review URL: https://codereview.chromium.org/1503593002

8 years agoUpdate SKP version
update-skps [Sun, 6 Dec 2015 08:27:08 +0000 (00:27 -0800)]
Update SKP version

Automatic commit by the RecreateSKPs bot.

TBR=
NO_MERGE_BUILDS

Review URL: https://codereview.chromium.org/1502893002

8 years agodetect when we can filter bitmaps/images directly, w/o a tmp layer
reed [Sat, 5 Dec 2015 21:07:27 +0000 (13:07 -0800)]
detect when we can filter bitmaps/images directly, w/o a tmp layer

visual bench run on Mac Pro

curr/maxrss loops min median mean max stddev samples    config bench
 100/100 MB 16 412µs 413µs 413µs 414µs 0% ▄▁▇▄▄▄▄█▄▃▅ gpu warmupbench
 101/102 MB 32 547µs 548µs 611µs 1.24ms 34% █▁▁▁▁▁▁▁▁▁▁ gpu image-filter-sprite-draw-image
 102/103 MB 32 547µs 548µs 721µs 1.23ms 41% █▁▇▁▁█▁▁▁▁▁ gpu image-filter-sprite-draw-bitmap
 103/103 MB 64 546µs 546µs 546µs 547µs 0% ▆▄▂▁▇█▅▇▅▇▃ gpu image-filter-sprite-draw-sprite

Should have no effect on Chrome while SK_SUPPORT_LEGACY_LAYER_BITMAP_IMAGEFILTERS is defined (which it is in chrome)

BUG=skia:1073

Review URL: https://codereview.chromium.org/1491293002

8 years agoRevert of Matrix convolution bounds fix; affectsTransparentBlack fixes. (patchset...
senorblanco [Sat, 5 Dec 2015 13:59:41 +0000 (05:59 -0800)]
Revert of Matrix convolution bounds fix; affectsTransparentBlack fixes. (patchset #4 id:60001 of https://codereview.chromium.org/1500923004/ )

Reason for revert:
Introduced memory leak; pixel changes in Chrome.

Original issue's description:
> Matrix convolution bounds fix; affectsTransparentBlack fixes.
>
> Because the convolution kernel is (currently) applied in device space,
> there's no way to know which object-space pixels will be touched. So
> return false from canComputeFastBounds().
>
> The results from the matrixconvolution GM were actually wrong, since
> they were showing edge differences on the clip boundaries, where they
> should really only show on crop boundaries. I added a crop to the GM
> to keep the results the same (which are useful to test the different
> convolution tile modes).
>
> While I was at it, SkImageFilter::affectsTransparentBlack() was
> inapplicable on most things except color filters, and its use on
> leaf nodes was confusing. So I removed it, and made
> SkImageFilter::canComputeFastBounds() virtual instead.
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/8705ec80518ef551994b82ca5ccaeb0241d6adec

TBR=reed@google.com,reed@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1497083005

8 years agoreport back colorfilters in lua
reed [Sat, 5 Dec 2015 04:45:59 +0000 (20:45 -0800)]
report back colorfilters in lua

BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/1498293002

8 years agoMatrix convolution bounds fix; affectsTransparentBlack fixes.
senorblanco [Fri, 4 Dec 2015 21:57:30 +0000 (13:57 -0800)]
Matrix convolution bounds fix; affectsTransparentBlack fixes.

Because the convolution kernel is (currently) applied in device space,
there's no way to know which object-space pixels will be touched. So
return false from canComputeFastBounds().

The results from the matrixconvolution GM were actually wrong, since
they were showing edge differences on the clip boundaries, where they
should really only show on crop boundaries. I added a crop to the GM
to keep the results the same (which are useful to test the different
convolution tile modes).

While I was at it, SkImageFilter::affectsTransparentBlack() was
inapplicable on most things except color filters, and its use on
leaf nodes was confusing. So I removed it, and made
SkImageFilter::canComputeFastBounds() virtual instead.

BUG=skia:

Review URL: https://codereview.chromium.org/1500923004

8 years agoclarify diff manually, showing black where they differ
reed [Fri, 4 Dec 2015 20:44:24 +0000 (12:44 -0800)]
clarify diff manually, showing black where they differ

BUG=skia:
TBR=robertphilips@google.com

Review URL: https://codereview.chromium.org/1498243002

8 years agouse RawIter in hairpath (simplifies)
reed [Fri, 4 Dec 2015 19:59:05 +0000 (11:59 -0800)]
use RawIter in hairpath (simplifies)

no impact on nanobench

BUG=skia:

Review URL: https://codereview.chromium.org/1497283002

8 years agoadd hairline with caps gm
caryclark [Fri, 4 Dec 2015 19:08:42 +0000 (11:08 -0800)]
add hairline with caps gm

TBR=reed@google.com

Review URL: https://codereview.chromium.org/1502613002

8 years agoAdd iOS compile bot to the CQ
borenet [Fri, 4 Dec 2015 18:19:21 +0000 (10:19 -0800)]
Add iOS compile bot to the CQ

BUG=skia:4252

Review URL: https://codereview.chromium.org/1501453005

8 years agoCreate a skeleton VisualDebugModule
joshualitt [Fri, 4 Dec 2015 17:02:34 +0000 (09:02 -0800)]
Create a skeleton VisualDebugModule

BUG=skia:

Review URL: https://codereview.chromium.org/1498043002

8 years agofix mozilla bug
joshualitt [Fri, 4 Dec 2015 16:51:11 +0000 (08:51 -0800)]
fix mozilla bug

TBR=bsalomon@google.com
BUG=skia:4621

Review URL: https://codereview.chromium.org/1500023002

8 years agoFix overflow caught by ASAN.
benjaminwagner [Fri, 4 Dec 2015 16:48:26 +0000 (08:48 -0800)]
Fix overflow caught by ASAN.

BUG=skia:

Review URL: https://codereview.chromium.org/1498923002

8 years agoMake SkAndroidCodec support ico
msarett [Fri, 4 Dec 2015 16:00:50 +0000 (08:00 -0800)]
Make SkAndroidCodec support ico

BUG=skia:

Review URL: https://codereview.chromium.org/1472933002

8 years agoSpeculative fix for win8 bot crash in ~GrAutoLocaleSetter
bsalomon [Fri, 4 Dec 2015 15:27:36 +0000 (07:27 -0800)]
Speculative fix for win8 bot crash in ~GrAutoLocaleSetter

Review URL: https://codereview.chromium.org/1493913008

8 years agoRevert of Make SkAndroidCodec support ico (patchset #7 id:130002 of https://coderevie...
scroggo [Fri, 4 Dec 2015 15:09:57 +0000 (07:09 -0800)]
Revert of Make SkAndroidCodec support ico (patchset #7 id:130002 of https://codereview.chromium.org/1472933002/ )

Reason for revert:
Crashing: https://uberchromegw.corp.google.com/i/client.skia.android/builders/Test-Android-GCC-NexusPlayer-CPU-SSE4-x86-Release/builds/1499/steps/dm/logs/stdio

Also, related ASAN failures:
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/3676/steps/dm/logs/stdio

Original issue's description:
> Make SkAndroidCodec support ico
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/1603e9310f62cf0dd543cdb09dea06aa78373f13

TBR=djsollen@google.com,msarett@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1498903004