28fcae2ec7
Reason for revert: Want to reland the original CL. Original issue's description: > Revert of Rename kPMColor_SkColorType to kN32_SkColorType. (https://codereview.chromium.org/227433009/) > > Reason for revert: > breaking the Chrome deps roll. > http://build.chromium.org/p/chromium.linux/builders/Linux%20GN%20%28dbg%29/builds/839/steps/compile/logs/stdio > > Original issue's description: > > Rename kPMColor_SkColorType to kN32_SkColorType. > > > > The new name better represents what this flag means. > > > > BUG=skia:2384 > > > > Committed: http://code.google.com/p/skia/source/detail?r=14117 > > TBR=reed@google.com,scroggo@google.com > NOTREECHECKS=true > NOTRY=true > BUG=skia:2384 > > Committed: http://code.google.com/p/skia/source/detail?r=14144 R=reed@google.com, bensong@google.com TBR=bensong@google.com, reed@google.com NOTREECHECKS=true NOTRY=true BUG=skia:2384 Author: scroggo@google.com Review URL: https://codereview.chromium.org/235523003 git-svn-id: http://skia.googlecode.com/svn/trunk@14156 2bbb7eff-a529-9590-31e7-b0007b416f81
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
|
|
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include <QtGui>
|
|
|
|
#include "SkDebugger.h"
|
|
#include "SkImageWidget.h"
|
|
|
|
SkImageWidget::SkImageWidget(SkDebugger *debugger)
|
|
: QWidget()
|
|
, fDebugger(debugger) {
|
|
this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
|
|
|
|
SkImageInfo info;
|
|
info.fWidth = kImageWidgetWidth;
|
|
info.fHeight = kImageWidgetHeight;
|
|
info.fColorType = kN32_SkColorType;
|
|
info.fAlphaType = kPremul_SkAlphaType;
|
|
|
|
fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth);
|
|
}
|
|
|
|
void SkImageWidget::paintEvent(QPaintEvent* event) {
|
|
if (this->isHidden()) {
|
|
return;
|
|
}
|
|
|
|
QPainter painter(this);
|
|
QStyleOption opt;
|
|
opt.init(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
|
|
|
|
const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands();
|
|
if (0 != commands.count()) {
|
|
SkDrawCommand* command = commands[fDebugger->index()];
|
|
|
|
if (command->render(fSurface->getCanvas())) {
|
|
QPoint origin(0,0);
|
|
QImage image((uchar*) fPixels,
|
|
kImageWidgetWidth,
|
|
kImageWidgetHeight,
|
|
QImage::Format_ARGB32_Premultiplied);
|
|
|
|
painter.drawImage(origin, image);
|
|
} else {
|
|
painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight);
|
|
}
|
|
}
|
|
|
|
painter.end();
|
|
emit drawComplete();
|
|
}
|