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

Side by Side Diff: platform_tools/nacl/src/nacl_debugger.cpp

Issue 18055014: Fixes for nacl_debugger's use of picture. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
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 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/graphics_2d.h" 10 #include "ppapi/cpp/graphics_2d.h"
(...skipping 19 matching lines...) Expand all
30 SkiaInstance* gPluginInstance; 30 SkiaInstance* gPluginInstance;
31 31
32 void FlushCallback(void* data, int32_t result); 32 void FlushCallback(void* data, int32_t result);
33 33
34 // Skia's subclass of pp::Instance, our interface with the browser. 34 // Skia's subclass of pp::Instance, our interface with the browser.
35 class SkiaInstance : public pp::Instance { 35 class SkiaInstance : public pp::Instance {
36 public: 36 public:
37 explicit SkiaInstance(PP_Instance instance) 37 explicit SkiaInstance(PP_Instance instance)
38 : pp::Instance(instance) 38 : pp::Instance(instance)
39 , fCanvas(NULL) 39 , fCanvas(NULL)
40 , fPicture(NULL)
41 , fFlushLoopRunning(false) 40 , fFlushLoopRunning(false)
42 , fFlushPending(false) 41 , fFlushPending(false)
43 42
44 { 43 {
45 gPluginInstance = this; 44 gPluginInstance = this;
46 SkGraphics::Init(); 45 SkGraphics::Init();
47 } 46 }
48 47
49 virtual ~SkiaInstance() { 48 virtual ~SkiaInstance() {
50 SkGraphics::Term(); 49 SkGraphics::Term();
(...skipping 10 matching lines...) Expand all
61 size_t dataSize = msg.size()/sizeof(char) - startIndex; 60 size_t dataSize = msg.size()/sizeof(char) - startIndex;
62 SkBase64 decodedData; 61 SkBase64 decodedData;
63 decodedData.decode(msg.c_str() + startIndex, dataSize); 62 decodedData.decode(msg.c_str() + startIndex, dataSize);
64 size_t decodedSize = 3 * (dataSize / 4); 63 size_t decodedSize = 3 * (dataSize / 4);
65 SkDebugf("Got size: %d\n", decodedSize); 64 SkDebugf("Got size: %d\n", decodedSize);
66 if (!decodedData.getData()) { 65 if (!decodedData.getData()) {
67 SkDebugf("Failed to decode SKP\n"); 66 SkDebugf("Failed to decode SKP\n");
68 return; 67 return;
69 } 68 }
70 SkMemoryStream pictureStream(decodedData.getData(), decodedSize) ; 69 SkMemoryStream pictureStream(decodedData.getData(), decodedSize) ;
71 fPicture = SkPicture::CreateFromStream(&pictureStream); 70 SkPicture* picture = SkPicture::CreateFromStream(&pictureStream) ;
72 if (fPicture->width() == 0 || fPicture->height() == 0) { 71 if (NULL == picture) {
73 SkDebugf("Failed to create SKP.\n"); 72 SkDebugf("Failed to create SKP.\n");
74 return; 73 return;
75 } 74 }
76 fDebugger.loadPicture(fPicture); 75 fDebugger.loadPicture(picture);
76 picture->unref();
77 77
78 // Set up the command list. 78 // Set up the command list.
79 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsString s(); 79 SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsString s();
80 PostMessage("ClearCommands"); 80 PostMessage("ClearCommands");
81 for (int i = 0; i < commands->count(); ++i) { 81 for (int i = 0; i < commands->count(); ++i) {
82 SkString addCommand("AddCommand:"); 82 SkString addCommand("AddCommand:");
83 addCommand.append((*commands)[i]); 83 addCommand.append((*commands)[i]);
84 PostMessage(addCommand.c_str()); 84 PostMessage(addCommand.c_str());
85 } 85 }
86 PostMessage("UpdateCommands"); 86 PostMessage("UpdateCommands");
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 private: 188 private:
189 pp::Graphics2D fDeviceContext; 189 pp::Graphics2D fDeviceContext;
190 pp::ImageData fImage; 190 pp::ImageData fImage;
191 int fWidth; 191 int fWidth;
192 int fHeight; 192 int fHeight;
193 193
194 SkBitmap fBitmap; 194 SkBitmap fBitmap;
195 SkCanvas* fCanvas; 195 SkCanvas* fCanvas;
196 SkDebugger fDebugger; 196 SkDebugger fDebugger;
197 SkPicture* fPicture;
198 197
199 bool fFlushLoopRunning; 198 bool fFlushLoopRunning;
200 bool fFlushPending; 199 bool fFlushPending;
201 }; 200 };
202 201
203 void FlushCallback(void* data, int32_t result) { 202 void FlushCallback(void* data, int32_t result) {
204 static_cast<SkiaInstance*>(data)->OnFlush(); 203 static_cast<SkiaInstance*>(data)->OnFlush();
205 } 204 }
206 205
207 class SkiaModule : public pp::Module { 206 class SkiaModule : public pp::Module {
208 public: 207 public:
209 SkiaModule() : pp::Module() {} 208 SkiaModule() : pp::Module() {}
210 virtual ~SkiaModule() {} 209 virtual ~SkiaModule() {}
211 210
212 virtual pp::Instance* CreateInstance(PP_Instance instance) { 211 virtual pp::Instance* CreateInstance(PP_Instance instance) {
213 return new SkiaInstance(instance); 212 return new SkiaInstance(instance);
214 } 213 }
215 }; 214 };
216 215
217 namespace pp { 216 namespace pp {
218 Module* CreateModule() { 217 Module* CreateModule() {
219 return new SkiaModule(); 218 return new SkiaModule();
220 } 219 }
221 } // namespace pp 220 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698