Commit Graph

2284 Commits

Author SHA1 Message Date
kkinnunen
dc0f408a96 Fold alpha to the inner savelayer in savelayer-savelayer-restore patterns
Fold alpha to the inner savelayer in savelayer-savelayer-restore
patterns such as this:

  SaveLayer (non-opaque)
    Save
      ClipRect
      SaveLayer
      Restore
    Restore
  Restore

Current blink generates these for example for SVG content such as this:

<path style="opacity:0.5 filter:url(#blur_filter)"/>

The outer save layer is due to the opacity and the inner one is due to
blur filter being implemented with picture image filter.

Reduces layers in desk_carsvg.skp testcase from 115 to 78.

BUG=skia:3119

Review URL: https://codereview.chromium.org/835973005
2015-01-26 00:14:26 -08:00
mtklein
31ff29829e Don't leak image in Surface test.
==7023== 5,056 (896 direct, 4,160 indirect) bytes in 8 blocks are definitely lost in loss record 947 of 2,656
==7023==    at 0x4C2B1C7: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7023==    by 0x82CB99: SkNewImageFromBitmapTexture(SkBitmap const&, int, SkSurface::Budgeted) (SkImage_Gpu.cpp:64)
==7023==    by 0x81A1CF: SkSurface_Gpu::onNewImageSnapshot(SkSurface::Budgeted) (SkSurface_Gpu.cpp:50)
==7023==    by 0x694F9D: SkSurface::newImageSnapshot(SkSurface::Budgeted) (SkSurface_Base.h:92)
==7023==    by 0x55EA7C: test_Surface(skiatest::Reporter*, GrContextFactory*) (SurfaceTest.cpp:485)
==7023==    by 0x407CB2: run_test(skiatest::Test*) (DM.cpp:399)
==7023==    by 0x408382: run_enclave_and_gpu_tests(SkTArray<Task, false>*) (DM.cpp:411)
==7023==    by 0x68B71E: SkTaskGroup::wait() (SkTaskGroup.cpp:67)
==7023==    by 0x40934E: dm_main() (DM.cpp:455)
==7023==    by 0x409483: main (DM.cpp:477)

http://build.chromium.org/p/client.skia/builders/Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind/builds/276/steps/dm/logs/stdio

TBR=bsalomon@google.com

BUG=skia:

Review URL: https://codereview.chromium.org/872183002
2015-01-24 11:27:27 -08:00
yunchao.he
90acb8e97c a typo in SkResourceCacheTest
BUG=skia:

Review URL: https://codereview.chromium.org/868613002
2015-01-23 17:06:21 -08:00
bsalomon
63c992f6c0 Fix the speeling of "purgeable" in Gr code
TBR=robertphillips@google.com

Review URL: https://codereview.chromium.org/874693002
2015-01-23 12:47:59 -08:00
halcanary
6a144345d7 Cleanup SkPDFObject::emit*
Review URL: https://codereview.chromium.org/869783003
2015-01-23 11:45:10 -08:00
bsalomon
eaaaf0b16c Take budgeted param when snapping new image.
Review URL: https://codereview.chromium.org/872543002
2015-01-23 08:08:04 -08:00
reed
2ff257bd95 check for too-large rowBytes
BUG=446164

Review URL: https://codereview.chromium.org/871993003
2015-01-23 07:51:14 -08:00
bsalomon
c2f35b750a Allow unbudgeted resources to be recycled by the cache as scratch.
Review URL: https://codereview.chromium.org/870743002
2015-01-23 07:19:22 -08:00
bsalomon
1ea1ebce10 Remove GrBinHashKey
Review URL: https://codereview.chromium.org/861323002
2015-01-23 06:46:16 -08:00
mtklein
2f6bb6b852 minor readability / refactors
I have been hacking at this test trying to understand why the N5 is
still sometimes crashy (it seems, less but not zero now). No luck so far.

But, while I've been reading and hacking at it, I think I've made a
few small improvements, mostly to readability.

BUG=skia:

Review URL: https://codereview.chromium.org/870803002
2015-01-23 05:47:55 -08:00
bsalomon
24db3b1c35 Add specialized content key class for resources.
Review URL: https://codereview.chromium.org/858123002
2015-01-23 04:24:05 -08:00
mtklein
cada95ad9b Move FP texture test buffers to heap.
This is a speculative fix for the crashing N5 bots.  It looks like the bots are
always failing in or around FloatingPointTextureTest.

