|
|
DescriptionMake SkFunction copyable so it can go in containers.
This totally overhauls the implementation to use ordinary inheritance-based type erasure. I give up for now getting my manual vtable shenanigans to work with MSVC. Still those same "expected ; before ), also expected ) before ;" errors.
I added support for uninitialized SkFunctions and operator=(), because it was fairly straightforward with this implementation.
The main downside here is that I've removed the inline implementation. All SkFunctions involve a heap allocation, even when just wrapping function pointers.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/0d992db1cf5003340409ed02993266004cc0a57c
Patch Set 1 #Patch Set 2 : tidier #Patch Set 3 : compiling #Patch Set 4 : is it this? #Patch Set 5 : prune down to minimum feature set #Patch Set 6 : real vtables #Patch Set 7 : FnPtrImpl #Patch Set 8 : TODO #Patch Set 9 : TODOs #
Total comments: 6
Patch Set 10 : ben #Messages
Total messages: 40 (17 generated)
mtklein@chromium.org changed reviewers: + bungeman@google.com
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/20001
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/40001
The CQ bit was checked by mtklein@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/60001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: Build-Win-MSVC-x86-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86-D...)
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/80001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot on client.skia (JOB_FAILED, http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2...) Build-Ubuntu-Clang-x86_64-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Ubuntu-Clang-x...)
Patchset #5 (id:80001) has been deleted
The CQ bit was checked by mtklein@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/60001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: Build-Win-MSVC-x86-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86-D...)
The CQ bit was checked by mtklein@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/100001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: Build-Win-MSVC-x86_64-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86_6...)
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/120001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by mtklein@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/180001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Righto Ben, PTAL if you can. I've given up fighting MSVC and fallen back to a simpler implementation that it likes.
https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h File src/core/SkFunction.h (right): https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h#... src/core/SkFunction.h:24: SkFunction(const Fn& fn) : fFunction(SkNEW_ARGS(LambdaImpl<Fn>, (fn))) {} It's been a while now, but not having the small function optimization makes these rather less useful from a performance standpoint doesn't it? In some cases it doesn't matter, but in some places it seemed like it did. https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h#... src/core/SkFunction.h:29: SkFunction& operator=(const SkFunction& other) { Check for self assignment?
https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h File src/core/SkFunction.h (right): https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h#... src/core/SkFunction.h:30: if (other.fFunction) { If the other guy doesn't have a function, shouldn't this not have a function as well?
https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h File src/core/SkFunction.h (right): https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h#... src/core/SkFunction.h:24: SkFunction(const Fn& fn) : fFunction(SkNEW_ARGS(LambdaImpl<Fn>, (fn))) {} On 2015/05/06 14:16:31, bungeman1 wrote: > It's been a while now, but not having the small function optimization makes > these rather less useful from a performance standpoint doesn't it? In some cases > it doesn't matter, but in some places it seemed like it did. Yes, for sure. But, not being able to copy SkFunctions makes them even less useful. https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h#... src/core/SkFunction.h:29: SkFunction& operator=(const SkFunction& other) { On 2015/05/06 14:16:31, bungeman1 wrote: > Check for self assignment? Done. https://codereview.chromium.org/1056673002/diff/180001/src/core/SkFunction.h#... src/core/SkFunction.h:30: if (other.fFunction) { On 2015/05/06 14:18:26, bungeman1 wrote: > If the other guy doesn't have a function, shouldn't this not have a function as > well? Ooh, yes, done. As you might imagine, that's a tricky situation to unit test.
Maybe with vc++14 something sane will be possible for the small function optimization. lgtm
On 2015/05/06 14:31:32, bungeman1 wrote: > Maybe with vc++14 something sane will be possible for the small function > optimization. > > lgtm Yeah, I'm still hopeful I can think of something, but I don't want to gate using this on that, at least in non-perf-critical spots. I was just looking to pilot it in a few spost in DM to start.
The CQ bit was checked by mtklein@google.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1056673002/200001
Message was sent while issue was closed.
Committed patchset #10 (id:200001) as https://skia.googlesource.com/skia/+/0d992db1cf5003340409ed02993266004cc0a57c |