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

Unified Diff: src/core/SkPictureShader.cpp

Issue 238253005: Fixes for SkPictureShader. (Closed) Base URL: https://skia.googlesource.com/skia.git@shaders
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkShader.h ('k') | tests/PictureShaderTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureShader.cpp
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 15df3a37a587f253f0634558517a09e141bce63a..bf312851ab3bb33b81d4a0b116d1549f96eea352 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -19,28 +19,25 @@
#endif
SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy)
- : fPicture(picture)
+ : fPicture(SkRef(picture))
, fTmx(tmx)
- , fTmy(tmy) {
- SkSafeRef(fPicture);
-}
+ , fTmy(tmy) { }
SkPictureShader::SkPictureShader(SkReadBuffer& buffer)
: INHERITED(buffer) {
fTmx = static_cast<SkShader::TileMode>(buffer.read32());
fTmy = static_cast<SkShader::TileMode>(buffer.read32());
- if (buffer.readBool()) {
- fPicture = SkPicture::CreateFromBuffer(buffer);
- } else {
- fPicture = NULL;
- }
+ fPicture = SkPicture::CreateFromBuffer(buffer);
}
SkPictureShader::~SkPictureShader() {
- SkSafeUnref(fPicture);
+ fPicture->unref();
}
SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy) {
+ if (!picture || 0 == picture->width() || 0 == picture->height()) {
+ return NULL;
+ }
return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy));
}
@@ -49,16 +46,11 @@ void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
buffer.write32(fTmx);
buffer.write32(fTmy);
- buffer.writeBool(NULL != fPicture);
- if (fPicture) {
- fPicture->flatten(buffer);
- }
+ fPicture->flatten(buffer);
}
bool SkPictureShader::buildBitmapShader(const SkMatrix& matrix) const {
- if (!fPicture || (0 == fPicture->width() && 0 == fPicture->height())) {
- return false;
- }
+ SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0);
SkMatrix m;
if (this->hasLocalMatrix()) {
« no previous file with comments | « include/core/SkShader.h ('k') | tests/PictureShaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698