Fixes for nacl_debugger's use of picture.

Now that CreateFromStream is used, check for NULL rather than
looking at width and height (prevents a crash on an invalid SKP).

Unref the picture when done with it.

Remove the member variable for picture, since it is only accessed
inside the one function.

R=borenet@google.com

Review URL: https://codereview.chromium.org/18055014

git-svn-id: http://skia.googlecode.com/svn/trunk@9831 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
scroggo@google.com 2013-07-01 12:42:49 +00:00
parent fa13a632a0
commit 6c4c3a5554

View File

@ -37,7 +37,6 @@ public:
explicit SkiaInstance(PP_Instance instance) explicit SkiaInstance(PP_Instance instance)
: pp::Instance(instance) : pp::Instance(instance)
, fCanvas(NULL) , fCanvas(NULL)
, fPicture(NULL)
, fFlushLoopRunning(false) , fFlushLoopRunning(false)
, fFlushPending(false) , fFlushPending(false)
@ -68,12 +67,13 @@ public:
return; return;
} }
SkMemoryStream pictureStream(decodedData.getData(), decodedSize); SkMemoryStream pictureStream(decodedData.getData(), decodedSize);
fPicture = SkPicture::CreateFromStream(&pictureStream); SkPicture* picture = SkPicture::CreateFromStream(&pictureStream);
if (fPicture->width() == 0 || fPicture->height() == 0) { if (NULL == picture) {
SkDebugf("Failed to create SKP.\n"); SkDebugf("Failed to create SKP.\n");
return; return;
} }
fDebugger.loadPicture(fPicture); fDebugger.loadPicture(picture);
picture->unref();
// Set up the command list. // Set up the command list.
SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings(); SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings();
@ -194,7 +194,6 @@ private:
SkBitmap fBitmap; SkBitmap fBitmap;
SkCanvas* fCanvas; SkCanvas* fCanvas;
SkDebugger fDebugger; SkDebugger fDebugger;
SkPicture* fPicture;
bool fFlushLoopRunning; bool fFlushLoopRunning;
bool fFlushPending; bool fFlushPending;