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

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

Issue 1782673003: Update debugger to use SkPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | debugger/QT/SkRasterWidget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 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 <QtGui> 9 #include <QtGui>
10 10
(...skipping 23 matching lines...) Expand all
34 void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) { 34 void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) {
35 this->QFrame::paintEvent(event); 35 this->QFrame::paintEvent(event);
36 36
37 if (!fSurface) { 37 if (!fSurface) {
38 return; 38 return;
39 } 39 }
40 40
41 QPainter painter(this); 41 QPainter painter(this);
42 painter.setRenderHint(QPainter::Antialiasing); 42 painter.setRenderHint(QPainter::Antialiasing);
43 43
44 SkImageInfo info; 44 SkPixmap pixmap;
45 size_t rowBytes; 45
46 if (const void* pixels = fSurface->peekPixels(&info, &rowBytes)) { 46 if (fSurface->peekPixels(&pixmap)) {
47 SkASSERT(info.width() > 0); 47 SkASSERT(pixmap.width() > 0);
48 SkASSERT(info.height() > 0); 48 SkASSERT(pixmap.height() > 0);
49 49
50 QRectF resultRect; 50 QRectF resultRect;
51 if (this->width() < this->height()) { 51 if (this->width() < this->height()) {
52 float ratio = this->width() / info.width(); 52 float ratio = this->width() / pixmap.width();
53 resultRect = QRectF(0, 0, this->width(), ratio * info.height()); 53 resultRect = QRectF(0, 0, this->width(), ratio * pixmap.height());
54 } else { 54 } else {
55 float ratio = this->height() / info.height(); 55 float ratio = this->height() / pixmap.height();
56 resultRect = QRectF(0, 0, ratio * info.width(), this->height()); 56 resultRect = QRectF(0, 0, ratio * pixmap.width(), this->height());
57 } 57 }
58 58
59 resultRect.moveCenter(this->contentsRect().center()); 59 resultRect.moveCenter(this->contentsRect().center());
60 60
61 QImage image(reinterpret_cast<const uchar*>(pixels), 61 QImage image(reinterpret_cast<const uchar*>(pixmap.addr()),
62 info.width(), 62 pixmap.width(),
63 info.height(), 63 pixmap.height(),
64 rowBytes, 64 pixmap.rowBytes(),
65 QImage::Format_ARGB32_Premultiplied); 65 QImage::Format_ARGB32_Premultiplied);
66 painter.drawImage(resultRect, image); 66 painter.drawImage(resultRect, image);
67 } 67 }
68 } 68 }
69 69
70 void SkDrawCommandGeometryWidget::setDrawCommandIndex(int commandIndex) { 70 void SkDrawCommandGeometryWidget::setDrawCommandIndex(int commandIndex) {
71 fCommandIndex = commandIndex; 71 fCommandIndex = commandIndex;
72 this->updateImage(); 72 this->updateImage();
73 } 73 }
74 74
(...skipping 10 matching lines...) Expand all
85 didRender = command->render(fSurface->getCanvas()); 85 didRender = command->render(fSurface->getCanvas());
86 } 86 }
87 87
88 if (!didRender) { 88 if (!didRender) {
89 fSurface->getCanvas()->clear(SK_ColorTRANSPARENT); 89 fSurface->getCanvas()->clear(SK_ColorTRANSPARENT);
90 } 90 }
91 91
92 fSurface->getCanvas()->flush(); 92 fSurface->getCanvas()->flush();
93 this->update(); 93 this->update();
94 } 94 }
OLDNEW
« no previous file with comments | « no previous file | debugger/QT/SkRasterWidget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698