Remove SkPicture copy constructor

Given where we're heading with SkPicture why would you need to make a copy?

R=reed@google.com, mtklein@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/381133002
This commit is contained in:
robertphillips 2014-07-13 07:55:53 -07:00 committed by Commit bot
parent b184f7f52b
commit dd528967fc
6 changed files with 2 additions and 90 deletions

View File

@ -64,10 +64,6 @@ public:
};
SkPicture();
/** Make a copy of the contents of src. If src records more drawing after
this call, those elements will not appear in this picture.
*/
SkPicture(const SkPicture& src);
/** PRIVATE / EXPERIMENTAL -- do not call */
void EXPERIMENTAL_addAccelData(const AccelData*) const;
@ -178,7 +174,6 @@ public:
/**
* Returns true if any bitmaps may be produced when this SkPicture
* is replayed.
* Returns false if called while still recording.
*/
bool willPlayBackBitmaps() const;
@ -255,9 +250,6 @@ private:
SkPicture(int width, int height, const SkPictureRecord& record, bool deepCopyOps);
static void WriteTagSize(SkWriteBuffer& buffer, uint32_t tag, size_t size);
static void WriteTagSize(SkWStream* stream, uint32_t tag, size_t size);
// An OperationList encapsulates a set of operation offsets into the picture byte
// stream along with the CTMs needed for those operation.
class OperationList : ::SkNoncopyable {

View File

@ -1359,13 +1359,11 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
}
if (kPicture_DeviceType == fDeviceType) {
SkAutoTUnref<SkPicture> picture(fRecorder.endRecording());
SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
if (true) {
SkPicture* pict = new SkPicture(*picture);
this->installDrawFilter(orig);
orig->drawPicture(pict);
pict->unref();
orig->drawPicture(picture);
} else if (true) {
SkDynamicMemoryWStream ostream;
picture->serialize(&ostream);

View File

@ -109,24 +109,6 @@ const char* DrawTypeToString(DrawType drawType) {
}
#endif
#ifdef SK_DEBUG_VALIDATE
static void validateMatrix(const SkMatrix* matrix) {
SkScalar scaleX = matrix->getScaleX();
SkScalar scaleY = matrix->getScaleY();
SkScalar skewX = matrix->getSkewX();
SkScalar skewY = matrix->getSkewY();
SkScalar perspX = matrix->getPerspX();
SkScalar perspY = matrix->getPerspY();
if (scaleX != 0 && skewX != 0)
SkDebugf("scaleX != 0 && skewX != 0\n");
SkASSERT(scaleX == 0 || skewX == 0);
SkASSERT(scaleY == 0 || skewY == 0);
SkASSERT(perspX == 0);
SkASSERT(perspY == 0);
}
#endif
///////////////////////////////////////////////////////////////////////////////
// fRecord OK
@ -151,14 +133,6 @@ SkPicture::SkPicture(int width, int height,
fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps)));
}
// The simplest / safest way to copy an SkRecord is to replay it into a new one.
static SkRecord* copy(const SkRecord& src, int width, int height) {
SkRecord* dst = SkNEW(SkRecord);
SkRecorder recorder(dst, width, height);
SkRecordDraw(src, &recorder);
return dst;
}
// Create an SkPictureData-backed SkPicture from an SkRecord.
// This for compatibility with serialization code only. This is not cheap.
static SkPicture* backport(const SkRecord& src, int width, int height) {
@ -167,24 +141,6 @@ static SkPicture* backport(const SkRecord& src, int width, int height) {
return recorder.endRecording();
}
// fRecord OK
SkPicture::SkPicture(const SkPicture& src) : INHERITED() {
this->needsNewGenID();
fWidth = src.fWidth;
fHeight = src.fHeight;
fRecordWillPlayBackBitmaps = src.fRecordWillPlayBackBitmaps;
if (NULL != src.fData.get()) {
fData.reset(SkNEW_ARGS(SkPictureData, (*src.fData)));
fUniqueID = src.uniqueID(); // need to call method to ensure != 0
}
if (NULL != src.fRecord.get()) {
fRecord.reset(copy(*src.fRecord, fWidth, fHeight));
fUniqueID = src.uniqueID(); // need to call method to ensure != 0
}
}
// fRecord OK
SkPicture::~SkPicture() {}

View File

@ -191,31 +191,6 @@ SkPictureData::SkPictureData(const SkPictureData& src, SkPictCopyInfo* deepCopyI
}
}
}
#else
SkPictureData::SkPictureData(const SkPictureData& src) : fInfo(src.fInfo) {
this->init();
fBitmapHeap.reset(SkSafeRef(src.fBitmapHeap.get()));
fPathHeap.reset(SkSafeRef(src.fPathHeap.get()));
fOpData = SkSafeRef(src.fOpData);
fBoundingHierarchy = src.fBoundingHierarchy;
fStateTree = src.fStateTree;
fContentInfo.set(src.fContentInfo);
SkSafeRef(fBoundingHierarchy);
SkSafeRef(fStateTree);
fBitmaps = SkSafeRef(src.fBitmaps);
fPaints = SkSafeRef(src.fPaints);
fPictureCount = src.fPictureCount;
fPictureRefs = SkNEW_ARRAY(const SkPicture*, fPictureCount);
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i] = SkRef(src.fPictureRefs[i]);
}
}
#endif//SK_SUPPORT_LEGACY_PICTURE_CLONE
void SkPictureData::init() {

View File

@ -132,8 +132,6 @@ class SkPictureData {
public:
#ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE
SkPictureData(const SkPictureData& src, SkPictCopyInfo* deepCopyInfo = NULL);
#else
SkPictureData(const SkPictureData& src);
#endif
SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCopyOps);
static SkPictureData* CreateFromStream(SkStream*,

View File

@ -1536,13 +1536,6 @@ static void test_gen_id(skiatest::Reporter* reporter) {
// both pictures should have different ids
REPORTER_ASSERT(reporter, hasData->uniqueID() != empty.uniqueID());
// test out copy constructor
SkPicture copyWithData(*hasData);
REPORTER_ASSERT(reporter, hasData->uniqueID() == copyWithData.uniqueID());
SkPicture emptyCopy(empty);
REPORTER_ASSERT(reporter, empty.uniqueID() != emptyCopy.uniqueID());
}
DEF_TEST(Picture, reporter) {