Fix GPU displacement with expanding crop rects, and re-enable the
imagefilterscropexpand GM. There were two bugs: the result texture was
being created at input color bitmap size, not the cropped bounds size,
and the matrix in GrContext was not being set to identity before draw.
R=junov@chromium.org
Review URL: https://codereview.chromium.org/195973007
git-svn-id: http://skia.googlecode.com/svn/trunk@13844 2bbb7eff-a529-9590-31e7-b0007b416f81
NOTE: this patch set is based on https://codereview.chromium.org/189913021/,
and needs that patch to land first.
Until now, crop rects in Skia have only been able to reduce
the size of the destination bounds, but not expand them.
SVG semantics require the latter as well. The heart of
the change is in applyCropRect(), which now assigns each
edge, instead of doing an intersection with the crop rect.
In order to support this (and still work well with tiled
drawing) we need to clip the resulting crop rect to the
clipping region of the filters. This uses the Context struct
previously landed from https://codereview.chromium.org/189913021/.
Many of the pixel loops are not yet ready to handle a
destination rect larger than the source rect. So we provide
a convenience version of applyCropRect() which creates an
offscreen and pads it out with transparent black. Once the
pixel loops and shaders have been fixed to support larger
destination bounds, they should be switched back to the
non-drawing version of applyCropRect().
BUG=skia:
R=bsalomon@google.com, reed@google.com
Committed: https://code.google.com/p/skia/source/detail?r=13805
Review URL: https://codereview.chromium.org/198003008
git-svn-id: http://skia.googlecode.com/svn/trunk@13809 2bbb7eff-a529-9590-31e7-b0007b416f81
NOTE: this patch set is based on https://codereview.chromium.org/189913021/,
and needs that patch to land first.
Until now, crop rects in Skia have only been able to reduce
the size of the destination bounds, but not expand them.
SVG semantics require the latter as well. The heart of
the change is in applyCropRect(), which now assigns each
edge, instead of doing an intersection with the crop rect.
In order to support this (and still work well with tiled
drawing) we need to clip the resulting crop rect to the
clipping region of the filters. This uses the Context struct
previously landed from https://codereview.chromium.org/189913021/.
Many of the pixel loops are not yet ready to handle a
destination rect larger than the source rect. So we provide
a convenience version of applyCropRect() which creates an
offscreen and pads it out with transparent black. Once the
pixel loops and shaders have been fixed to support larger
destination bounds, they should be switched back to the
non-drawing version of applyCropRect().
BUG=skia:
R=bsalomon@google.com, reed@google.com
Review URL: https://codereview.chromium.org/198003008
git-svn-id: http://skia.googlecode.com/svn/trunk@13805 2bbb7eff-a529-9590-31e7-b0007b416f81
Add SkSmallAllocator, a template for allocating small (as defined by the
instantiation) objects without extra calls to new. Add a helper macro to
make using it simple.
Remove SkTemplatesPriv.h, whose behavior is replaced by SkSmallAllocator.
The old SK_PLACEMENT_NEW had the following drawbacks:
- Easily confused with SkNEW_PLACEMENT.
- Requires passing around lots of void*s along with the storageSize.
- Requires using a separate class for deleting it.
- We had multiple ways Auto objects for deleting in different places.
- It always did a straight heap allocation on Windows, meaning Windows
did not get any advantages from the confusing code.
The new SkSmallAllocator simplifies things:
- It is clear about what it does.
- It takes care of the deletion in one place that is automatically
handled.
Further, the new class can be used to create more than one object. This
is in preparation for BUG=skia:1976, for which we would like to create
a new object without extra heap allocations. The plan is to create both
the blitter and the new object on the stack using the SkSmallAllocator.
Add a new test for SkSmallAllocator.
SkShader.h:
Move the private version of CreateBitmapShader to SkBitmapProcShader
(which already has the implementation) and remove the friend class
(which was only used to call this private function). This allows
SkSmallAllocator to reside in the private src/ directory.
SkBitmapProcShader:
Move CreateBitmapShader and the macro for the storage size here. With
the macro in a (private) header, the (private) headers with function
declarations (which now depend on the storage size used) can see the
macro.
Use SkSmallAllocator in CreateBitmapShader.
Change the macro to kBlitterStorageByteCount, since SkSmallAllocator
takes a byte count as its template parameter.
SkBlitter:
Use the SkSmallAllocator.
Remove Sk3DShader::fKillProc and SkAutoCallProc. Both of their
behaviors have been moved into SkSmallAllocator (SkAutoCallProc was
unnecessary anyway, because the only time we ever used it we also
called detach(), so its auto behavior never happened).
Create the Sk3DShader on the stack, if there's room.
Remove the helper version of Choose, which was unused.
SmallAllocatorTest:
Test for the new class.
The rest:
Use SkSmallAllocator.
BUG=skia:1976
R=reed@google.com, mtklein@google.com
Author: scroggo@google.com
Review URL: https://codereview.chromium.org/179343005
git-svn-id: http://skia.googlecode.com/svn/trunk@13696 2bbb7eff-a529-9590-31e7-b0007b416f81
The main meat of things is in SkThreadPool. We can now give SkThreadPool a
type for each thread to create and destroy on its local stack. It's TLS
without going through SkTLS.
I've split the DM tasks into CpuTasks that run on threads with no TLS, and
GpuTasks that run on threads with a thread local GrContextFactory.
The old CpuTask and GpuTask have been renamed to CpuGMTask and GpuGMTask.
Upshot: default run of out/Debug/dm goes from ~45 seconds to ~20 seconds.
BUG=skia:
R=bsalomon@google.com, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/179233005
git-svn-id: http://skia.googlecode.com/svn/trunk@13632 2bbb7eff-a529-9590-31e7-b0007b416f81
Also:
- make GrMemoryPoolBenches threadsafe
- some tweaks to various DM code
- rename GM::shortName() to getName() to match benches and tests
On my desktop, (289 GMs, 617 benches) x 4 configs, 227 tests takes 46s in Debug, 14s in Release. (Still minutes faster than running tests && bench && gm.) GPU singlethreading is definitely the limiting factor again; going to reexamine whether that's helpful to thread it again.
BUG=skia:
R=reed@google.com, bsalomon@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/178473006
git-svn-id: http://skia.googlecode.com/svn/trunk@13603 2bbb7eff-a529-9590-31e7-b0007b416f81
- refactor GYPs and a few flags
- make GPU tests grab a thread-local GrContextFactory when needed as we do in DM for GMs
- add a few more UI features to make DM more like tests
I believe this makes the program 'tests' obsolete.
It should be somewhat faster to run the two sets together than running the old binaries serially:
- serial: tests 20s (3m18s CPU), dm 21s (3m01s CPU)
- together: 27s (6m21s CPU)
Next up is to incorporate benches. I'm only planning there on a single-pass sanity check, so that won't obsolete the program 'bench' just yet.
Tested: out/Debug/tests && out/Debug/dm && echo ok
BUG=skia:
Committed: http://code.google.com/p/skia/source/detail?r=13586R=reed@google.com, bsalomon@google.com, mtklein@google.com, tfarina@chromium.org
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/178273002
git-svn-id: http://skia.googlecode.com/svn/trunk@13592 2bbb7eff-a529-9590-31e7-b0007b416f81
- refactor GYPs and a few flags
- make GPU tests grab a thread-local GrContextFactory when needed as we do in DM for GMs
- add a few more UI features to make DM more like tests
I believe this makes the program 'tests' obsolete.
It should be somewhat faster to run the two sets together than running the old binaries serially:
- serial: tests 20s (3m18s CPU), dm 21s (3m01s CPU)
- together: 27s (6m21s CPU)
Next up is to incorporate benches. I'm only planning there on a single-pass sanity check, so that won't obsolete the program 'bench' just yet.
Tested: out/Debug/tests && out/Debug/dm && echo ok
BUG=skia:
R=reed@google.com, bsalomon@google.com, mtklein@google.com, tfarina@chromium.org
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/178273002
git-svn-id: http://skia.googlecode.com/svn/trunk@13586 2bbb7eff-a529-9590-31e7-b0007b416f81
Motivation:
I have downloaded a barebones Linux system built for 64-bit ARM
from linaro.org and a ARMv8 Foundation Model from arm.com to run
it on. This will let us build and test Skia on ARM64 before we
aquire hardware to allow that. This CL introduces the changes to
the build files necessary to build Skia on a barebones embedded
Linux system. I tested it with the aarch64 GCC compiler provided
by linaro.org.
Changes:
Add a "barelinux" target_os for the DEPS file. Add an optional
git download of zlib.
Changes to gyp files: these changes abstract out libpng, libz, and
giflib so that images.gyp doesn't know whether they are static or
dynamically linked. I also add the variables skia_giflib_static,
skia_libpng_static, skia_zlib_static, and skia_freetype_static,
all of which default to false but when set to true will override
the behavior of the giflib, libpng, zlib, and freetype build
targets to require them to build statically. Also, the
skia_no_fontconfig variable turns off use of the fontconfig service.
Scripts in platform_tools/barelinux/bin:
arm64_download - this script downloads the Linaro's ARMv8 Aarch64
toolchain and minimal embedded Linux system as well as ARM's
foundation model. The required files are mirrored on Google
Cloud. The script then starts a emulated Arm64 Linux system in
the background. After the boot is complete, you can SSH into the
system at port 8022 via user@localhost. The SSH key will be
downloaded into the working directery as well.
download_deps - Uses gclient to download Skia's dependencies for a
bare Linux system (the normal dependecies plus giflib, libpng, and
zlib.)
barelinux_make - this script builds a version of skia that does
not depend on external libraries, perfect for putting in an
embedded system running Linux. Assumes you have run download_deps
first.
To test:
To build a barelinux target, use the barelinux_make script.
To build for a armv8 system: skia_arch_type=arm arm_neon=0 armv7=1
armv8=1 arm_thumb=0 skia_arch_width=64 and set the CC and CXX
variables to point at the cross-compiler downloaded by
arm64_download.
R=djsollen@google.com, scroggo@google.com, borenet@google.com
Author: halcanary@google.com
Review URL: https://codereview.chromium.org/152513007
git-svn-id: http://skia.googlecode.com/svn/trunk@13570 2bbb7eff-a529-9590-31e7-b0007b416f81
This change makes kSkipTiled_Flag also skip --tileGrid and --rtree.
All GMs which were passing kSkipTiled_Flag before were also passing
kSkipPicture_Flag, which also skips tilegrid and rtree, so this should
have no effect on them, but provides a smaller hammer for GMs which
still want to test picture playback, but not tiling.
The exception is magnifier, which was passing only kSkipTiled_Flag,
but magnifier is an odd beast and not web-exposed, so I'm not worried
about reducing its coverage slightly.
R=scroggo@google.com
BUG=skia:
Review URL: https://codereview.chromium.org/165723009
git-svn-id: http://skia.googlecode.com/svn/trunk@13514 2bbb7eff-a529-9590-31e7-b0007b416f81
SkResizeImageFilter resizes all the pixels from its input (subject to
the input's crop rect), but the offset to be applied was incorrect.
It should take the CTM into account, so that the origin of the resize is
the world space origin, unaffected by whatever clipping is applied.
New GM imageresizetiled exercises the behaviour under
impl-side-painting-like conditions, and existing GMs now have resize
cases added.
R=reed@google.com, robertphillips@google.com
Review URL: https://codereview.chromium.org/168283006
git-svn-id: http://skia.googlecode.com/svn/trunk@13506 2bbb7eff-a529-9590-31e7-b0007b416f81
Image filters in Skia currently clip the size of the the offscreen
bitmap used for filtering to the device clip bounds. This means that
any pixel-moving filter (e.g., blur) has edge artifacts at the clip
boundaries. This is problematic for tiling, where a single SkPicture
is played back with a clip set to the tile boundaries.
By implementing the onFilterBounds() traversal, and using it in
saveLayer() when a filter is present, we can clip the layer to the
expanded clip rect. Note that this requires that the traversal be
performed in reverse as compared to computeFastBounds(). (It's also
done in device space, unlike computeFastBounds()).
New test imagefiltersclipped tests pixel-moving filters when clipped
by various clip rects.
New test imageblurtiled tests tiled (compositor-style) rendering of
blurred text. There should be no artifacts at the tile boundaries.
BUG=337831
R=reed@google.com
Review URL: https://codereview.chromium.org/23011012
git-svn-id: http://skia.googlecode.com/svn/trunk@13323 2bbb7eff-a529-9590-31e7-b0007b416f81
Split off from https://codereview.chromium.org/140503007/.
The eventual goal is to create our Android.mk from gyp. This patch
adds an option for skia_android_framework with the right settings.
The follow-up (https://codereview.chromium.org/140503007/) will
use scripts to create the final makefile.
gyp/android_deps.gyp:
Use different dependencies for the framework than for building Skia
normally.
gyp/android_framework_lib.gyp:
Like skia_lib, specifies the minimum needed for building Skia, in this
case for the framework.
gyp/common_conditions.gypi:
Add settings specific to skia_android_framework. In some cases this
means turning off flags and defines.
gyp/common.gypi
Turn off SK_DEBUG and SK_DEVELOPER when building for the framework.
This allows the framework to create a single makefile which can be
modified to add SK_DEBUG and SK_DEVELOPER as desired.
gyp/common_variables.gypi:
Add skia_android_framework.
gyp/core.gyp:
Don't depend on cpufeatures, and add the cutils library for
skia_android_framework.
gyp/freetype.gyp:
skia_android_framework-specific options:
Don't include freetype_static as a dependency.
Include the proper folders.
Include the android library.
gyp/images.gyp:
Don't export libjpeg as a dependency for targets that include images
for the framework.
Also reorder image decoders to match the Android order, leaving our
most commonly used ones last (and therefore first in the chain for
trying them).
gyp/libwebp.gyp:
Use the system webp when building for the Android framework. Specify
the correct settings for the framework.
gyp/opts.gyp:
Specify a default set of files to compile when there are no possible
optimizations.
gyp/pdf.gyp:
Add dependencies for Android framework.
gyp/zlib.gyp:
Include the zlib folder, and undefine SK_ZLIB_INCLUDE.
BUG=skia:1975
R=djsollen@google.com
Committed: https://code.google.com/p/skia/source/detail?r=13298
Review URL: https://codereview.chromium.org/153093003
git-svn-id: http://skia.googlecode.com/svn/trunk@13304 2bbb7eff-a529-9590-31e7-b0007b416f81
Split off from https://codereview.chromium.org/140503007/.
The eventual goal is to create our Android.mk from gyp. This patch
adds an option for skia_android_framework with the right settings.
The follow-up (https://codereview.chromium.org/140503007/) will
use scripts to create the final makefile.
gyp/android_deps.gyp:
Use different dependencies for the framework than for building Skia
normally.
gyp/android_framework_lib.gyp:
Like skia_lib, specifies the minimum needed for building Skia, in this
case for the framework.
gyp/common_conditions.gypi:
Add settings specific to skia_android_framework. In some cases this
means turning off flags and defines.
gyp/common.gypi
Turn off SK_DEBUG and SK_DEVELOPER when building for the framework.
This allows the framework to create a single makefile which can be
modified to add SK_DEBUG and SK_DEVELOPER as desired.
gyp/common_variables.gypi:
Add skia_android_framework.
gyp/core.gyp:
Don't depend on cpufeatures, and add the cutils library for
skia_android_framework.
gyp/freetype.gyp:
skia_android_framework-specific options:
Don't include freetype_static as a dependency.
Include the proper folders.
Include the android library.
gyp/images.gyp:
Don't export libjpeg as a dependency for targets that include images
for the framework.
Also reorder image decoders to match the Android order, leaving our
most commonly used ones last (and therefore first in the chain for
trying them).
gyp/libwebp.gyp:
Use the system webp when building for the Android framework. Specify
the correct settings for the framework.
gyp/opts.gyp:
Specify a default set of files to compile when there are no possible
optimizations.
gyp/pdf.gyp:
Add dependencies for Android framework.
gyp/zlib.gyp:
Include the zlib folder, and undefine SK_ZLIB_INCLUDE.
BUG=skia:1975
R=djsollen@google.com
Review URL: https://codereview.chromium.org/153093003
git-svn-id: http://skia.googlecode.com/svn/trunk@13298 2bbb7eff-a529-9590-31e7-b0007b416f81
This patch includes a modified version of Chrome's trace_event.h, which provides
tracing macros that can easily integrate into the about://tracing framework.
Currently the macros link to a default implementation of the (narrow) tracing
class SkDefaultEventTracer which does nothing; next step will be to have Chrome
subclass the SkEventTracer with a shim that bolts Skia's trace events to its own,
allowing Skia's trace events to show up in about://tracing.
I've verified that this file builds properly, and when I added a simple scoped
TRACE_EVENT0 to SkCanvas::drawRect, along with some debug prints in the NOP
implementation of tracing, I saw what I expected printed to the screen.
BUG=skia:
R=nduca@chromium.org, reed@google.com, mtklein@google.com, bsalomon@google.com
Author: humper@google.com
Review URL: https://codereview.chromium.org/149563004
git-svn-id: http://skia.googlecode.com/svn/trunk@13256 2bbb7eff-a529-9590-31e7-b0007b416f81
Eliminates SkFlattenable{Read,Write}Buffer, promoting SkOrdered{Read,Write}Buffer
a step each in the hierarchy.
What used to be this:
SkFlattenableWriteBuffer -> SkOrderedWriteBuffer
SkFlattenableReadBuffer -> SkOrderedReadBuffer
SkFlattenableReadBuffer -> SkValidatingReadBuffer
is now
SkWriteBuffer
SkReadBuffer -> SkValidatingReadBuffer
Benefits:
- code is simpler, names are less wordy
- the generic SkFlattenableFooBuffer code in SkPaint was incorrect; removed
- write buffers are completely devirtualized, important for record speed
This refactoring was mostly mechanical. You aren't going to find anything
interesting in files with less than 10 lines changed.
BUG=skia:
R=reed@google.com, scroggo@google.com, djsollen@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/134163010
git-svn-id: http://skia.googlecode.com/svn/trunk@13245 2bbb7eff-a529-9590-31e7-b0007b416f81
BitmapProcState: new factorised code
This one basically factorises the clamp and repeat transformations with
some performance improvements. It has the benefit of being faster, much
easier to maintain (nearly three times less code for more work
done :-)), and more complete (all persp transformations weren't optimised
in the previous version).
It also introduces the use of can_truncate_to_fixed_for_decal where
useful.
The effect on benchmarks ranges from a 5% penalty to a 25% gain on a
Cortex-A9 and from a 5% penalty to a 100% gain on a Cortex-A15.
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
BUG=
R=djsollen@google.com, mtklein@google.com, luisjoseromeroesclusa@hotmail.com, reed@google.com
Author: kevin.petit.arm@gmail.com
Review URL: https://codereview.chromium.org/23835006
git-svn-id: http://skia.googlecode.com/svn/trunk@13218 2bbb7eff-a529-9590-31e7-b0007b416f81
This revealed that the displacement map was not handling clipping or upstream cropping at all well (the color would "swim" through the displacement at the edge of the clip rect). Fixed by passing through the correct offsets to the bitmap accesses in both raster and GPU paths. Same for morphology.
R=sugoi@google.com
Review URL: https://codereview.chromium.org/137053003
git-svn-id: http://skia.googlecode.com/svn/trunk@13127 2bbb7eff-a529-9590-31e7-b0007b416f81
Make leak counters implemented with SK_DECLARE_INST_COUNT thread-safe.
Enable the leak counting for Debug builds when Skia is built as a
static library. Having SK_DECLARE_INST_COUNT without
SK_DEFINE_INST_COUNT relies on static variables in member functions
declared in the header files. These might be duplicated in the clients
of the library when Skia is built as a dynamic library, producing
incorrect operation.
Protect the instance counter initialization step (initStep) by
using SkOnce.
Makes SkOnce.h part of the public API, since SkInstCnt is public.
Protect the per-class child list shared variable with a per-class mutex.
Changes the behavior in the way that if the child list has been
"cleaned up", it will still try to create subsequent child lists.
BUG=skia:1219
R=robertphillips@google.com, mtklein@google.com, bsalomon@google.com, bungeman@google.com, djsollen@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/99483003
git-svn-id: http://skia.googlecode.com/svn/trunk@13120 2bbb7eff-a529-9590-31e7-b0007b416f81
The Mac fontconfig just #defines the cache directory, which works fine if fontconfig never has to look up any fonts (the case until now). If it has to actually find fonts from the disk, the cache directory and config directory need to be properly defined as well as running fc-cache to populate the cache directory.
Populating the cache directory can take some time, but should only happen on a clean build. To remove this extra time, we have to not build poppler on Mac, which can now be accomplished with GYP_DEFINES="skia_mac_poppler=0"
R=epoger@google.com
Author: vandebo@chromium.org
Review URL: https://codereview.chromium.org/132333002
git-svn-id: http://skia.googlecode.com/svn/trunk@13007 2bbb7eff-a529-9590-31e7-b0007b416f81
The Mac fontconfig just #defines the cache directory, which works fine if fontconfig never has to look up any fonts (the case until now). If it has to actually find fonts from the disk, the cache directory and config directory need to be properly defined as well as running fc-cache to populate the cache directory.
Populating the cache directory can take some time, but should only happen on a clean build. To remove this extra time, we have to not build poppler on Mac, which can now be accomplished with GYP_DEFINES="skia_mac_poppler=0"
R=bungeman@google.com, epoger@google.com
Author: vandebo@chromium.org
Review URL: https://codereview.chromium.org/113203003
git-svn-id: http://skia.googlecode.com/svn/trunk@12994 2bbb7eff-a529-9590-31e7-b0007b416f81
This works in a way that is similar to SkData.
SkMallocPixelRef::NewWithProc
Motivation: Chrome has a ETC1PixelRef which calls delete[] on the
pixles on destruction. There is no reason for them to almost
duplicate our class, when we can provide them a more flexible
class. Example use:
static void delete_uint8_proc(void* ptr, void*) {
delete[] static_cast<uint8_t>(ptr);
}
SkPixelRef* new_delete_pixref(const SkImageInfo& info,
SkColorTable* ctable) {
size_t rb = info.minRowBytes();
return SkMallocPixelRef::NewWithProc(
info, rb, ctable,
new uint8_t[info.getSafeSize(rb)],
delete_uint8_proc, NULL);
}
SkMallocPixelRef::NewWithData
Motivation: This allows up to eliminate SkDataPixelRef. We
modified SkImage_Raster to use MallocPixelRef rather than
SkDataPixlRef.
Also: Unit tests in tests/MallocPixelRefTest.
BUG=
R=reed@google.com
Review URL: https://codereview.chromium.org/106883006
git-svn-id: http://skia.googlecode.com/svn/trunk@12861 2bbb7eff-a529-9590-31e7-b0007b416f81