Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Issue 849103004: Make SkStream *not* ref counted. (Closed)

Created:
5 years, 11 months ago by scroggo
Modified:
5 years, 11 months ago
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

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. Committed: https://skia.googlesource.com/skia/+/a1193e4b0e34a7e4e1bd33e9708d7341679f8321

Patch Set 1 #

Patch Set 2 : Add some more comments regarding SkStream ownership. #

Patch Set 3 : Update rasterizers. #

Patch Set 4 : Fix a compile error in gm. #

Patch Set 5 : Fix more Android/linux stream reffing. #

Patch Set 6 : Treat SkFontMgr::createFromStream as taking ownership of the stream (is this correct?) #

Total comments: 10

Patch Set 7 : Fixes for linux #

Patch Set 8 : Fix debugger; remove unnecessary rewind. #

Patch Set 9 : No more inst count stream; update comment. #

Patch Set 10 : fix src/utils/win/SkDWriteFontFileStream.cpp #

Patch Set 11 : rebase #

Patch Set 12 : Fix DM streams. #

Patch Set 13 : Pass duplicate stream to buildTileIndex. #

Patch Set 14 : Update SkImageDecoder_empty for chrome. #

Patch Set 15 : No need to duplicate - just detach a new one. #

Patch Set 16 : Rebase #

Patch Set 17 : Add SkStream::unref() for staging. #

Patch Set 18 : Remove another SkRef(SkStream). #

Patch Set 19 : Rebase #

Total comments: 6

Patch Set 20 : Delete streams in onCreateFromStream failures. #

Total comments: 2

Patch Set 21 : Remove unnecessary forward declare. #

Total comments: 2

Patch Set 22 : Fix a caller that needs a duplicate. #

