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

Unified Diff: experimental/webtry/webtry.go

Issue 639833003: preliminary support for fiddle font use (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « experimental/webtry/templates/template.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/webtry/webtry.go
diff --git a/experimental/webtry/webtry.go b/experimental/webtry/webtry.go
index ce144b93e05e3e70d52a2733357a7a0cc1d6b9c2..36c7afe5db6d428582d2a1fb4b45645940d0ac88 100644
--- a/experimental/webtry/webtry.go
+++ b/experimental/webtry/webtry.go
@@ -36,7 +36,6 @@ import (
)
const (
-
DEFAULT_SAMPLE = `void draw(SkCanvas* canvas) {
SkPaint p;
p.setColor(SK_ColorRED);
@@ -368,14 +367,29 @@ func expandToFile(filename string, code string, t *template.Template) error {
// expandCode expands the template into a file and calculates the MD5 hash.
func expandCode(code string, source int) (string, error) {
+ // in order to support fonts in the chroot jail, we need to make sure
+ // we're using portable typefaces.
+ // TODO(humper): Make this more robust, supporting things like setTypeface
+
+ inputCodeLines := strings.Split(code, "\n")
+ outputCodeLines := []string{}
+ for _, line := range inputCodeLines {
+ outputCodeLines = append(outputCodeLines, line)
+ if strings.HasPrefix(strings.TrimSpace(line), "SkPaint ") {
+ outputCodeLines = append(outputCodeLines, "sk_tool_utils::set_portable_typeface(&p);")
+ }
+ }
+
+ fontFriendlyCode := strings.Join(outputCodeLines, "\n")
+
h := md5.New()
- h.Write([]byte(code))
+ h.Write([]byte(fontFriendlyCode))
binary.Write(h, binary.LittleEndian, int64(source))
hash := fmt.Sprintf("%x", h.Sum(nil))
// At this point we are running in skia/experimental/webtry, making cache a
// peer directory to skia.
// TODO(jcgregorio) Make all relative directories into flags.
- err := expandToFile(fmt.Sprintf("../../../cache/src/%s.cpp", hash), code, codeTemplate)
+ err := expandToFile(fmt.Sprintf("../../../cache/src/%s.cpp", hash), fontFriendlyCode, codeTemplate)
return hash, err
}
@@ -817,7 +831,7 @@ func mainHandler(w http.ResponseWriter, r *http.Request) {
cmd := "scripts/fiddle_wrapper " + hash
if *useChroot {
cmd = "schroot -c webtry --directory=/ -- /skia_build/skia/experimental/webtry/" + cmd
- }
+ }
if request.Source > 0 {
cmd += fmt.Sprintf(" image-%d.png", request.Source)
}
« no previous file with comments | « experimental/webtry/templates/template.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698