Chromium Code Reviews| Index: debugger/QT/SkImageWidget.cpp |
| =================================================================== |
| --- debugger/QT/SkImageWidget.cpp (revision 9448) |
| +++ debugger/QT/SkImageWidget.cpp (working copy) |
| @@ -15,6 +15,17 @@ |
| : QWidget() |
| , fDebugger(debugger) { |
| this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}"); |
| + |
|
jvanverth1
2013/06/05 21:48:02
Why not declare fPixels as char fPixels[4*kImageWi
robertphillips
2013/06/05 22:00:12
Done.
|
| + int rowBytes = kImageWidgetWidth * 4; |
| + fPixels = new char[kImageWidgetHeight * rowBytes]; |
| + |
| + SkImage::Info info; |
| + info.fWidth = kImageWidgetWidth; |
| + info.fHeight = kImageWidgetHeight; |
| + info.fColorType = SkImage::kPMColor_ColorType; |
| + info.fAlphaType = SkImage::kPremul_AlphaType; |
| + |
| + fSurface = SkSurface::NewRasterDirect(info, fPixels, rowBytes); |
| } |
| void SkImageWidget::paintEvent(QPaintEvent* event) { |
| @@ -32,18 +43,14 @@ |
| if (0 != commands.count()) { |
| SkDrawCommand* command = commands[fDebugger->index()]; |
| - const SkBitmap* bitmap = command->getBitmap(); |
| - |
| - if (NULL != bitmap) { |
| - bitmap->lockPixels(); |
| - |
| + if (command->render(fSurface->getCanvas())) { |
| QPoint origin(0,0); |
| - QImage image((uchar *)bitmap->getPixels(), bitmap->width(), |
| - bitmap->height(), QImage::Format_ARGB32_Premultiplied); |
| + QImage image((uchar*) fPixels, |
| + kImageWidgetWidth, |
| + kImageWidgetHeight, |
| + QImage::Format_ARGB32_Premultiplied); |
| painter.drawImage(origin, image); |
| - |
| - bitmap->unlockPixels(); |
| } else { |
| painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight); |
| } |