It looks like sometimes they're hitting a SIGBUS, which I suspect is stack
overflow.  FloatingPointTextureTest allocates ~320K on the stack, which may
be too much.  This CL moves those buffers to the heap.  For consistency I did
the same with the half-float tests, though they're only using ~1/8th the stack.

It looks like sometimes the bots are failing to malloc.  I don't understand that,
and this CL doesn't address that directly.  But it's possible this is still a stack
overflow, just trashing RAM and causing arbitrary mayhem instead of a SIGBUS.

I have no idea why this is a problem only on the N5.  I have been unable to
reproduce this locally, neither with a K N5 nor an L N5, but the bots are pretty
reliable.

NOTREECHECKS=true
BUG=skia:

Review URL: https://codereview.chromium.org/871623002
2015-01-22 13:50:35 -08:00
egdaniel
8dd688b756 Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder
BUG=skia:

Review URL: https://codereview.chromium.org/858343002
2015-01-22 10:16:09 -08:00
reed
e44acc9617 remove more dead code
BUG=skia:

Review URL: https://codereview.chromium.org/865873003
2015-01-22 09:37:46 -08:00
reed
b0dfb546f5 remove (unused) GatherPixelRefs
BUG=skia:

Review URL: https://codereview.chromium.org/869463002
2015-01-22 09:03:25 -08:00
scroggo
a1193e4b0e Make SkStream *not* ref counted.
SkStream is a stateful object, so it does not make sense for it to have
multiple owners. Make SkStream inherit directly from SkNoncopyable.

Update methods which previously called SkStream::ref() (e.g.
SkImageDecoder::buildTileIndex() and SkFrontBufferedStream::Create(),
which required the existing owners to call SkStream::unref()) to take
ownership of their SkStream parameters and delete when done (including
on failure).

Switch all SkAutoTUnref<SkStream>s to SkAutoTDelete<SkStream>s. In some
cases this means heap allocating streams that were previously stack
allocated.

Respect ownership rules of SkTypeface::CreateFromStream() and
SkImageDecoder::buildTileIndex().

Update the comments for exceptional methods which do not affect the
ownership of their SkStream parameters (e.g.
SkPicture::CreateFromStream() and SkTypeface::Deserialize()) to be
explicit about ownership.

Remove test_stream_life, which tested that buildTileIndex() behaved
correctly when SkStream was a ref counted object. The test does not
make sense now that it is not.

In SkPDFStream, remove the SkMemoryStream member. Instead of using it,
create a new SkMemoryStream to pass to fDataStream (which is now an
SkAutoTDelete).

Make other pdf rasterizers behave like SkPDFDocumentToBitmap.

SkPDFDocumentToBitmap delete the SkStream, so do the same in the
following pdf rasterizers:

SkPopplerRasterizePDF
SkNativeRasterizePDF
SkNoRasterizePDF

Requires a change to Android, which currently treats SkStreams as ref
counted objects.

Review URL: https://codereview.chromium.org/849103004
2015-01-21 12:09:53 -08:00
joshualitt
17e7314e0e remove drawtype
BUG=skia:

Review URL: https://codereview.chromium.org/862933005
2015-01-21 11:52:36 -08:00
joshualitt
b77e4b6bf0 remove drawType from optState
BUG=skia:

Review URL: https://codereview.chromium.org/864853002
2015-01-21 10:16:18 -08:00
bsalomon
1c60dfe7ca Reland https://codereview.chromium.org/860333002 with fix for test failures.
Revert "Revert of Make GrScratchKey memory buffer correct size on copy (patchset #1 id:1 of https://codereview.chromium.org/860333002/)"

This reverts commit 988018c817.

BUG=skia:

