Remove SkDynamicMemoryWStream::getOffset.

This method does the same thing as ::bytesWritten but has a confusing
name. It appears there are no external users, so remove it.

Change-Id: I06aed269200c34c2dda36605092f8ea37fcec693
Reviewed-on: https://skia-review.googlesource.com/6188
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2016-12-16 16:51:41 +00:00 committed by Skia Commit-Bot
parent 9f67f044dd
commit 884300dca5
6 changed files with 18 additions and 20 deletions

View File

@ -385,16 +385,14 @@ public:
bool write(const void* buffer, size_t size) override;
size_t bytesWritten() const override;
bool read(void* buffer, size_t offset, size_t size);
// Why do we have this as a separate method???
size_t getOffset() const { return this->bytesWritten(); }
// copy what has been written to the stream into dst
/** More efficient version of read(dst, 0, bytesWritten()). */
void copyTo(void* dst) const;
void writeToStream(SkWStream* dst) const;
// Return the contents as SkData, and then reset the stream.
/** Return the contents as SkData, and then reset the stream. */
sk_sp<SkData> detachAsData();
/** Reset, returning a reader stream with the current content. */

View File

@ -1800,7 +1800,7 @@ SkPDFDevice::ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* cli
}
SkPDFDevice::ContentEntry* entry;
if (fContentEntries.back() && fContentEntries.back()->fContent.getOffset() == 0) {
if (fContentEntries.back() && fContentEntries.back()->fContent.bytesWritten() == 0) {
entry = fContentEntries.back();
} else if (blendMode != SkBlendMode::kDstOver) {
entry = fContentEntries.emplace_back();
@ -1830,7 +1830,7 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
}
if (blendMode == SkBlendMode::kDstOver) {
SkASSERT(!dst);
if (fContentEntries.front()->fContent.getOffset() == 0) {
if (fContentEntries.front()->fContent.bytesWritten() == 0) {
// For DstOver, an empty content entry was inserted before the rest
// of the content entries. If nothing was drawn, it needs to be
// removed.
@ -1974,7 +1974,7 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
}
bool SkPDFDevice::isContentEmpty() {
if (!fContentEntries.front() || fContentEntries.front()->fContent.getOffset() == 0) {
if (!fContentEntries.front() || fContentEntries.front()->fContent.bytesWritten() == 0) {
SkASSERT(fContentEntries.count() <= 1);
return true;
}

View File

@ -261,7 +261,7 @@ void SkParsePath::ToSVGString(const SkPath& path, SkString* str) {
stream.write("Z", 1);
break;
case SkPath::kDone_Verb:
str->resize(stream.getOffset());
str->resize(stream.bytesWritten());
stream.copyTo(str->writable_str());
return;
}

View File

@ -90,7 +90,7 @@ endbfchar\n\
endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult,
buffer.getOffset()));
buffer.bytesWritten()));
// Remove characters and ranges.
buffer.reset();
@ -108,7 +108,7 @@ endbfchar\n\
endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResultChop1,
buffer.getOffset()));
buffer.bytesWritten()));
// Remove characters from range to downdrade it to one char.
buffer.reset();
@ -122,7 +122,7 @@ endbfrange\n";
endbfchar\n";
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResultChop2,
buffer.getOffset()));
buffer.bytesWritten()));
buffer.reset();
@ -139,7 +139,7 @@ endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer, 0,
expectedResultSingleBytes,
buffer.getOffset()));
buffer.bytesWritten()));
glyphToUnicode.reset();
glyphsInSubset.reset();
@ -176,5 +176,5 @@ endbfchar\n\
endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2,
buffer2.getOffset()));
buffer2.bytesWritten()));
}

View File

@ -33,7 +33,7 @@ DEF_TEST(SkPDF_OpaqueSrcModeToSrcOver, r) {
U8CPU alpha = SK_AlphaOPAQUE;
run_test(&srcMode, SkBlendMode::kSrc, alpha);
run_test(&srcOverMode, SkBlendMode::kSrcOver, alpha);
REPORTER_ASSERT(r, srcMode.getOffset() == srcOverMode.getOffset());
REPORTER_ASSERT(r, srcMode.bytesWritten() == srcOverMode.bytesWritten());
// The two PDFs should be equal because they have an opaque alpha.
srcMode.reset();
@ -42,6 +42,6 @@ DEF_TEST(SkPDF_OpaqueSrcModeToSrcOver, r) {
alpha = 0x80;
run_test(&srcMode, SkBlendMode::kSrc, alpha);
run_test(&srcOverMode, SkBlendMode::kSrcOver, alpha);
REPORTER_ASSERT(r, srcMode.getOffset() > srcOverMode.getOffset());
REPORTER_ASSERT(r, srcMode.bytesWritten() > srcOverMode.bytesWritten());
// The two PDFs should not be equal because they have a non-opaque alpha.
}

View File

@ -84,7 +84,7 @@ static void TestWStream(skiatest::Reporter* reporter) {
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, ds.write(s, 26));
}
REPORTER_ASSERT(reporter, ds.getOffset() == 100 * 26);
REPORTER_ASSERT(reporter, ds.bytesWritten() == 100 * 26);
char* dst = new char[100 * 26 + 1];
dst[100*26] = '*';
@ -97,7 +97,7 @@ static void TestWStream(skiatest::Reporter* reporter) {
{
std::unique_ptr<SkStreamAsset> stream(ds.detachAsStream());
REPORTER_ASSERT(reporter, 100 * 26 == stream->getLength());
REPORTER_ASSERT(reporter, ds.getOffset() == 0);
REPORTER_ASSERT(reporter, ds.bytesWritten() == 0);
test_loop_stream(reporter, stream.get(), s, 26, 100);
std::unique_ptr<SkStreamAsset> stream2(stream->duplicate());
@ -115,12 +115,12 @@ static void TestWStream(skiatest::Reporter* reporter) {
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, ds.write(s, 26));
}
REPORTER_ASSERT(reporter, ds.getOffset() == 100 * 26);
REPORTER_ASSERT(reporter, ds.bytesWritten() == 100 * 26);
{
// Test that this works after a snapshot.
std::unique_ptr<SkStreamAsset> stream(ds.detachAsStream());
REPORTER_ASSERT(reporter, ds.getOffset() == 0);
REPORTER_ASSERT(reporter, ds.bytesWritten() == 0);
test_loop_stream(reporter, stream.get(), s, 26, 100);
std::unique_ptr<SkStreamAsset> stream2(stream->duplicate());