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

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

Issue 787143004: debugger: Make draw command image widget resize (Closed) Base URL: https://skia.googlesource.com/skia.git@debugger-resize-01-settings-layout
Patch Set: address review comments Created 5 years, 11 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
« no previous file with comments | « debugger/QT/SkImageWidget.h ('k') | gyp/debugger.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include <QtGui>
10
11 #include "SkDebugger.h"
12 #include "SkImageWidget.h"
13
14 SkImageWidget::SkImageWidget(SkDebugger *debugger)
15 : QWidget()
16 , fDebugger(debugger)
17 {
18 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc cccc;}");
19
20 SkImageInfo info = SkImageInfo::MakeN32Premul(kImageWidgetWidth, kImageWidge tHeight);
21 fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth);
22 }
23
24 void SkImageWidget::paintEvent(QPaintEvent* event) {
25 if (this->isHidden()) {
26 return;
27 }
28
29 QPainter painter(this);
30 QStyleOption opt;
31 opt.init(this);
32
33 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
34
35 const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands();
36 if (0 != commands.count()) {
37 SkDrawCommand* command = commands[fDebugger->index()];
38
39 if (command->render(fSurface->getCanvas())) {
40 QPoint origin(0,0);
41 QImage image((uchar*) fPixels,
42 kImageWidgetWidth,
43 kImageWidgetHeight,
44 QImage::Format_ARGB32_Premultiplied);
45
46 painter.drawImage(origin, image);
47 } else {
48 painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight);
49 }
50 }
51
52 painter.end();
53 emit drawComplete();
54 }
OLDNEW
« no previous file with comments | « debugger/QT/SkImageWidget.h ('k') | gyp/debugger.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698