Patch Set 23 : Rebase, just in case. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+274 lines, -337 lines) Patch
M bench/nanobench.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -1 line 0 comments Download
M debugger/QT/SkDebuggerGUI.cpp View 1 2 3 4 5 6 7 2 chunks +1 line, -3 lines 0 comments Download
M dm/DMSrcSink.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -1 line 0 comments Download
M dm/DMSrcSink.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +7 lines, -5 lines 0 comments Download
M experimental/PdfViewer/inc/SkPdfRenderer.h View 1 2 2 chunks +2 lines, -0 lines 0 comments Download
M experimental/PdfViewer/pdfparser/native/SkPdfNativeDoc.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M gm/coloremoji.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M gm/dcshader.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +2 lines, -2 lines 0 comments Download
M gm/dftext.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -2 lines 0 comments Download
M include/core/SkImageDecoder.h View 2 chunks +5 lines, -5 lines 0 comments Download
M include/core/SkPicture.h View 1 chunk +1 line, -1 line 0 comments Download
M include/core/SkStream.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +13 lines, -8 lines 0 comments Download
M include/core/SkTypeface.h View 1 2 chunks +2 lines, -0 lines 0 comments Download
M include/images/SkDecodingImageGenerator.h View 1 chunk +2 lines, -14 lines 0 comments Download
M include/utils/SkFrontBufferedStream.h View 1 chunk +4 lines, -2 lines 0 comments Download
M include/utils/mac/SkCGUtils.h View 1 chunk +7 lines, -10 lines 0 comments Download
M samplecode/SampleAnimator.cpp View 1 chunk +4 lines, -6 lines 0 comments Download
M src/animator/SkAnimateMaker.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/animator/SkAnimator.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/animator/SkDrawBitmap.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkFontDescriptor.h View 1 3 chunks +5 lines, -4 lines 0 comments Download
M src/core/SkFontMgr.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +3 lines, -2 lines 0 comments Download
M src/core/SkPaint.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkPictureData.h View 1 3 chunks +3 lines, -0 lines 0 comments Download
M src/core/SkStream.cpp View 6 chunks +6 lines, -6 lines 0 comments Download
M src/core/SkTypeface.cpp View 3 chunks +3 lines, -3 lines 0 comments Download
M src/device/xps/SkXPSDevice.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/fonts/SkFontMgr_fontconfig.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +4 lines, -3 lines 0 comments Download
M src/fonts/SkFontMgr_indirect.cpp View 1 2 3 4 5 1 chunk +4 lines, -4 lines 0 comments Download
M src/gpu/gl/GrGLPathRendering.cpp View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M src/images/SkDecodingImageGenerator.cpp View 5 chunks +7 lines, -11 lines 0 comments Download
M src/images/SkImageDecoder.cpp View 2 chunks +8 lines, -1 line 0 comments Download
M src/images/SkImageDecoder_libjpeg.cpp View 2 chunks +3 lines, -0 lines 0 comments Download
M src/images/SkImageDecoder_libpng.cpp View 1 2 3 4 4 chunks +4 lines, -3 lines 0 comments Download
M src/images/SkImageDecoder_libwebp.cpp View 4 chunks +3 lines, -6 lines 0 comments Download
M src/images/SkJpegUtility.h View 1 chunk +1 line, -2 lines 0 comments Download
M src/images/SkJpegUtility.cpp View 2 chunks +1 line, -5 lines 0 comments Download
M src/images/SkMovie.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/pdf/SkPDFFont.cpp View 6 chunks +6 lines, -6 lines 0 comments Download
M src/pdf/SkPDFFormXObject.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/pdf/SkPDFImage.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M src/pdf/SkPDFImage.cpp View 4 chunks +16 lines, -16 lines 0 comments Download
M src/pdf/SkPDFShader.cpp View 3 chunks +3 lines, -3 lines 0 comments Download
M src/pdf/SkPDFStream.h View 1 chunk +1 line, -4 lines 0 comments Download
M src/pdf/SkPDFStream.cpp View 2 chunks +5 lines, -11 lines 0 comments Download
M src/ports/SkFontConfigTypeface.h View 1 2 3 4 5 6 3 chunks +4 lines, -9 lines 0 comments Download
M src/ports/SkFontHost_FreeType.cpp View 1 2 3 4 5 6 7 8 1 chunk +8 lines, -11 lines 0 comments Download
M src/ports/SkFontHost_fontconfig.cpp View 1 2 3 4 5 6 7 2 chunks +2 lines, -5 lines 0 comments Download
M src/ports/SkFontHost_linux.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 chunks +7 lines, -8 lines 0 comments Download
M src/ports/SkFontHost_win.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2 chunks +4 lines, -4 lines 0 comments Download
M src/ports/SkFontMgr_android.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 chunks +8 lines, -8 lines 0 comments Download
M src/ports/SkFontMgr_fontconfig.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 chunks +7 lines, -9 lines 0 comments Download
M src/ports/SkFontMgr_win_dw.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 5 chunks +7 lines, -7 lines 0 comments Download
M src/ports/SkImageDecoder_empty.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +8 lines, -2 lines 0 comments Download
M src/ports/SkTypeface_win_dw.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/sfnt/SkOTUtils.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +2 lines, -0 lines 0 comments Download
M src/utils/SkFrontBufferedStream.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M src/utils/SkPDFRasterizer.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M src/utils/SkPDFRasterizer.cpp View 1 2 2 chunks +2 lines, -0 lines 0 comments Download
M src/utils/mac/SkStream_mac.cpp View 2 chunks +14 lines, -5 lines 0 comments Download
M src/utils/win/SkDWriteFontFileStream.h View 1 chunk +1 line, -1 line 0 comments Download
M src/utils/win/SkDWriteFontFileStream.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M src/views/animated/SkWidgetViews.cpp View 1 chunk +1 line, -1 line 0 comments Download
M tests/FontHostStreamTest.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M tests/FrontBufferedStreamTest.cpp View 6 chunks +24 lines, -21 lines 0 comments Download
M tests/ImageDecodingTest.cpp View 5 chunks +3 lines, -67 lines 0 comments Download
M tests/KtxTest.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/PDFPrimitivesTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M tests/SerializationTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M tests/StreamTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +7 lines, -7 lines 0 comments Download
M tools/dump_record.cpp View 1 chunk +1 line, -1 line 0 comments Download
M tools/lua/lua_pictures.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 27 (7 generated)
bungeman-skia
https://codereview.chromium.org/849103004/diff/100001/gm/gmmain.cpp File gm/gmmain.cpp (right): https://codereview.chromium.org/849103004/diff/100001/gm/gmmain.cpp#newcode1097 gm/gmmain.cpp:1097: documentStream->duplicate(), &pdfBitmap); I think you can just rewind and ...
5 years, 11 months ago (2015-01-15 22:44:56 UTC) #2
bungeman-skia
Looks like SkFontConfigTypeface.h and SkDWriteFontFileStream are the next files which need to be touched. https://codereview.chromium.org/849103004/diff/100001/src/ports/SkFontHost_fontconfig.cpp ...
5 years, 11 months ago (2015-01-15 22:56:04 UTC) #3
scroggo
Adding Hal, primarily to look at PDF stuff (but feel free to look at other ...
5 years, 11 months ago (2015-01-16 19:13:37 UTC) #5
bungeman-skia
SkDWriteFontFileStream.cpp will also need some changes, it at least calls SkRef on an SkStream.
5 years, 11 months ago (2015-01-16 19:24:52 UTC) #6
scroggo
On 2015/01/16 19:24:52, bungeman1 wrote: > SkDWriteFontFileStream.cpp will also need some changes, it at least ...
5 years, 11 months ago (2015-01-16 20:14:48 UTC) #7
hal.canary
On 2015/01/16 19:13:37, scroggo wrote: > Adding Hal, primarily to look at PDF stuff (but ...
5 years, 11 months ago (2015-01-16 23:32:56 UTC) #8
bungeman-skia
I believe that SkEmptyFontMgr::onCreateFromStream needs to delete the SkStream passed to it.
5 years, 11 months ago (2015-01-20 21:37:05 UTC) #9
bungeman-skia
https://codereview.chromium.org/849103004/diff/360001/src/fonts/SkFontMgr_fontconfig.cpp File src/fonts/SkFontMgr_fontconfig.cpp (right): https://codereview.chromium.org/849103004/diff/360001/src/fonts/SkFontMgr_fontconfig.cpp#newcode311 src/fonts/SkFontMgr_fontconfig.cpp:311: return NULL; Looks like we need to delete the ...
5 years, 11 months ago (2015-01-20 21:41:49 UTC) #10
scroggo
On 2015/01/20 21:37:05, bungeman1 wrote: > I believe that SkEmptyFontMgr::onCreateFromStream needs to delete the SkStream ...
5 years, 11 months ago (2015-01-20 22:19:09 UTC) #11
bungeman-skia
https://codereview.chromium.org/849103004/diff/380001/src/core/SkFontMgr.cpp File src/core/SkFontMgr.cpp (right): https://codereview.chromium.org/849103004/diff/380001/src/core/SkFontMgr.cpp#newcode14 src/core/SkFontMgr.cpp:14: class SkStream; Since we need to include now, should ...
5 years, 11 months ago (2015-01-20 22:23:54 UTC) #12
scroggo
https://codereview.chromium.org/849103004/diff/380001/src/core/SkFontMgr.cpp File src/core/SkFontMgr.cpp (right): https://codereview.chromium.org/849103004/diff/380001/src/core/SkFontMgr.cpp#newcode14 src/core/SkFontMgr.cpp:14: class SkStream; On 2015/01/20 22:23:54, bungeman1 wrote: > Since ...
5 years, 11 months ago (2015-01-20 22:25:15 UTC) #13
bungeman
https://codereview.chromium.org/849103004/diff/400001/src/ports/SkFontMgr_win_dw.cpp File src/ports/SkFontMgr_win_dw.cpp (right): https://codereview.chromium.org/849103004/diff/400001/src/ports/SkFontMgr_win_dw.cpp#newcode84 src/ports/SkFontMgr_win_dw.cpp:84: HR(SkDWriteFontFileStreamWrapper::Create(fStream, &stream)); fStream->duplicate() This is an existing bug, but ...
5 years, 11 months ago (2015-01-21 05:44:29 UTC) #14
scroggo
https://codereview.chromium.org/849103004/diff/400001/src/ports/SkFontMgr_win_dw.cpp File src/ports/SkFontMgr_win_dw.cpp (right): https://codereview.chromium.org/849103004/diff/400001/src/ports/SkFontMgr_win_dw.cpp#newcode84 src/ports/SkFontMgr_win_dw.cpp:84: HR(SkDWriteFontFileStreamWrapper::Create(fStream, &stream)); On 2015/01/21 05:44:29, bungeman wrote: > fStream->duplicate() ...
5 years, 11 months ago (2015-01-21 14:56:07 UTC) #15
bungeman-skia
PS23 lgtm.
5 years, 11 months ago (2015-01-21 17:01:12 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/849103004/440001
5 years, 11 months ago (2015-01-21 19:53:51 UTC) #18
commit-bot: I haz the power
Presubmit check for 849103004-440001 failed and returned exit status 1. Running presubmit commit checks ...
5 years, 11 months ago (2015-01-21 19:54:12 UTC) #20
scroggo
5 years, 11 months ago (2015-01-21 19:55:08 UTC) #22
reed1
lgtm
5 years, 11 months ago (2015-01-21 19:58:50 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/849103004/440001
5 years, 11 months ago (2015-01-21 20:00:55 UTC) #26
commit-bot: I haz the power
5 years, 11 months ago (2015-01-21 20:09:58 UTC) #27
Message was sent while issue was closed.
Committed patchset #23 (id:440001) as
https://skia.googlesource.com/skia/+/a1193e4b0e34a7e4e1bd33e9708d7341679f8321

Powered by Google App Engine
This is Rietveld 408576698