Added missing files to fix build.

TBR

Review URL: https://codereview.appspot.com/6455058

git-svn-id: http://skia.googlecode.com/svn/trunk@4822 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
chudy@google.com 2012-07-28 23:26:10 +00:00
parent 0ab03397af
commit 38b08ce020
3 changed files with 145 additions and 1 deletions

View File

@ -217,7 +217,7 @@ void SkDebuggerGUI::actionSave() {
void SkDebuggerGUI::actionSaveAs() {
QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
"Skia Picture (*skp)");
if (!filename.endsWith(".skp", Qt::CaseInsensitive))
if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
filename.append(".skp");
}
saveToFile(filename);

View File

@ -0,0 +1,64 @@
/*
* 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 "SkRasterWidget.h"
SkRasterWidget::SkRasterWidget(QWidget* parent) : QWidget(parent) {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 800, 800);
fBitmap.allocPixels();
fBitmap.eraseColor(0);
fTransform.set(0,0);
fScaleFactor = 1.0;
fIndex = 0;
fDebugCanvas = new SkDebugCanvas();
this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
}
SkRasterWidget::~SkRasterWidget() {
delete fDevice;
delete fDebugCanvas;
}
void SkRasterWidget::resizeEvent(QResizeEvent* event) {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, event->size().width(), event->size().height());
fBitmap.allocPixels();
delete fDevice;
fDevice = new SkDevice(fBitmap);
fDebugCanvas->setBounds(event->size().width(), event->size().height());
this->update();
}
void SkRasterWidget::paintEvent(QPaintEvent* event) {
fBitmap.eraseColor(0);
SkCanvas canvas(fDevice);
canvas.translate(fTransform.fX, fTransform.fY);
if (fScaleFactor < 0) {
canvas.scale((1.0 / -fScaleFactor), (1.0 / -fScaleFactor));
} else if (fScaleFactor > 0) {
canvas.scale(fScaleFactor, fScaleFactor);
}
fMatrix = canvas.getTotalMatrix();
fClip = canvas.getTotalClip().getBounds();
fDebugCanvas->drawTo(&canvas, fIndex+1, &fBitmap);
QPainter painter(this);
QStyleOption opt;
opt.init(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
QPoint origin(0,0);
QImage image((uchar *)fBitmap.getPixels(), fBitmap.width(),
fBitmap.height(), QImage::Format_ARGB32_Premultiplied);
painter.drawImage(origin, image);
painter.end();
}

View File

@ -0,0 +1,80 @@
/*
* SkRasterWidget.h
*
* Created on: Jul 28, 2012
* Author: chudy
*/
#ifndef SKRASTERWIDGET_H_
#define SKRASTERWIDGET_H_
#include "SkGpuDevice.h"
#include "SkDevice.h"
#include "SkDebugCanvas.h"
#include <QApplication>
#include <QtGui>
#include <QWidget>
class SkRasterWidget : public QWidget {
public:
SkRasterWidget(QWidget* parent = NULL);
~SkRasterWidget();
void drawTo(int index) {
fIndex = index;
this->update();
}
void setDebugCanvas(SkDebugCanvas* debugCanvas) {
fDebugCanvas = debugCanvas;
fIndex = debugCanvas->getSize();
this->update();
}
int getBitmapHeight() {
return fBitmap.height();
}
int getBitmapWidth() {
return fBitmap.width();
}
const SkMatrix& getCurrentMatrix() {
return fMatrix;
}
const SkIRect& getCurrentClip() {
return fClip;
}
void setTranslate(SkIPoint transform) {
fTransform = transform;
}
void setScale(float scale) {
fScaleFactor = scale;
}
protected:
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent* event);
private:
SkBitmap fBitmap;
SkDebugCanvas* fDebugCanvas;
SkDevice* fDevice;
SkMatrix fMatrix;
SkIRect fClip;
int fIndex;
SkIPoint fTransform;
float fScaleFactor;
};
#endif /* SKRASTERWIDGET_H_ */