| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef sk_tool_utils_DEFINED | 8 #ifndef sk_tool_utils_DEFINED |
| 9 #define sk_tool_utils_DEFINED | 9 #define sk_tool_utils_DEFINED |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, 0xFF666666, 8); | 108 sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, 0xFF666666, 8); |
| 109 } | 109 } |
| 110 | 110 |
| 111 SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y, | 111 SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y, |
| 112 int textSize, const char* str); | 112 int textSize, const char* str); |
| 113 | 113 |
| 114 // Encodes to PNG, unless there is already encoded data, in which case that
gets | 114 // Encodes to PNG, unless there is already encoded data, in which case that
gets |
| 115 // used. | 115 // used. |
| 116 class PngPixelSerializer : public SkPixelSerializer { | 116 class PngPixelSerializer : public SkPixelSerializer { |
| 117 public: | 117 public: |
| 118 bool onUseEncodedData(const void*, size_t) override { return true; } |
| 118 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, | 119 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, |
| 119 size_t rowBytes) override { | 120 size_t rowBytes) override { |
| 120 return SkImageEncoder::EncodeData(info, pixels, rowBytes, | 121 return SkImageEncoder::EncodeData(info, pixels, rowBytes, |
| 121 SkImageEncoder::kPNG_Type, 100); | 122 SkImageEncoder::kPNG_Type, 100); |
| 122 } | 123 } |
| 123 }; | 124 }; |
| 124 | 125 |
| 125 // A helper for inserting a drawtext call into a SkTextBlobBuilder | 126 // A helper for inserting a drawtext call into a SkTextBlobBuilder |
| 126 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const Sk
Paint& origPaint, | 127 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const Sk
Paint& origPaint, |
| 127 SkScalar x, SkScalar y); | 128 SkScalar x, SkScalar y); |
| 128 | 129 |
| 129 void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst); | 130 void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst); |
| 130 | 131 |
| 131 void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst); | 132 void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst); |
| 132 | 133 |
| 133 void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst); | 134 void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst); |
| 134 | 135 |
| 135 } // namespace sk_tool_utils | 136 } // namespace sk_tool_utils |
| 136 | 137 |
| 137 #endif // sk_tool_utils_DEFINED | 138 #endif // sk_tool_utils_DEFINED |
| OLD | NEW |