Review URL: https://codereview.chromium.org/863983003
2015-01-21 09:32:40 -08:00
mtklein
988018c817 Revert of Make GrScratchKey memory buffer correct size on copy (patchset #1 id:1 of https://codereview.chromium.org/860333002/)
Reason for revert:
Our Valgrind bot just spewed out a weird error.  I don't know if it's related, but it looks at least like one of the stacks was in the right area, so I'm going to revert this precautionarily.  Sorry if this is a false positive.

http://build.chromium.org/p/client.skia/builders/Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind/builds/266/steps/dm/logs/stdio

Original issue's description:
> Make GrScratchKey memory buffer correct size on copy
>
> Scratch key memory buffer of a copy of a key was too big. The (new) copy
> was N times uint32_t bytes instead of N bytes.
>
> Adds few tests to resource cache. These tests would not catch the too
> big buffer. This is just a precaution for too small buffers. The main
> idea of the test change is that the scratch key should contain some
> information, so that lookup with a scratch key can also return no
> match. Otherwise testing of scratch lookup result is not indicative of
> correct code (eg. no-information scratch key will always match).
>
> Committed: https://skia.googlesource.com/skia/+/711ef4831363fb8cbdf061dc2c36c65b13c0ccf2

TBR=bsalomon@google.com,kkinnunen@nvidia.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/864833003
2015-01-21 08:05:55 -08:00
kkinnunen
711ef48313 Make GrScratchKey memory buffer correct size on copy
Scratch key memory buffer of a copy of a key was too big. The (new) copy
was N times uint32_t bytes instead of N bytes.

Adds few tests to resource cache. These tests would not catch the too
big buffer. This is just a precaution for too small buffers. The main
idea of the test change is that the scratch key should contain some
information, so that lookup with a scratch key can also return no
match. Otherwise testing of scratch lookup result is not indicative of
correct code (eg. no-information scratch key will always match).

Review URL: https://codereview.chromium.org/860333002
2015-01-21 06:39:14 -08:00
reed
3f43f8ab9c remove dead SkPersp macros
BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/864713002
2015-01-20 19:58:36 -08:00
halcanary
87f3ba4847 Simplify skiatest framework.
skiatest::Test class is now a simple struct.  Some
functionalty, such as counting errors or timing is now
handled elsewhere.

skiatest:Reporter is now a simpler abstract class.  The two
implementations handle test errors.

DM and pathops_unittest updated.

Review URL: https://codereview.chromium.org/830513004
2015-01-20 09:30:20 -08:00
joshualitt
873ad0e0b4 BUG=skia:
Review URL: https://codereview.chromium.org/815643005
2015-01-20 09:08:52 -08:00
egdaniel
71e236c03e Remove willReadDst from GrFragmentProcessor.
Since only XP's can read dst now, there is no reason to have this query on GrFP.
This also triggered a chain reaction of cleaning up/removing unnecessary code
elsewhere.

BUG=skia:

Review URL: https://codereview.chromium.org/851143003
2015-01-20 06:34:51 -08:00
sugoi
692135f968 YUV planes cache
- Added new classes to contain YUV planes of memory, along with the associated data.
- Used these classes in load_yuv_texture() to enable YUV planes caching
- Added a unit test for the new cache

BUG=450021

Review URL: https://codereview.chromium.org/851273003
2015-01-19 10:10:27 -08:00
bsalomon
afe3005be3 Require budget decision when creating a RenderTarget SkSurface.
Restructure SkGpuDevice creation:
*SkSurfaceProps are optional.
*Use SkSurfaceProps to communicate DF text rather than a flag.
*Tell SkGpuDevice::Create whether RT comes from cache or not.

Review URL: https://codereview.chromium.org/848903004
2015-01-16 07:32:33 -08:00
caryclark
45fa447460 new files for pathops geometric intersection
There's no gyp references to these new files,
so this should only have the effect of reducing
the size of the commit that turns this code on.

TBR=

Review URL: https://codereview.chromium.org/853223002
2015-01-16 07:04:10 -08:00
kkinnunen
678c1b019a Fold alpha to the draw in savelayer-draw-restore patterns with non-opaque draw
Fold alpha of a save layer call to the subsequent draw call paint, even when
the draw call paint color is already non-opaque.

Comparing the difference of the unoptimized and the optimized call pattern
with all (layer alpha, draw alpha) combinations, this produces
off-by-one pixels ~50% of the time.

Reduces layers of current desk_carsvg.skp (recorded with cross-process
picture image filters allowed) from 122 to 115.

BUG=skia:3119

Review URL: https://codereview.chromium.org/840483005
2015-01-16 05:04:36 -08:00
mtklein
0c278972d0 Why are we afraid of saveLayer() bounds?
They're only hints.  We can ignore them in this optimization.
My only hesitation is that this pattern doesn't seem to happen in our .skps.

BUG=skia:

Review URL: https://codereview.chromium.org/849243002
2015-01-15 08:08:10 -08:00
fmalita
1a178ca6dd Use device-space stroke width for SkDraw::drawRect() quick-reject
The stroke width needs to be CTM-adjusted when applied to device space
rects.

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

Review URL: https://codereview.chromium.org/801353008
2015-01-15 06:01:23 -08:00
bsalomon
5236cf480d Make uncached textures uncached from the get go.
This avoids the problem of a newly created uncached texture causing a purge of cached resources.

BUG=chromium:445885

Review URL: https://codereview.chromium.org/846303002
2015-01-14 10:42:08 -08:00
mtklein
7c348a8097 DM can see into src/gpu. No need for relative include.
BUG=skia:

Review URL: https://codereview.chromium.org/853613004
2015-01-14 09:25:01 -08:00
mtklein
2c0e8f13a0 Remove self-assignment in a test.
BUG=skia:

Review URL: https://codereview.chromium.org/853723002
2015-01-14 08:49:10 -08:00
joshualitt
71c9260e6f More changes to bring together path / geo procs
BUG=skia:

Review URL: https://codereview.chromium.org/820783005
2015-01-14 08:12:47 -08:00
mtklein
199ba8e19b namespace {} trick for SK_DECLARE_STATIC_ONCE
Like all our other SK_DECLARE_STATIC_*, it's usually not a thread-safe
thing to put inside a function.  Adding namespace {} prevents that
syntactically.

Needs https://codereview.chromium.org/841263004/ to land first.

BUG=chromium:447890

No public API changes.
TBR=reed@google.com

Review URL: https://codereview.chromium.org/806473006
2015-01-13 08:40:23 -08:00
mtklein
6f07665768 Simplify SkInstCnt
This code requires fewer macros to use it (just one), has less code in macro
definitions, and has simpler synchronization code (just atomic ints, no SkOnce,
no SkMutex, etc.)

A minor downside, we lose indentation and reverse-ordering in the final report:
  Leaked SkRefCntBase: 7
     Leaked SkFontMgr: 1
     Leaked SkWeakRefCnt: 1
         Leaked SkTypeface: 1
     Leaked SkFlattenable: 3
         Leaked SkXfermode: 3
     Leaked SkPathRef: 1
     Leaked SkPixelRef: 1
         Leaked SkMallocPixelRef: 1
becomes
  Leaked SkXfermode: 3
  Leaked SkMallocPixelRef: 1
  Leaked SkPixelRef: 1
  Leaked SkPathRef: 1
  Leaked SkFlattenable: 3
  Leaked SkTypeface: 1
  Leaked SkWeakRefCnt: 1
  Leaked SkFontMgr: 1
  Leaked SkRefCntBase: 7

This is motivated by wanting to land https://codereview.chromium.org/806473006/,
which makes sure all static use of SkOnce are in global scope.  The current
implementation of SkInstCnt uses them in function scope, which isn't safe.
BUG=skia:

No public API changes.
TBR=reed@google.com

Review URL: https://codereview.chromium.org/841263004
2015-01-13 08:22:44 -08:00
halcanary
f361b71439 In SkPDFDocument::emitPDF(), stop pre-calculating file offsets.
* Add Streamer utility class which measures the current
  pdf offset by calling SkWStream::bytesWritten(). Calls
  SkPDFCatalog::setFileOffset() and SkPDFObject::emit() at
  the same time to guarantee that everything works out.

* SkPDFCatalog::setFileOffset() no longer calculates the
  object's size.

* SkPDFCatalog::setSubstituteResourcesOffsets() removed.

* SkPDFCatalog::emitSubstituteResources() removed and
  getSubstituteList() made public in its place.

* Remove SkPDFPage::getPageSize and SkPDFPage::emitPage.
  Replace with SkPDFPage::getContentStream().

* SkPDFObject::getOutputSize no longer virtual, only used in
  unit tests.  All SkPDFObject subclasses getOutputSize()
  overrides removed.

* SkPDFObject::getIndirectOutputSize removed.

* PDFPrimitivesTest updated for new functions.

Review URL: https://codereview.chromium.org/846023003
2015-01-13 07:12:57 -08:00
halcanary
4fc48af0d7 Change function signature of SkPDFObject::emitObject.
Replace virutal SkPDFObject::emitObject(s, c, true) with non-virtual
SkPDFObject::emitIndirectObject(s, c), since none of the subclasses do
(or should do) anything different.

Replace object->emitObject(s, c, false) with object->emitObject(s, c)

This is one step in simplifying the SkPDFObject interface to allow for
the next step in refactoring.

Review URL: https://codereview.chromium.org/827733004
2015-01-12 10:07:50 -08:00
mtklein
72c9faab45 Fix up all the easy virtual ... SK_OVERRIDE cases.
This fixes every case where virtual and SK_OVERRIDE were on the same line,
which should be the bulk of cases.  We'll have to manually clean up the rest
over time unless I level up in regexes.

for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end

BUG=skia:

Review URL: https://codereview.chromium.org/806653007
2015-01-09 10:06:40 -08:00
mtklein
703dd2ed18 Remove SkTileGrid (except for TileGridInfo).
TBR=reed@google.com

BUG=skia:3085

Review URL: https://codereview.chromium.org/845623002
2015-01-09 06:41:48 -08:00
reed
5965c8ae4e add ImageGenerator::NewFromData to porting layer
BUG=skia:3275

Review URL: https://codereview.chromium.org/834633006
2015-01-07 18:04:45 -08:00
mtklein
7e44bb1916 Remove macros that make it look like it's a good idea to not be able to flatten.
There are only a handful of SkFlattenables that are not flattenable.  That
there are any seems highly illogical.  To make this look less like a normal
thing, this removes both macros that marked SkFlattenables as non-flattenable
(in slightly different ways).

The handful of SkFlattenables in our codebase that can't be flattened now
assert violently that they can't be flattened.  They're internal or
part of animator... places where we'll never actually flatten them.

TestLooper and DummyRasterizer were so trivial that I just made them flattenable.

BUG=skia:

Review URL: https://codereview.chromium.org/841753002
2015-01-07 09:06:08 -08:00
robertphillips
783fe16b8e Rename SkDrawPictureCallback to SkPicture::AbortCallback
Committed: https://skia.googlesource.com/skia/+/7ef197255deb4e2fa64c03c7130d56ddf164e83c

Review URL: https://codereview.chromium.org/829983003
2015-01-07 07:28:41 -08:00
reed
8ea6dabbb1 Revert of Rename SkDrawPictureCallback to SkPicture::AbortCallback (patchset #2 id:20001 of https://codereview.chromium.org/829983003/)
Reason for revert:
speculative revert to unblock DEPS roll

Original issue's description:
> Rename SkDrawPictureCallback to SkPicture::AbortCallback
>
> Committed: https://skia.googlesource.com/skia/+/7ef197255deb4e2fa64c03c7130d56ddf164e83c

TBR=reed@google.com,robertphillips@google.com
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/824013004
2015-01-06 16:15:25 -08:00
robertphillips
7ef197255d Rename SkDrawPictureCallback to SkPicture::AbortCallback
Review URL: https://codereview.chromium.org/829983003
2015-01-06 12:26:08 -08:00
robertphillips
c4bd39c903 Require explicit disabling of cross process pictureimagefilters
This is to allow capturing .skp files with their pictureimagefilters intact.

This is a companion to https://codereview.chromium.org/810933004/ (Provide a way of allowing cross process pictureimagefilters).

Review URL: https://codereview.chromium.org/834673006
2015-01-06 09:17:02 -08:00
robertphillips
2b6ab61e22 Remove SkPath::asRect
AFAICT the asRect entry point is not needed.

Greg: GPU
Reed: API
Cary: Path

Review URL: https://codereview.chromium.org/833193002
2015-01-05 12:22:14 -08:00
robertphillips
91b0a35873 Cleanup isRect variants
Review URL: https://codereview.chromium.org/832083002
2015-01-05 10:13:46 -08:00
reed
41af966ab3 Revert of Revert of move remaining virtual draw methods to onDraw (patchset #1 id:1 of https://codereview.chromium.org/835913002/)
Reason for revert:
test to see if it wasn't this CL that broke chromeos

Original issue's description:
> Revert of move remaining virtual draw methods to onDraw (patchset #5 id:80001 of https://codereview.chromium.org/817723005/)
>
> Reason for revert:
> did this cause chromeos heap corruption on skp?
>
> Original issue's description:
> > move remaining virtual draw methods to onDraw
> >
> > BUG=skia:
> >
> > Committed: https://skia.googlesource.com/skia/+/2e0f7d53bba5438c9bf11ee5ccae2c301e348419
>
> TBR=robertphillips@google.com,djsollen@google.com,bsalomon@google.com,mtklein@google.com
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/e87e383351e1547b21d96d02bcd0c3cbbe0837f1

TBR=robertphillips@google.com,djsollen@google.com,bsalomon@google.com,mtklein@google.com,reed@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/831253002
2015-01-05 07:49:08 -08:00