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; } | |
119 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, | 118 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, |
120 size_t rowBytes) override { | 119 size_t rowBytes) override { |
121 return SkImageEncoder::EncodeData(info, pixels, rowBytes, | 120 return SkImageEncoder::EncodeData(info, pixels, rowBytes, |
122 SkImageEncoder::kPNG_Type, 100); | 121 SkImageEncoder::kPNG_Type, 100); |
123 } | 122 } |
124 }; | 123 }; |
125 | 124 |
126 // A helper for inserting a drawtext call into a SkTextBlobBuilder | 125 // A helper for inserting a drawtext call into a SkTextBlobBuilder |
127 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const Sk
Paint& origPaint, | 126 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const Sk
Paint& origPaint, |
128 SkScalar x, SkScalar y); | 127 SkScalar x, SkScalar y); |
129 | 128 |
130 void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst); | 129 void create_hemi_normal_map(SkBitmap* bm, const SkIRect& dst); |
131 | 130 |
132 void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst); | 131 void create_frustum_normal_map(SkBitmap* bm, const SkIRect& dst); |
133 | 132 |
134 void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst); | 133 void create_tetra_normal_map(SkBitmap* bm, const SkIRect& dst); |
135 | 134 |
136 } // namespace sk_tool_utils | 135 } // namespace sk_tool_utils |
137 | 136 |
138 #endif // sk_tool_utils_DEFINED | 137 #endif // sk_tool_utils_DEFINED |
OLD | NEW |