Show the paint's typeface information in the details pane of the debugger.
Also add a convenience constructor for SkMemoryStream that takes the SkData directly (instead of having to construct an empty one and call setData). Review URL: https://codereview.appspot.com/7065045 git-svn-id: http://skia.googlecode.com/svn/trunk@7048 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
e3453cbd20
commit
f515ffc3d4
@ -8,6 +8,10 @@
|
||||
|
||||
#include "SkObjectParser.h"
|
||||
#include "SkRRect.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkData.h"
|
||||
#include "SkFontDescriptor.h"
|
||||
|
||||
/* TODO(chudy): Replace all std::strings with char */
|
||||
|
||||
@ -98,8 +102,29 @@ SkString* SkObjectParser::MatrixToString(const SkMatrix& matrix) {
|
||||
|
||||
SkString* SkObjectParser::PaintToString(const SkPaint& paint) {
|
||||
SkColor color = paint.getColor();
|
||||
SkString* mPaint = new SkString("SkPaint: Color: 0x");
|
||||
SkString* mPaint = new SkString("<dl><dt>SkPaint:</dt><dd><dl><dt>Color:</dt><dd>0x");
|
||||
mPaint->appendHex(color);
|
||||
mPaint->append("</dd>");
|
||||
|
||||
SkTypeface *typeface = paint.getTypeface();
|
||||
if (typeface) {
|
||||
SkDynamicMemoryWStream ostream;
|
||||
typeface->serialize(&ostream);
|
||||
SkData *data = SkAutoTUnref<SkData>(ostream.copyToData());
|
||||
|
||||
SkMemoryStream stream(data);
|
||||
SkFontDescriptor descriptor(&stream);
|
||||
|
||||
mPaint->append("<dt>Font Family Name:</dt><dd>");
|
||||
mPaint->append(descriptor.getFamilyName());
|
||||
mPaint->append("</dd><dt>Font Full Name:</dt><dd>");
|
||||
mPaint->append(descriptor.getFullName());
|
||||
mPaint->append("</dd><dt>Font PS Name:</dt><dd>");
|
||||
mPaint->append(descriptor.getPostscriptName());
|
||||
mPaint->append("</dd><dt>Font File Name:</dt><dd>");
|
||||
mPaint->append(descriptor.getFontFileName());
|
||||
mPaint->append("</dd></dl></dl>");
|
||||
}
|
||||
|
||||
return mPaint;
|
||||
}
|
||||
|
@ -81,6 +81,7 @@
|
||||
'../debugger', # To pull SkDebugger.h
|
||||
'../debugger/QT', # For all the QT UI Goodies
|
||||
'../src/gpu', # To pull gl/GrGLUtil.h
|
||||
'../src/ports', # To pull SkFontDescriptor.h
|
||||
'../bench',
|
||||
'../tools',
|
||||
'<@(qt_includes)',
|
||||
|
@ -188,6 +188,7 @@ public:
|
||||
/** if copyData is true, the stream makes a private copy of the data
|
||||
*/
|
||||
SkMemoryStream(const void* data, size_t length, bool copyData = false);
|
||||
SkMemoryStream(SkData *data);
|
||||
virtual ~SkMemoryStream();
|
||||
|
||||
/** Resets the stream to the specified data and length,
|
||||
|
@ -299,6 +299,11 @@ SkMemoryStream::SkMemoryStream(const void* src, size_t size, bool copyData) {
|
||||
fOffset = 0;
|
||||
}
|
||||
|
||||
SkMemoryStream::SkMemoryStream(SkData *data) {
|
||||
fData = SkSafeRef(data);
|
||||
fOffset = 0;
|
||||
}
|
||||
|
||||
SkMemoryStream::~SkMemoryStream() {
|
||||
fData->unref();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user