aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-03-09 07:42:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-09 07:42:54 -0800
commit51190df040c5a81bb82b9cd5b95f07a39d0e602b (patch)
treecf344dc20df2b26b7683e19530124cdba854c5a5
parentc3adf2fb41d8f2be2724a998ed2aa03b48a10a99 (diff)
Add SkDrawPosTextHCommand JSON, fix skiaserve build.
Adds SkDrawPosTextHCommand ::fromJSON and ::toJSON. Both SkDrawPosTextCommand and SkDrawPosTextHCommand's ::toJSON write the correct number of positions, preventing reading uninitialized memory. The microhttpd build is now done in the build tree as opposed to in a temporary directory. The microhttpd build script uses os.path.join so that absolute paths do not confuse the build. This allows compatibility with the cmake gyp generator as CMake likes to pass absolute paths. The microhttpd gyp target is now marked as 'none' since it is not a 'static_library' target (which directs gyp to compile sources into a static library). The dependencies to the action are updated to the minimum required for sane re-building. The everything gyp target now depends on the skiaserve gyp target. This means that when using skia_build_server=1, building 'most' will build skiaserve, but when skia_build_server is not defined the skiaserve target will still be available if specified manually. The old json.gyp is removed as it currently does not build anything. All of the files currently referenced by it as sources no longer exist. Review URL: https://codereview.chromium.org/1775203002
-rw-r--r--gyp/everything.gyp1
-rw-r--r--gyp/json.gyp29
-rw-r--r--gyp/microhttpd.gyp10
-rw-r--r--gyp/most.gyp1
-rw-r--r--third_party/libmicrohttpd/build.py20
-rw-r--r--tools/debugger/SkDrawCommand.cpp34
-rw-r--r--tools/debugger/SkDrawCommand.h2
7 files changed, 54 insertions, 43 deletions
diff --git a/gyp/everything.gyp b/gyp/everything.gyp
index 61909e494e..47db978171 100644
--- a/gyp/everything.gyp
+++ b/gyp/everything.gyp
@@ -18,6 +18,7 @@
'type': 'none',
'dependencies': [
'most.gyp:most',
+ 'skiaserve.gyp:skiaserve',
],
'conditions': [
['skia_os in ("ios", "android", "chromeos")', {
diff --git a/gyp/json.gyp b/gyp/json.gyp
deleted file mode 100644
index 707e225115..0000000000
--- a/gyp/json.gyp
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2015 Google Inc.
-#
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'json',
- 'product_name': 'skia_json',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'dependencies': [
- 'core.gyp:core',
- 'jsoncpp.gyp:jsoncpp',
- ],
- 'include_dirs': [
- '../include/core',
- '../include/effects',
- '../include/private',
- '../include/utils',
- '../src/core',
- ],
- 'sources': [
- '../tools/json/SkJSONCanvas.cpp',
- '../tools/json/SkJSONRenderer.cpp',
- ],
- },
- ],
-}
diff --git a/gyp/microhttpd.gyp b/gyp/microhttpd.gyp
index 58ea0baa74..5254c02250 100644
--- a/gyp/microhttpd.gyp
+++ b/gyp/microhttpd.gyp
@@ -8,17 +8,17 @@
'targets': [
{
'target_name': 'microhttpd',
- 'type': 'static_library',
+ 'type': 'none',
'variables': {
'base_dir%': '../third_party/libmicrohttpd',
+ 'out_dir%': '<(INTERMEDIATE_DIR)/build',
'src_dir%': '../third_party/externals/microhttpd',
},
'direct_dependent_settings': {
'include_dirs': [
'<(src_dir)/src/include',
],
- # for reasons I can't quite fathom, we need the below line to trigger
- # a link
+ # Link the built library to dependents.
'libraries': [
'libmicrohttpd.a',
],
@@ -27,13 +27,15 @@
{
'action_name': 'configure_and_build',
'inputs': [
- '<(PRODUCT_DIR)/',
+ '<(base_dir)/build.py',
+ '<(src_dir)/.git/HEAD', # This does not support local changes, but does support DEPS.
],
'outputs': [ '<(PRODUCT_DIR)/libmicrohttpd.a' ],
'action': [
'python',
'<(base_dir)/build.py',
'--src', '<(src_dir)',
+ '--out', '<(out_dir)',
'--dst', '<(PRODUCT_DIR)',
],
},
diff --git a/gyp/most.gyp b/gyp/most.gyp
index 22be29b823..dac0685b9a 100644
--- a/gyp/most.gyp
+++ b/gyp/most.gyp
@@ -82,7 +82,6 @@
[ 'skia_build_server', {
'dependencies': [
'skiaserve.gyp:skiaserve',
- 'json.gyp:json',
],
}],
],
diff --git a/third_party/libmicrohttpd/build.py b/third_party/libmicrohttpd/build.py
index cafcbeac88..f09a360204 100644
--- a/third_party/libmicrohttpd/build.py
+++ b/third_party/libmicrohttpd/build.py
@@ -13,13 +13,19 @@ import tempfile
parser = argparse.ArgumentParser()
parser.add_argument("--src", help="microhttpd src directory")
-parser.add_argument("--dst", help="output for build files")
+parser.add_argument("--out", help="build directory")
+parser.add_argument("--dst", help="output for final build products")
args = parser.parse_args()
-temp_dir = tempfile.mkdtemp()
+out_dir = args.out
cwd = os.getcwd()
-os.chdir(temp_dir)
-call([cwd + "/" + args.src + "/configure",
+try:
+ os.makedirs(out_dir)
+except OSError as e:
+ pass
+
+os.chdir(out_dir)
+call([os.path.join(cwd, args.src, "configure"),
"--disable-doc",
"--disable-examples",
"--enable-https=no",
@@ -28,7 +34,5 @@ call([cwd + "/" + args.src + "/configure",
"--enable-shared=no"])
call(["make", "--silent"])
call(["cp",
- temp_dir + "/src/microhttpd/.libs/libmicrohttpd.a",
- cwd + "/" + args.dst])
-shutil.rmtree(temp_dir)
-
+ "src/microhttpd/.libs/libmicrohttpd.a",
+ os.path.join(cwd, args.dst)])
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index df338247d5..e342c4415e 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -245,6 +245,7 @@ SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url
INSTALL_FACTORY(DrawPoints);
INSTALL_FACTORY(DrawText);
INSTALL_FACTORY(DrawPosText);
+ INSTALL_FACTORY(DrawPosTextH);
INSTALL_FACTORY(DrawTextOnPath);
INSTALL_FACTORY(DrawTextBlob);
@@ -2371,7 +2372,8 @@ Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const {
result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
((const char*) fText) + fByteLength);
Json::Value coords(Json::arrayValue);
- for (size_t i = 0; i < fByteLength; i++) {
+ size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr);
+ for (size_t i = 0; i < numCoords; i++) {
coords.append(make_json_point(fPos[i]));
}
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords;
@@ -2419,6 +2421,36 @@ void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const {
canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
}
+Json::Value SkDrawPosTextHCommand::toJSON(UrlDataManager& urlDataManager) const {
+ Json::Value result = INHERITED::toJSON(urlDataManager);
+ result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
+ ((const char*) fText) + fByteLength);
+ result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fConstY);
+ Json::Value xpos(Json::arrayValue);
+ size_t numXpos = fPaint.textToGlyphs(fText, fByteLength, nullptr);
+ for (size_t i = 0; i < numXpos; i++) {
+ xpos.append(Json::Value(fXpos[i]));
+ }
+ result[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = xpos;
+ result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManager);
+ return result;
+}
+
+SkDrawPosTextHCommand* SkDrawPosTextHCommand::fromJSON(Json::Value& command,
+ UrlDataManager& urlDataManager) {
+ const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
+ SkPaint paint;
+ extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint);
+ Json::Value jsonXpos = command[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS];
+ int count = (int) jsonXpos.size();
+ SkScalar* xpos = (SkScalar*) sk_malloc_throw(count * sizeof(SkScalar));
+ for (int i = 0; i < count; i++) {
+ xpos[i] = jsonXpos[i].asFloat();
+ }
+ SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat();
+ return new SkDrawPosTextHCommand(text, strlen(text), xpos, y, paint);
+}
+
static const char* gPositioningLabels[] = {
"kDefault_Positioning",
"kHorizontal_Positioning",
diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h
index 44682b55be..0a365c04b5 100644
--- a/tools/debugger/SkDrawCommand.h
+++ b/tools/debugger/SkDrawCommand.h
@@ -497,6 +497,8 @@ public:
SkScalar constY, const SkPaint& paint);
virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
void execute(SkCanvas* canvas) const override;
+ Json::Value toJSON(UrlDataManager& urlDataManager) const override;
+ static SkDrawPosTextHCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
private:
SkScalar* fXpos;