|
|
Created:
4 years, 4 months ago by hal.canary Modified:
4 years, 4 months ago Reviewers:
bungeman-skia CC:
reviews_skia.org Base URL:
https://skia.googlesource.com/skia.git@master Target Ref:
refs/heads/master Project:
skia Visibility:
Public. |
DescriptionSkPDF: refactor font subset: fewer copies
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2190643002
Committed: https://skia.googlesource.com/skia/+/fe8f0e0d3126d27fe9fdd5bc4804392492f14e51
Patch Set 1 #Patch Set 2 : 2016-07-27 (Wednesday) 11:47:36 EDT #Patch Set 3 : 2016-07-27 (Wednesday) 14:24:06 EDT #
Total comments: 2
Patch Set 4 : 2016-07-27 (Wednesday) 15:53:56 EDT #
Total comments: 4
Patch Set 5 : 2016-07-27 (Wednesday) 16:22:36 EDT #
Messages
Total messages: 32 (20 generated)
Description was changed from ========== SkPDF: refactor font subset: fewer copies BUG=skia: ========== to ========== SkPDF: refactor font subset: fewer copies BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2190643002 ==========
The CQ bit was checked by halcanary@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by halcanary@google.com
halcanary@google.com changed reviewers: + bungeman@google.com
PTAL Note: all gm/skp PDFs are identical.
rebased. take another look.
The CQ bit was checked by halcanary@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2190643002/diff/40001/src/pdf/SkPDFFont.cpp File src/pdf/SkPDFFont.cpp (right): https://codereview.chromium.org/2190643002/diff/40001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:1033: fontAsset.reset(this->typeface()->openStream(&ttcIndex)); Hopefully it doesn't matter too much, but note that this means 'fontData' and 'fontAsset' are both active here, meaning that there may be two copies / mmaps of the same data in memory (and the the 'subsetFont' data as well). Indeed, the lifetime of 'fontData' appears to just be around the call to SubsetFont, it could go away even before making the SkPDFStream. I know inlining this made some of this more straight forward, but the five levels of indentation plus indentation for expression continuation makes this much more difficult to take in.
Patchset #4 (id:60001) has been deleted
The CQ bit was checked by halcanary@google.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
good catches! https://codereview.chromium.org/2190643002/diff/40001/src/pdf/SkPDFFont.cpp File src/pdf/SkPDFFont.cpp (right): https://codereview.chromium.org/2190643002/diff/40001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:1033: fontAsset.reset(this->typeface()->openStream(&ttcIndex)); On 2016/07/27 19:26:44, bungeman-skia wrote: > Hopefully it doesn't matter too much, but note that this means 'fontData' and > 'fontAsset' are both active here, meaning that there may be two copies / mmaps > of the same data in memory Fixed. now fontData is out of scope (in another fn) before this call. > (and the the 'subsetFont' data as well). nope. > Indeed, the > lifetime of 'fontData' appears to just be around the call to SubsetFont, it > could go away even before making the SkPDFStream. done. > I know inlining this made some of this more straight forward, but the five > levels of indentation plus indentation for expression continuation makes this > much more difficult to take in. fixed.
good catches! https://codereview.chromium.org/2190643002/diff/40001/src/pdf/SkPDFFont.cpp File src/pdf/SkPDFFont.cpp (right): https://codereview.chromium.org/2190643002/diff/40001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:1033: fontAsset.reset(this->typeface()->openStream(&ttcIndex)); On 2016/07/27 19:26:44, bungeman-skia wrote: > Hopefully it doesn't matter too much, but note that this means 'fontData' and > 'fontAsset' are both active here, meaning that there may be two copies / mmaps > of the same data in memory Fixed. now fontData is out of scope (in another fn) before this call. > (and the the 'subsetFont' data as well). nope. > Indeed, the > lifetime of 'fontData' appears to just be around the call to SubsetFont, it > could go away even before making the SkPDFStream. done. > I know inlining this made some of this more straight forward, but the five > levels of indentation plus indentation for expression continuation makes this > much more difficult to take in. fixed.
The CQ bit was unchecked by halcanary@google.com
https://codereview.chromium.org/2190643002/diff/80001/src/pdf/SkPDFFont.cpp File src/pdf/SkPDFFont.cpp (right): https://codereview.chromium.org/2190643002/diff/80001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:994: fontData = nullptr; // Release memory if necessary. Instead of doing this, can this be like unsigned char* subsetFont = nullptr; int subsetFontSize = 0; { sk_sp<SkData> fontData(...); subsetFontSize = ... } or even something roughly like unsigned char* subsetFont = nullptr; int subsetFontSize = [&]() { sk_sp<SkData> fontData(...); return SfntlyWrapper::SubsetFont( ... ); } so that fontData just naturally goes out of scope. https://codereview.chromium.org/2190643002/diff/80001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:996: if (subsetFontSize > 0) { Can we reverse this so that less code goes into the block. if (subsetFontSize < 1) { return nullptr; } ... Then the code that's currently in the block is less indented, so it can fit more per line. Also, the 'successful' 'return subset;' really wants to be on the last line of this function.
The CQ bit was checked by halcanary@google.com to run a CQ dry run
https://codereview.chromium.org/2190643002/diff/80001/src/pdf/SkPDFFont.cpp File src/pdf/SkPDFFont.cpp (right): https://codereview.chromium.org/2190643002/diff/80001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:994: fontData = nullptr; // Release memory if necessary. On 2016/07/27 20:15:59, bungeman-skia wrote: > Instead of doing this, can this be like > > unsigned char* subsetFont = nullptr; > int subsetFontSize = 0; > { > sk_sp<SkData> fontData(...); > subsetFontSize = ... > } > > or even something roughly like > > unsigned char* subsetFont = nullptr; > int subsetFontSize = [&]() { > sk_sp<SkData> fontData(...); > return SfntlyWrapper::SubsetFont( ... ); > } > > so that fontData just naturally goes out of scope. Done. https://codereview.chromium.org/2190643002/diff/80001/src/pdf/SkPDFFont.cpp#n... src/pdf/SkPDFFont.cpp:996: if (subsetFontSize > 0) { On 2016/07/27 20:15:59, bungeman-skia wrote: > Can we reverse this so that less code goes into the block. > > if (subsetFontSize < 1) { > return nullptr; > } > > ... > > Then the code that's currently in the block is less indented, so it can fit more > per line. Also, the 'successful' 'return subset;' really wants to be on the last > line of this function. Done.
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
So long as tomhudson is ok with your use of auto, lgtm.
everywhere I use auto is with sk_make_sp
The CQ bit was unchecked by halcanary@google.com
The CQ bit was checked by halcanary@google.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by halcanary@google.com
The CQ bit was checked by halcanary@google.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== SkPDF: refactor font subset: fewer copies BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2190643002 ========== to ========== SkPDF: refactor font subset: fewer copies BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2190643002 Committed: https://skia.googlesource.com/skia/+/fe8f0e0d3126d27fe9fdd5bc4804392492f14e51 ==========
Message was sent while issue was closed.
Committed patchset #5 (id:100001) as https://skia.googlesource.com/skia/+/fe8f0e0d3126d27fe9fdd5bc4804392492f14e51 |