| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 default: | 102 default: |
| 103 SkDebugf("DrawType error 0x%08x\n", drawType); | 103 SkDebugf("DrawType error 0x%08x\n", drawType); |
| 104 SkASSERT(0); | 104 SkASSERT(0); |
| 105 break; | 105 break; |
| 106 } | 106 } |
| 107 SkASSERT(0); | 107 SkASSERT(0); |
| 108 return NULL; | 108 return NULL; |
| 109 } | 109 } |
| 110 #endif | 110 #endif |
| 111 | 111 |
| 112 #ifdef SK_DEBUG_VALIDATE | |
| 113 static void validateMatrix(const SkMatrix* matrix) { | |
| 114 SkScalar scaleX = matrix->getScaleX(); | |
| 115 SkScalar scaleY = matrix->getScaleY(); | |
| 116 SkScalar skewX = matrix->getSkewX(); | |
| 117 SkScalar skewY = matrix->getSkewY(); | |
| 118 SkScalar perspX = matrix->getPerspX(); | |
| 119 SkScalar perspY = matrix->getPerspY(); | |
| 120 if (scaleX != 0 && skewX != 0) | |
| 121 SkDebugf("scaleX != 0 && skewX != 0\n"); | |
| 122 SkASSERT(scaleX == 0 || skewX == 0); | |
| 123 SkASSERT(scaleY == 0 || skewY == 0); | |
| 124 SkASSERT(perspX == 0); | |
| 125 SkASSERT(perspY == 0); | |
| 126 } | |
| 127 #endif | |
| 128 | |
| 129 | |
| 130 /////////////////////////////////////////////////////////////////////////////// | 112 /////////////////////////////////////////////////////////////////////////////// |
| 131 | 113 |
| 132 // fRecord OK | 114 // fRecord OK |
| 133 SkPicture::SkPicture() | 115 SkPicture::SkPicture() |
| 134 : fWidth(0) | 116 : fWidth(0) |
| 135 , fHeight(0) | 117 , fHeight(0) |
| 136 , fRecordWillPlayBackBitmaps(false) { | 118 , fRecordWillPlayBackBitmaps(false) { |
| 137 this->needsNewGenID(); | 119 this->needsNewGenID(); |
| 138 } | 120 } |
| 139 | 121 |
| 140 // fRecord OK | 122 // fRecord OK |
| 141 SkPicture::SkPicture(int width, int height, | 123 SkPicture::SkPicture(int width, int height, |
| 142 const SkPictureRecord& record, | 124 const SkPictureRecord& record, |
| 143 bool deepCopyOps) | 125 bool deepCopyOps) |
| 144 : fWidth(width) | 126 : fWidth(width) |
| 145 , fHeight(height) | 127 , fHeight(height) |
| 146 , fRecordWillPlayBackBitmaps(false) { | 128 , fRecordWillPlayBackBitmaps(false) { |
| 147 this->needsNewGenID(); | 129 this->needsNewGenID(); |
| 148 | 130 |
| 149 SkPictInfo info; | 131 SkPictInfo info; |
| 150 this->createHeader(&info); | 132 this->createHeader(&info); |
| 151 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); | 133 fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps))); |
| 152 } | 134 } |
| 153 | 135 |
| 154 // The simplest / safest way to copy an SkRecord is to replay it into a new one. | |
| 155 static SkRecord* copy(const SkRecord& src, int width, int height) { | |
| 156 SkRecord* dst = SkNEW(SkRecord); | |
| 157 SkRecorder recorder(dst, width, height); | |
| 158 SkRecordDraw(src, &recorder); | |
| 159 return dst; | |
| 160 } | |
| 161 | |
| 162 // Create an SkPictureData-backed SkPicture from an SkRecord. | 136 // Create an SkPictureData-backed SkPicture from an SkRecord. |
| 163 // This for compatibility with serialization code only. This is not cheap. | 137 // This for compatibility with serialization code only. This is not cheap. |
| 164 static SkPicture* backport(const SkRecord& src, int width, int height) { | 138 static SkPicture* backport(const SkRecord& src, int width, int height) { |
| 165 SkPictureRecorder recorder; | 139 SkPictureRecorder recorder; |
| 166 SkRecordDraw(src, recorder.beginRecording(width, height)); | 140 SkRecordDraw(src, recorder.beginRecording(width, height)); |
| 167 return recorder.endRecording(); | 141 return recorder.endRecording(); |
| 168 } | 142 } |
| 169 | 143 |
| 170 // fRecord OK | 144 // fRecord OK |
| 171 SkPicture::SkPicture(const SkPicture& src) : INHERITED() { | |
| 172 this->needsNewGenID(); | |
| 173 fWidth = src.fWidth; | |
| 174 fHeight = src.fHeight; | |
| 175 fRecordWillPlayBackBitmaps = src.fRecordWillPlayBackBitmaps; | |
| 176 | |
| 177 if (NULL != src.fData.get()) { | |
| 178 fData.reset(SkNEW_ARGS(SkPictureData, (*src.fData))); | |
| 179 fUniqueID = src.uniqueID(); // need to call method to ensure != 0 | |
| 180 } | |
| 181 | |
| 182 if (NULL != src.fRecord.get()) { | |
| 183 fRecord.reset(copy(*src.fRecord, fWidth, fHeight)); | |
| 184 fUniqueID = src.uniqueID(); // need to call method to ensure != 0 | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 // fRecord OK | |
| 189 SkPicture::~SkPicture() {} | 145 SkPicture::~SkPicture() {} |
| 190 | 146 |
| 191 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 147 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
| 192 // fRecord TODO, fix by deleting this method | 148 // fRecord TODO, fix by deleting this method |
| 193 SkPicture* SkPicture::clone() const { | 149 SkPicture* SkPicture::clone() const { |
| 194 SkPicture* clonedPicture = SkNEW(SkPicture); | 150 SkPicture* clonedPicture = SkNEW(SkPicture); |
| 195 this->clone(clonedPicture, 1); | 151 this->clone(clonedPicture, 1); |
| 196 return clonedPicture; | 152 return clonedPicture; |
| 197 } | 153 } |
| 198 | 154 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 } | 499 } |
| 544 | 500 |
| 545 // fRecord OK | 501 // fRecord OK |
| 546 SkPicture::SkPicture(int width, int height, SkRecord* record) | 502 SkPicture::SkPicture(int width, int height, SkRecord* record) |
| 547 : fWidth(width) | 503 : fWidth(width) |
| 548 , fHeight(height) | 504 , fHeight(height) |
| 549 , fRecord(record) | 505 , fRecord(record) |
| 550 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { | 506 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { |
| 551 this->needsNewGenID(); | 507 this->needsNewGenID(); |
| 552 } | 508 } |
| OLD | NEW |