aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/SkColor4f_Reference.bmh11
-rw-r--r--site/user/api/SkColor4f_Reference.md15
-rw-r--r--tools/bookmaker/bookmaker.h2
-rw-r--r--tools/bookmaker/includeWriter.cpp148
4 files changed, 160 insertions, 16 deletions
diff --git a/docs/SkColor4f_Reference.bmh b/docs/SkColor4f_Reference.bmh
index a23431e827..19d4b5dc61 100644
--- a/docs/SkColor4f_Reference.bmh
+++ b/docs/SkColor4f_Reference.bmh
@@ -285,13 +285,20 @@ Returns Color4f with all components in the range from zero to one.
# ------------------------------------------------------------------------------
#Method SkPM4f premul() const
-#Deprecated
+#In Utility
+#Line # returns Premultiplied color; internal use only ##
+#Private
+Internal use only.
+##
+#Return Premultiplied color ##
#Method ##
#Struct SkColor4f ##
#Struct SkPM4f
-#Deprecated
+#Private
+Internal use only.
+##
##
#Topic Color4f ##
diff --git a/site/user/api/SkColor4f_Reference.md b/site/user/api/SkColor4f_Reference.md
index 6b3b01108b..574681d50a 100644
--- a/site/user/api/SkColor4f_Reference.md
+++ b/site/user/api/SkColor4f_Reference.md
@@ -96,10 +96,14 @@ SkColor4f member functions read and modify the structure properties.
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>sets components to valid range</td>
</tr>
<tr>
+ <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkColor4f_premul'>premul</a></td>
+ <td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>returns <a href='undocumented#Premultiply'>Premultiplied</a> color; internal use only</td>
+ </tr>
+ <tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkColor4f_toSkColor'>toSkColor</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>returns closest <a href='SkColor_Reference#Color'>Color</a></td>
</tr>
- <tr style='background-color: #f0f0f0; '>
+ <tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a href='#SkColor4f_vec'>vec</a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>returns array of components</td>
</tr>
@@ -422,10 +426,13 @@ Returns <a href='#Color4f'>Color4f</a> with all components in the range from zer
<a href='#SkPM4f'>SkPM4f</a> <a href='#SkColor4f_premul'>premul</a>() const
</pre>
-Deprecated.
+Internal use only.
+
+### Return Value
+
+<a href='undocumented#Premultiply'>Premultiplied</a> color
---
# <a name='SkPM4f'>Struct SkPM4f</a>
-Deprecated.
-
+Internal use only.
diff --git a/tools/bookmaker/bookmaker.h b/tools/bookmaker/bookmaker.h
index c727983c0f..a002621cd7 100644
--- a/tools/bookmaker/bookmaker.h
+++ b/tools/bookmaker/bookmaker.h
@@ -1970,6 +1970,7 @@ public:
void checkEnumLengths(const Definition& child, string enumName, ItemLength* length) const;
void constOut(const Definition* memberStart, const Definition* bmhConst);
void constSizeMembers(const RootDefinition* root);
+ bool defineOut(const Definition& );
bool descriptionOut(const Definition* def, SkipFirstLine , Phrase );
void enumHeaderOut(RootDefinition* root, const Definition& child);
string enumMemberComment(const Definition* currentEnumItem, const Definition& child) const;
@@ -2037,6 +2038,7 @@ public:
void structOut(const Definition* root, const Definition& child,
const char* commentStart, const char* commentEnd);
void structSizeMembers(const Definition& child);
+ bool writeHeader(std::pair<const string, Definition>& );
private:
vector<const Definition* > fICSStack;
BmhParser* fBmhParser;
diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp
index 53930c6c13..566cc7cc58 100644
--- a/tools/bookmaker/includeWriter.cpp
+++ b/tools/bookmaker/includeWriter.cpp
@@ -6,6 +6,9 @@
*/
#include "bookmaker.h"
+#include <chrono>
+#include <ctime>
+#include <string>
bool IncludeWriter::checkChildCommentLength(const Definition* parent, MarkType childType) const {
bool oneMember = false;
@@ -126,13 +129,14 @@ bool IncludeWriter::descriptionOut(const Definition* def, SkipFirstLine skipFirs
}
size_t childSize = prop->fChildren.size();
if (childSize) {
- SkASSERT(1 == childSize || 2 == childSize); // incomplete
- SkASSERT(MarkType::kLiteral == prop->fChildren[0]->fMarkType);
- SkASSERT(1 == childSize || MarkType::kOutdent == prop->fChildren[1]->fMarkType);
- commentStart = prop->fChildren[childSize - 1]->fContentStart;
- literal = true;
- literalOutdent = 2 == childSize &&
- MarkType::kOutdent == prop->fChildren[1]->fMarkType;
+ if (MarkType::kLiteral == prop->fChildren[0]->fMarkType) {
+ SkASSERT(1 == childSize || 2 == childSize); // incomplete
+ SkASSERT(1 == childSize || MarkType::kOutdent == prop->fChildren[1]->fMarkType);
+ commentStart = prop->fChildren[childSize - 1]->fContentStart;
+ literal = true;
+ literalOutdent = 2 == childSize &&
+ MarkType::kOutdent == prop->fChildren[1]->fMarkType;
+ }
}
commentLen = (int) (prop->fContentEnd - commentStart);
SkASSERT(commentLen > 0);
@@ -1154,6 +1158,22 @@ void IncludeWriter::constSizeMembers(const RootDefinition* root) {
fConstLength = fConstCommentTab + longestComment + (int) sizeof("//!<");
}
+bool IncludeWriter::defineOut(const Definition& def) {
+ if (def.fTokens.size() < 1) {
+ return false;
+ }
+ auto& child = def.fTokens.front();
+ string name(child.fContentStart, child.length());
+ auto defIter = fBmhParser->fDefineMap.find(name);
+ if (fBmhParser->fDefineMap.end() == defIter) {
+ return false;
+ }
+ const Definition& bmhDef = defIter->second;
+ this->constOut(&def, &bmhDef);
+ SkDebugf("");
+ return true;
+}
+
void IncludeWriter::structSizeMembers(const Definition& child) {
int longestType = 0;
Definition* typeStart = nullptr;
@@ -1325,7 +1345,7 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti
const Definition* requireDense = nullptr;
const Definition* startDef = nullptr;
for (auto& child : def->fTokens) {
- if (131 == child.fLineCount) {
+ if (39 == child.fLineCount) {
SkDebugf("");
}
if (KeyWord::kInline == child.fKeyWord) {
@@ -1762,11 +1782,9 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti
case KeyWord::kTemplate:
break;
case KeyWord::kTypedef:
-#if 01
SkASSERT(!memberStart);
memberStart = &child;
sawTypedef = true;
-#endif
break;
case KeyWord::kSK_BEGIN_REQUIRE_DENSE:
requireDense = &child;
@@ -1837,6 +1855,10 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti
if (fAttrDeprecated) {
continue;
}
+ if (KeyWord::kDefine == child.fKeyWord && this->defineOut(child)) {
+ fDeferComment = nullptr;
+ continue;
+ }
fDeferComment = nullptr;
if (KeyWord::kClass == def->fKeyWord || KeyWord::kStruct == def->fKeyWord) {
fIndentNext = true;
@@ -2052,6 +2074,7 @@ bool IncludeWriter::populate(BmhParser& bmhParser) {
this->setStartBack(includeMapper.second.fContentStart, &includeMapper.second);
fEnd = includeMapper.second.fContentEnd;
fAnonymousEnumCount = 1;
+ this->writeHeader(includeMapper);
allPassed &= this->populate(&includeMapper.second, nullptr, root);
this->writeBlock((int) (fEnd - fStart), fStart);
#if 0
@@ -2643,3 +2666,108 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data, Phr
}
return wroteLineFeeds ? Wrote::kLF : Wrote::kChars;
}
+
+static string paddedString(int num) {
+ auto padded = std::to_string(num);
+ padded.insert(0, 2U - std::min(string::size_type(2), padded.length()), '0');
+ return padded;
+}
+
+bool IncludeWriter::writeHeader(std::pair<const string, Definition>& include) {
+ std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
+ time_t tt = std::chrono::system_clock::to_time_t(now);
+ tm local_tm = *localtime(&tt);
+
+ // find end of copyright header
+ fChar = fStart;
+ if (!this->skipExact(
+ "/*\n"
+ " * Copyright ")) {
+ return this->reportError<bool>("copyright mismatch 1");
+ }
+ const char* date = fChar;
+ this->skipToSpace();
+ string yearStr(date, fChar - date);
+ int year = stoi(yearStr);
+ if (year < 2005 || year > local_tm.tm_year + 1900) {
+ return this->reportError<bool>("copyright year out of range");
+ }
+ this->skipSpace();
+ const char android[] = "The Android Open Source Project";
+ const char google[] = "Google Inc.";
+ if (this->startsWith(android)) {
+ this->skipExact(android);
+ } else if (!this->skipExact(google)) {
+ return this->reportError<bool>("copyright mismatch 2");
+ }
+ if (!this->skipExact(
+ "\n"
+ " *\n"
+ " * Use of this source code is governed by a BSD-style license that can be\n"
+ " * found in the LICENSE file.\n"
+ " */\n"
+ "\n"
+ )) {
+ return this->reportError<bool>("copyright mismatch 2");
+ }
+ this->writeBlock(fChar - fStart, fStart);
+ this->lf(2);
+ this->writeString("/* Generated by tools/bookmaker from");
+ this->writeSpace();
+ string includeName = include.first;
+ std::replace(includeName.begin(), includeName.end(), '\\', '/');
+ this->writeString(includeName);
+ this->writeSpace();
+ this->writeString("and");
+ this->writeSpace();
+ string bmhName = fRootTopic->fFileName;
+ std::replace(bmhName.begin(), bmhName.end(), '\\', '/');
+ this->writeString(bmhName);
+ this->lfcr();
+ fIndent = 3;
+ string dateTimeStr = std::to_string(local_tm.tm_year + 1900) + "-"
+ + paddedString(local_tm.tm_mon + 1) + "-"
+ + paddedString(local_tm.tm_mday) + " "
+ + paddedString(local_tm.tm_hour) + ":"
+ + paddedString(local_tm.tm_min) + ":"
+ + paddedString(local_tm.tm_sec);
+ this->writeString("on");
+ this->writeSpace();
+ this->writeString(dateTimeStr);
+ this->writeString(". Additional documentation and examples can be found at:");
+ this->lfcr();
+ this->writeString("https://skia.org/user/api/");
+ size_t bmhPageStart = bmhName.rfind('/');
+ size_t bmhPageEnd = bmhName.rfind('.');
+ if (string::npos == bmhPageStart || string::npos == bmhPageEnd) {
+ return this->reportError<bool>("badly formed bmh page name");
+ }
+ ++bmhPageStart;
+ string bmhPage = bmhName.substr(bmhPageStart, bmhPageEnd - bmhPageStart);
+ this->writeString(bmhPage);
+ this->lf(2);
+ this->writeString("You may edit either file directly. Structural changes to public interfaces require");
+ this->lfcr();
+ this->writeString("editing both files. After editing");
+ this->writeSpace();
+ this->writeString(bmhName);
+ this->writeSpace();
+ this->writeString(", run:");
+ this->lfcr();
+ fIndent += 4;
+ this->writeString("bookmaker -b docs -i");
+ this->writeSpace();
+ this->writeString(includeName);
+ this->writeSpace();
+ this->writeString("-p");
+ this->lfcr();
+ fIndent -= 4;
+ this->writeString("to create an updated version of this file.");
+ this->lfcr();
+ fIndent = 1;
+ this->writeString("*/");
+ this->lf(2);
+ fIndent = 0;
+ fStart = fChar;
+ return true;
+}