High level pdf classes and pdf specific interface.
The guts of the implementation will be in SkPDFDevice and below. This is a first implementation of everything above that point.
Review URL: http://codereview.appspot.com/2342043
git-svn-id: http://skia.googlecode.com/svn/trunk@602 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 6187f81..cbe3eb4 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -123,6 +123,13 @@
return this->write(tmp.c_str(), tmp.size());
}
+bool SkWStream::writeBigDecAsText(int64_t dec, int minDigits)
+{
+ SkString tmp;
+ tmp.appendS64(dec, minDigits);
+ return this->write(tmp.c_str(), tmp.size());
+}
+
bool SkWStream::writeHexAsText(uint32_t hex, int digits)
{
SkString tmp;
@@ -725,4 +732,3 @@
#endif
return true;
}
-
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index d595d51..cdce160 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -79,6 +79,39 @@
return string;
}
+char* SkStrAppendS64(char string[], int64_t dec, int minDigits)
+{
+ SkDEBUGCODE(char* start = string;)
+
+ char buffer[SkStrAppendS64_MaxSize];
+ char* p = buffer + sizeof(buffer);
+ bool neg = false;
+
+ if (dec < 0) {
+ neg = true;
+ dec = -dec;
+ }
+ do {
+ *--p = SkToU8('0' + dec % 10);
+ dec /= 10;
+ minDigits--;
+ } while (dec != 0);
+ while (minDigits > 0) {
+ *--p = '0';
+ minDigits--;
+ }
+ if (neg)
+ *--p = '-';
+
+ SkASSERT(p >= buffer);
+ size_t cp_len = buffer + sizeof(buffer) - p;
+ memcpy(string, p, cp_len);
+ string += cp_len;
+
+ SkASSERT(string - start <= SkStrAppendS64_MaxSize);
+ return string;
+}
+
char* SkStrAppendScalar(char string[], SkScalar value)
{
SkDEBUGCODE(char* start = string;)
@@ -440,6 +473,13 @@
this->insert(offset, buffer, stop - buffer);
}
+void SkString::insertS64(size_t offset, int64_t dec, int minDigits)
+{
+ char buffer[SkStrAppendS64_MaxSize];
+ char* stop = SkStrAppendS64(buffer, dec, minDigits);
+ this->insert(offset, buffer, stop - buffer);
+}
+
void SkString::insertHex(size_t offset, uint32_t hex, int minDigits)
{
minDigits = SkPin32(minDigits, 0, 8);
@@ -580,4 +620,3 @@
{
delete[] fUCS2;
}
-