diff options
Diffstat (limited to 'experimental/webtry')
-rwxr-xr-x | experimental/webtry/build | 4 | ||||
-rw-r--r-- | experimental/webtry/templates/template.gyp | 4 | ||||
-rw-r--r-- | experimental/webtry/webtry.go | 22 |
3 files changed, 24 insertions, 6 deletions
diff --git a/experimental/webtry/build b/experimental/webtry/build index 8536dbce16..ace33b1e0b 100755 --- a/experimental/webtry/build +++ b/experimental/webtry/build @@ -18,7 +18,9 @@ PATH=$PATH:$GOROOT/bin cd ${SKIA_ROOT}/include echo "Creating compile template..." -find core effects pathops -maxdepth 1 -name "*.h" | sed "s#^[^\/]*\/##g" | sed "s/\(.*\)/#include \"\1\"/" | sort > ${WEBTRY_ROOT}/templates/template.cpp +find core effects pathops -maxdepth 1 -name "*.h" | sed "s/.*\///" | sed "s/\(.*\)/#include \"\1\"/" | sort > ${WEBTRY_ROOT}/templates/template.cpp +echo '#include "sk_tool_utils.h"' >> ${WEBTRY_ROOT}/templates/template.cpp +echo '' >> ${WEBTRY_ROOT}/templates/template.cpp echo "SkBitmap source;" >> ${WEBTRY_ROOT}/templates/template.cpp echo "{{.Code}}" >> ${WEBTRY_ROOT}/templates/template.cpp cd ${WEBTRY_ROOT} diff --git a/experimental/webtry/templates/template.gyp b/experimental/webtry/templates/template.gyp index 7ba40eaf78..e53fa0bddd 100644 --- a/experimental/webtry/templates/template.gyp +++ b/experimental/webtry/templates/template.gyp @@ -12,7 +12,9 @@ 'type': 'executable', 'dependencies': [ 'skia_lib.gyp:skia_lib', - 'flags.gyp:flags' + 'flags.gyp:flags', + 'tools.gyp:sk_tool_utils' + ], 'include_dirs': [ '../include/config', diff --git a/experimental/webtry/webtry.go b/experimental/webtry/webtry.go index ce144b93e0..36c7afe5db 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) } |