Implemented transparent gradients
R=vandebo@chromium.org, edisonn@google.com
Author: richardlin@chromium.org
Review URL: https://chromiumcodereview.appspot.com/18585002
git-svn-id: http://skia.googlecode.com/svn/trunk@10297 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index 16abc2f..d034270 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -17,6 +17,17 @@
#include "SkString.h"
#include "SkPDFTypes.h"
+//static
+SkPDFArray* SkPDFUtils::RectToArray(const SkRect& rect) {
+ SkPDFArray* result = new SkPDFArray();
+ result->reserve(4);
+ result->appendScalar(rect.fLeft);
+ result->appendScalar(rect.fTop);
+ result->appendScalar(rect.fRight);
+ result->appendScalar(rect.fBottom);
+ return result;
+}
+
// static
SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) {
SkScalar values[6];
@@ -222,3 +233,17 @@
objectIndex).c_str());
content->writeText(" gs\n");
}
+
+// static
+void SkPDFUtils::ApplyPattern(int objectIndex, SkWStream* content) {
+ // Select Pattern color space (CS, cs) and set pattern object as current
+ // color (SCN, scn)
+ SkString resourceName = SkPDFResourceDict::getResourceName(
+ SkPDFResourceDict::kPattern_ResourceType,
+ objectIndex);
+ content->writeText("/Pattern CS/Pattern cs/");
+ content->writeText(resourceName.c_str());
+ content->writeText(" SCN/");
+ content->writeText(resourceName.c_str());
+ content->writeText(" scn\n");
+}