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 #include "SkRasterWidget.h" | 9 #include "SkRasterWidget.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 SkSafeUnref(fDevice); | 22 SkSafeUnref(fDevice); |
23 } | 23 } |
24 | 24 |
25 void SkRasterWidget::resizeEvent(QResizeEvent* event) { | 25 void SkRasterWidget::resizeEvent(QResizeEvent* event) { |
26 fBitmap.allocN32Pixels(event->size().width(), event->size().height()); | 26 fBitmap.allocN32Pixels(event->size().width(), event->size().height()); |
27 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 27 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
28 SkSafeUnref(fCanvas); | 28 SkSafeUnref(fCanvas); |
29 SkSafeUnref(fDevice); | 29 SkSafeUnref(fDevice); |
30 fDevice = new SkBitmapDevice(fBitmap); | 30 fDevice = new SkBitmapDevice(fBitmap); |
31 fCanvas = new SkCanvas(fDevice); | 31 fCanvas = new SkCanvas(fDevice); |
32 fDebugger->resize(event->size().width(), event->size().height()); | 32 fDebugger->setWindowSize(event->size().width(), event->size().height()); |
33 this->update(); | 33 this->update(); |
34 } | 34 } |
35 | 35 |
36 void SkRasterWidget::paintEvent(QPaintEvent* event) { | 36 void SkRasterWidget::paintEvent(QPaintEvent* event) { |
37 if (!this->isHidden()) { | 37 if (!this->isHidden()) { |
38 fDebugger->draw(fCanvas); | 38 fDebugger->draw(fCanvas); |
39 QPainter painter(this); | 39 QPainter painter(this); |
40 QStyleOption opt; | 40 QStyleOption opt; |
41 opt.init(this); | 41 opt.init(this); |
42 | 42 |
43 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); | 43 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); |
44 | 44 |
45 QPoint origin(0,0); | 45 QPoint origin(0,0); |
46 QImage image((uchar *)fBitmap.getPixels(), fBitmap.width(), | 46 QImage image((uchar *)fBitmap.getPixels(), fBitmap.width(), |
47 fBitmap.height(), QImage::Format_ARGB32_Premultiplied); | 47 fBitmap.height(), QImage::Format_ARGB32_Premultiplied); |
48 | 48 |
49 #if SK_R32_SHIFT == 0 | 49 #if SK_R32_SHIFT == 0 |
50 painter.drawImage(origin, image.rgbSwapped()); | 50 painter.drawImage(origin, image.rgbSwapped()); |
51 #else | 51 #else |
52 painter.drawImage(origin, image); | 52 painter.drawImage(origin, image); |
53 #endif | 53 #endif |
54 painter.end(); | 54 painter.end(); |
55 emit drawComplete(); | 55 emit drawComplete(); |
56 } | 56 } |
57 } | 57 } |
OLD | NEW |