| OLD | NEW |
| 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 | 9 |
| 10 #include "SkCanvasWidget.h" | 10 #include "SkCanvasWidget.h" |
| 11 #include <QtGui> |
| 11 | 12 |
| 12 SkCanvasWidget::SkCanvasWidget(QWidget* parent, | 13 SkCanvasWidget::SkCanvasWidget(QWidget* parent, |
| 13 SkDebugger* debugger) : QWidget(parent) | 14 SkDebugger* debugger) : QWidget(parent) |
| 14 , fHorizontalLayout(this) | 15 , fHorizontalLayout(this) |
| 15 , fRasterWidget(debugger) | 16 , fRasterWidget(debugger) |
| 16 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 17 , fGLWidget(debugger) | 18 , fGLWidget(debugger) |
| 18 #endif | 19 #endif |
| 19 { | 20 { |
| 20 | 21 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 #if SK_SUPPORT_GPU | 34 #if SK_SUPPORT_GPU |
| 34 fHorizontalLayout.addWidget(&fGLWidget); | 35 fHorizontalLayout.addWidget(&fGLWidget); |
| 35 #endif | 36 #endif |
| 36 | 37 |
| 37 fPreviousPoint.set(0,0); | 38 fPreviousPoint.set(0,0); |
| 38 fUserMatrix.reset(); | 39 fUserMatrix.reset(); |
| 39 | 40 |
| 40 #if SK_SUPPORT_GPU | 41 #if SK_SUPPORT_GPU |
| 41 setWidgetVisibility(kGPU_WidgetType, true); | 42 setWidgetVisibility(kGPU_WidgetType, true); |
| 42 #endif | 43 #endif |
| 43 connect(&fRasterWidget, SIGNAL(drawComplete()), | 44 connect(&fRasterWidget, SIGNAL(drawComplete()), this->parentWidget(), SLOT(d
rawComplete())); |
| 44 this->parentWidget(), SLOT(drawComplete())); | 45 connect(&fGLWidget, SIGNAL(drawComplete()), this->parentWidget(), SLOT(drawC
omplete())); |
| 45 } | 46 } |
| 46 | 47 |
| 47 SkCanvasWidget::~SkCanvasWidget() {} | 48 SkCanvasWidget::~SkCanvasWidget() {} |
| 48 | 49 |
| 49 void SkCanvasWidget::drawTo(int index) { | 50 void SkCanvasWidget::drawTo(int index) { |
| 50 fDebugger->setIndex(index); | 51 fDebugger->setIndex(index); |
| 51 fRasterWidget.draw(); | 52 fRasterWidget.updateImage(); |
| 52 #if SK_SUPPORT_GPU | 53 #if SK_SUPPORT_GPU |
| 53 fGLWidget.draw(); | 54 fGLWidget.updateImage(); |
| 54 #endif | 55 #endif |
| 55 emit commandChanged(fDebugger->index()); | 56 emit commandChanged(fDebugger->index()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { | 59 void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { |
| 59 SkIPoint eventPoint = SkIPoint::Make(event->globalX(), event->globalY()); | 60 SkIPoint eventPoint = SkIPoint::Make(event->globalX(), event->globalY()); |
| 60 SkIPoint eventOffset = eventPoint - fPreviousPoint; | 61 SkIPoint eventOffset = eventPoint - fPreviousPoint; |
| 61 fPreviousPoint = eventPoint; | 62 fPreviousPoint = eventPoint; |
| 62 fUserMatrix.postTranslate(eventOffset.fX, eventOffset.fY); | 63 fUserMatrix.postTranslate(eventOffset.fX, eventOffset.fY); |
| 63 fDebugger->setUserMatrix(fUserMatrix); | 64 fDebugger->setUserMatrix(fUserMatrix); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 fGLWidget.setSampleCount(sampleCount); | 136 fGLWidget.setSampleCount(sampleCount); |
| 136 } | 137 } |
| 137 #endif | 138 #endif |
| 138 | 139 |
| 139 void SkCanvasWidget::zoom(float scale, int px, int py) { | 140 void SkCanvasWidget::zoom(float scale, int px, int py) { |
| 140 fUserMatrix.postScale(scale, scale, px, py); | 141 fUserMatrix.postScale(scale, scale, px, py); |
| 141 emit scaleFactorChanged(fUserMatrix.getScaleX()); | 142 emit scaleFactorChanged(fUserMatrix.getScaleX()); |
| 142 fDebugger->setUserMatrix(fUserMatrix); | 143 fDebugger->setUserMatrix(fUserMatrix); |
| 143 drawTo(fDebugger->index()); | 144 drawTo(fDebugger->index()); |
| 144 } | 145 } |
| OLD | NEW |