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

Unified Diff: sky/engine/core/painting/Paint.cpp

Issue 1185423003: Add a Paint::toString() method to describe our Paint objects. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: abarth Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/painting/Paint.h ('k') | sky/engine/core/painting/Paint.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/painting/Paint.cpp
diff --git a/sky/engine/core/painting/Paint.cpp b/sky/engine/core/painting/Paint.cpp
index 7644299345541f6167ea56c828e7a5861e933d13..4b4fedd3078fee305485fcb08bed02ecfd79adf7 100644
--- a/sky/engine/core/painting/Paint.cpp
+++ b/sky/engine/core/painting/Paint.cpp
@@ -9,50 +9,80 @@
#include "sky/engine/core/painting/DrawLooper.h"
#include "sky/engine/core/painting/MaskFilter.h"
#include "sky/engine/core/painting/Shader.h"
+#include "sky/engine/wtf/text/StringBuilder.h"
+#include "third_party/skia/include/core/SkColorFilter.h"
+#include "third_party/skia/include/core/SkMaskFilter.h"
+#include "third_party/skia/include/core/SkShader.h"
+#include "third_party/skia/include/core/SkString.h"
namespace blink {
-Paint::Paint()
-{
- setIsAntiAlias(true);
+namespace {
+
+template <typename T>
+void SkToString(const char* title, const T* sk_object, StringBuilder* result) {
+ if (!sk_object)
+ return;
+ SkString string;
+ sk_object->toString(&string);
+ result->append(String::format(", %s: %s", title, string.c_str()));
+}
+
+}
+
+Paint::Paint() {
+ setIsAntiAlias(true);
+}
+
+Paint::~Paint() {
}
-Paint::~Paint()
-{
+void Paint::setDrawLooper(DrawLooper* looper) {
+ ASSERT(looper);
+ paint_.setLooper(looper->looper());
}
-void Paint::setDrawLooper(DrawLooper* looper)
-{
- ASSERT(looper);
- m_paint.setLooper(looper->looper());
+void Paint::setColorFilter(ColorFilter* filter) {
+ ASSERT(filter);
+ paint_.setColorFilter(filter->filter());
}
-void Paint::setColorFilter(ColorFilter* filter)
-{
- ASSERT(filter);
- m_paint.setColorFilter(filter->filter());
+void Paint::setMaskFilter(MaskFilter* filter) {
+ ASSERT(filter);
+ paint_.setMaskFilter(filter->filter());
}
-void Paint::setMaskFilter(MaskFilter* filter)
-{
- ASSERT(filter);
- m_paint.setMaskFilter(filter->filter());
+void Paint::setShader(Shader* shader) {
+ ASSERT(shader);
+ paint_.setShader(shader->shader());
}
-void Paint::setShader(Shader* shader)
-{
- ASSERT(shader);
- m_paint.setShader(shader->shader());
+void Paint::setStyle(SkPaint::Style style) {
+ paint_.setStyle(style);
}
-void Paint::setStyle(SkPaint::Style style)
-{
- m_paint.setStyle(style);
+void Paint::setTransferMode(SkXfermode::Mode transfer_mode) {
+ paint_.setXfermodeMode(transfer_mode);
}
-void Paint::setTransferMode(SkXfermode::Mode transfer_mode)
-{
- m_paint.setXfermodeMode(transfer_mode);
+String Paint::toString() const {
+ StringBuilder result;
+
+ result.append("Paint(");
+
+ result.append(String::format("color:Color(0x%.8x)", paint_.getColor()));
+
+ SkToString("shader", paint_.getShader(), &result);
+ SkToString("colorFilter", paint_.getColorFilter(), &result);
+ SkToString("maskFilter", paint_.getMaskFilter(), &result);
+
+ if (paint_.getLooper()) {
+ // TODO(mpcomplete): Figure out how to show a drawLooper.
+ result.append(", drawLooper:true");
+ }
+ result.append(")");
+
+ return result.toString();
}
-} // namespace blink
+} // namespace blink
« no previous file with comments | « sky/engine/core/painting/Paint.h ('k') | sky/engine/core/painting/Paint.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698