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

Side by Side Diff: debugger/QT/SkImageWidget.cpp

Issue 15907023: Make SkDrawCommands lighter weight (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review comments Created 7 years, 6 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 | « debugger/QT/SkImageWidget.h ('k') | debugger/SkDebugCanvas.cpp » ('j') | 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 2012 Google Inc. 3 * Copyright 2012 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 <QtGui> 9 #include <QtGui>
10 10
11 #include "SkDebugger.h" 11 #include "SkDebugger.h"
12 #include "SkImageWidget.h" 12 #include "SkImageWidget.h"
13 13
14 SkImageWidget::SkImageWidget(SkDebugger *debugger) 14 SkImageWidget::SkImageWidget(SkDebugger *debugger)
15 : QWidget() 15 : QWidget()
16 , fDebugger(debugger) { 16 , fDebugger(debugger) {
17 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc cccc;}"); 17 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc cccc;}");
18
19 SkImage::Info info;
20 info.fWidth = kImageWidgetWidth;
21 info.fHeight = kImageWidgetHeight;
22 info.fColorType = SkImage::kPMColor_ColorType;
23 info.fAlphaType = SkImage::kPremul_AlphaType;
24
25 fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth);
18 } 26 }
19 27
20 void SkImageWidget::paintEvent(QPaintEvent* event) { 28 void SkImageWidget::paintEvent(QPaintEvent* event) {
21 if (this->isHidden()) { 29 if (this->isHidden()) {
22 return; 30 return;
23 } 31 }
24 32
25 QPainter painter(this); 33 QPainter painter(this);
26 QStyleOption opt; 34 QStyleOption opt;
27 opt.init(this); 35 opt.init(this);
28 36
29 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); 37 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
30 38
31 const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands(); 39 const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands();
32 if (0 != commands.count()) { 40 if (0 != commands.count()) {
33 SkDrawCommand* command = commands[fDebugger->index()]; 41 SkDrawCommand* command = commands[fDebugger->index()];
34 42
35 const SkBitmap* bitmap = command->getBitmap(); 43 if (command->render(fSurface->getCanvas())) {
36
37 if (NULL != bitmap) {
38 bitmap->lockPixels();
39
40 QPoint origin(0,0); 44 QPoint origin(0,0);
41 QImage image((uchar *)bitmap->getPixels(), bitmap->width(), 45 QImage image((uchar*) fPixels,
42 bitmap->height(), QImage::Format_ARGB32_Premultiplied); 46 kImageWidgetWidth,
47 kImageWidgetHeight,
48 QImage::Format_ARGB32_Premultiplied);
43 49
44 painter.drawImage(origin, image); 50 painter.drawImage(origin, image);
45
46 bitmap->unlockPixels();
47 } else { 51 } else {
48 painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight); 52 painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight);
49 } 53 }
50 } 54 }
51 55
52 painter.end(); 56 painter.end();
53 emit drawComplete(); 57 emit drawComplete();
54 } 58 }
OLDNEW
« no previous file with comments | « debugger/QT/SkImageWidget.h ('k') | debugger/SkDebugCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698