OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 internal::SkiaTextRenderer::DrawDecorations( | 156 internal::SkiaTextRenderer::DrawDecorations( |
157 x, y, width, underline, strike, diagonal_strike); | 157 x, y, width, underline, strike, diagonal_strike); |
158 } | 158 } |
159 | 159 |
160 std::vector<TextLog> text_log_; | 160 std::vector<TextLog> text_log_; |
161 std::vector<DecorationLog> decoration_log_; | 161 std::vector<DecorationLog> decoration_log_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(TestSkiaTextRenderer); | 163 DISALLOW_COPY_AND_ASSIGN(TestSkiaTextRenderer); |
164 }; | 164 }; |
165 | 165 |
166 // Given a buffer to test against, this can be used to test various areas of the | |
167 // rectangular buffer against a specific color value. | |
168 class TestRectangleBuffer { | |
169 public: | |
170 TestRectangleBuffer(const wchar_t* string, | |
171 const SkColor* buffer, | |
172 uint32_t stride, | |
173 uint32_t row_count) | |
174 : string_(string), | |
175 buffer_(buffer), | |
176 stride_(stride), | |
177 row_count_(row_count) {} | |
178 | |
179 // Test if any values in the rectangular area are anything other than |color|. | |
180 void EnsureSolidRect(SkColor color, | |
181 int left, | |
182 int top, | |
183 int width, | |
184 int height) const { | |
185 ASSERT_LT(top, row_count_) << string_; | |
186 ASSERT_LE(top + height, row_count_) << string_; | |
187 ASSERT_LT(left, stride_) << string_; | |
188 ASSERT_LE(left + width, stride_) << string_ << ", left " << left | |
189 << ", width " << width << ", stride_ " | |
190 << stride_; | |
191 for (int y = top; y < top + height; ++y) { | |
192 for (int x = left; x < left + width; ++x) { | |
193 SkColor color = buffer_[x + y * stride_]; | |
194 EXPECT_EQ(SK_ColorWHITE, color) << string_ << " at " << x << ", " << y; | |
195 } | |
196 } | |
197 } | |
198 | |
199 private: | |
200 const wchar_t* string_; | |
201 const SkColor* buffer_; | |
202 int stride_; | |
203 int row_count_; | |
204 | |
205 DISALLOW_COPY_AND_ASSIGN(TestRectangleBuffer); | |
206 }; | |
207 | |
166 } // namespace | 208 } // namespace |
167 | 209 |
168 class RenderTextTest : public testing::Test { | 210 class RenderTextTest : public testing::Test { |
169 }; | 211 }; |
170 | 212 |
171 TEST_F(RenderTextTest, DefaultStyle) { | 213 TEST_F(RenderTextTest, DefaultStyle) { |
172 // Check the default styles applied to new instances and adjusted text. | 214 // Check the default styles applied to new instances and adjusted text. |
173 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 215 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
174 EXPECT_TRUE(render_text->text().empty()); | 216 EXPECT_TRUE(render_text->text().empty()); |
175 const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" }; | 217 const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" }; |
176 for (size_t i = 0; i < arraysize(cases); ++i) { | 218 for (size_t i = 0; i < arraysize(cases); ++i) { |
177 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLACK)); | 219 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLACK)); |
220 EXPECT_TRUE( | |
221 render_text->baselines().EqualsValueForTesting(NORMAL_BASELINE)); | |
178 for (size_t style = 0; style < NUM_TEXT_STYLES; ++style) | 222 for (size_t style = 0; style < NUM_TEXT_STYLES; ++style) |
179 EXPECT_TRUE(render_text->styles()[style].EqualsValueForTesting(false)); | 223 EXPECT_TRUE(render_text->styles()[style].EqualsValueForTesting(false)); |
180 render_text->SetText(WideToUTF16(cases[i])); | 224 render_text->SetText(WideToUTF16(cases[i])); |
181 } | 225 } |
182 } | 226 } |
183 | 227 |
184 TEST_F(RenderTextTest, SetColorAndStyle) { | 228 TEST_F(RenderTextTest, SetColorAndStyle) { |
185 // Ensure custom default styles persist across setting and clearing text. | 229 // Ensure custom default styles persist across setting and clearing text. |
186 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 230 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
187 const SkColor color = SK_ColorRED; | 231 const SkColor color = SK_ColorRED; |
188 render_text->SetColor(color); | 232 render_text->SetColor(color); |
233 render_text->SetBaselineStyle(SUPERSCRIPT); | |
189 render_text->SetStyle(BOLD, true); | 234 render_text->SetStyle(BOLD, true); |
190 render_text->SetStyle(UNDERLINE, false); | 235 render_text->SetStyle(UNDERLINE, false); |
191 const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" }; | 236 const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" }; |
192 for (size_t i = 0; i < arraysize(cases); ++i) { | 237 for (size_t i = 0; i < arraysize(cases); ++i) { |
193 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(color)); | 238 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(color)); |
239 EXPECT_TRUE(render_text->baselines().EqualsValueForTesting(SUPERSCRIPT)); | |
194 EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(true)); | 240 EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(true)); |
195 EXPECT_TRUE(render_text->styles()[UNDERLINE].EqualsValueForTesting(false)); | 241 EXPECT_TRUE(render_text->styles()[UNDERLINE].EqualsValueForTesting(false)); |
196 render_text->SetText(WideToUTF16(cases[i])); | 242 render_text->SetText(WideToUTF16(cases[i])); |
197 | 243 |
198 // Ensure custom default styles can be applied after text has been set. | 244 // Ensure custom default styles can be applied after text has been set. |
199 if (i == 1) | 245 if (i == 1) |
200 render_text->SetStyle(STRIKE, true); | 246 render_text->SetStyle(STRIKE, true); |
201 if (i >= 1) | 247 if (i >= 1) |
202 EXPECT_TRUE(render_text->styles()[STRIKE].EqualsValueForTesting(true)); | 248 EXPECT_TRUE(render_text->styles()[STRIKE].EqualsValueForTesting(true)); |
203 } | 249 } |
204 } | 250 } |
205 | 251 |
206 TEST_F(RenderTextTest, ApplyColorAndStyle) { | 252 TEST_F(RenderTextTest, ApplyColorAndStyle) { |
207 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 253 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
208 render_text->SetText(ASCIIToUTF16("012345678")); | 254 render_text->SetText(ASCIIToUTF16("012345678")); |
209 | 255 |
210 // Apply a ranged color and style and check the resulting breaks. | 256 // Apply a ranged color and style and check the resulting breaks. |
211 render_text->ApplyColor(SK_ColorRED, Range(1, 4)); | 257 render_text->ApplyColor(SK_ColorRED, Range(1, 4)); |
258 render_text->ApplyBaselineStyle(SUPERIOR, Range(2, 4)); | |
212 render_text->ApplyStyle(BOLD, true, Range(2, 5)); | 259 render_text->ApplyStyle(BOLD, true, Range(2, 5)); |
213 std::vector<std::pair<size_t, SkColor> > expected_color; | 260 std::vector<std::pair<size_t, SkColor> > expected_color; |
214 expected_color.push_back(std::pair<size_t, SkColor>(0, SK_ColorBLACK)); | 261 expected_color.push_back(std::pair<size_t, SkColor>(0, SK_ColorBLACK)); |
215 expected_color.push_back(std::pair<size_t, SkColor>(1, SK_ColorRED)); | 262 expected_color.push_back(std::pair<size_t, SkColor>(1, SK_ColorRED)); |
216 expected_color.push_back(std::pair<size_t, SkColor>(4, SK_ColorBLACK)); | 263 expected_color.push_back(std::pair<size_t, SkColor>(4, SK_ColorBLACK)); |
217 EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color)); | 264 EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color)); |
265 std::vector<std::pair<size_t, BaselineStyle>> expected_baseline_style; | |
266 expected_baseline_style.push_back( | |
267 std::pair<size_t, BaselineStyle>(0, NORMAL_BASELINE)); | |
268 expected_baseline_style.push_back( | |
269 std::pair<size_t, BaselineStyle>(2, SUPERIOR)); | |
270 expected_baseline_style.push_back( | |
271 std::pair<size_t, BaselineStyle>(4, NORMAL_BASELINE)); | |
272 EXPECT_TRUE( | |
273 render_text->baselines().EqualsForTesting(expected_baseline_style)); | |
218 std::vector<std::pair<size_t, bool> > expected_style; | 274 std::vector<std::pair<size_t, bool> > expected_style; |
219 expected_style.push_back(std::pair<size_t, bool>(0, false)); | 275 expected_style.push_back(std::pair<size_t, bool>(0, false)); |
220 expected_style.push_back(std::pair<size_t, bool>(2, true)); | 276 expected_style.push_back(std::pair<size_t, bool>(2, true)); |
221 expected_style.push_back(std::pair<size_t, bool>(5, false)); | 277 expected_style.push_back(std::pair<size_t, bool>(5, false)); |
222 EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style)); | 278 EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style)); |
223 | 279 |
224 // Ensure setting a color and style overrides the ranged colors and styles. | 280 // Ensure setting a color, baseline, and style overrides the ranged colors, |
281 // baseline, and styles. | |
225 render_text->SetColor(SK_ColorBLUE); | 282 render_text->SetColor(SK_ColorBLUE); |
226 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLUE)); | 283 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLUE)); |
284 render_text->SetBaselineStyle(SUBSCRIPT); | |
285 EXPECT_TRUE(render_text->baselines().EqualsValueForTesting(SUBSCRIPT)); | |
227 render_text->SetStyle(BOLD, false); | 286 render_text->SetStyle(BOLD, false); |
228 EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(false)); | 287 EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(false)); |
229 | 288 |
230 // Apply a color and style over the text end and check the resulting breaks. | 289 // Apply a color, baseline, and style over the text end and check the |
231 // (INT_MAX should be used instead of the text length for the range end) | 290 // resulting breaks (INT_MAX should be used instead of the text length for |
291 // the range end) | |
232 const size_t text_length = render_text->text().length(); | 292 const size_t text_length = render_text->text().length(); |
233 render_text->ApplyColor(SK_ColorRED, Range(0, text_length)); | 293 render_text->ApplyColor(SK_ColorRED, Range(0, text_length)); |
294 render_text->ApplyBaselineStyle(SUPERIOR, Range(0, text_length)); | |
234 render_text->ApplyStyle(BOLD, true, Range(2, text_length)); | 295 render_text->ApplyStyle(BOLD, true, Range(2, text_length)); |
235 std::vector<std::pair<size_t, SkColor> > expected_color_end; | 296 std::vector<std::pair<size_t, SkColor> > expected_color_end; |
236 expected_color_end.push_back(std::pair<size_t, SkColor>(0, SK_ColorRED)); | 297 expected_color_end.push_back(std::pair<size_t, SkColor>(0, SK_ColorRED)); |
237 EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color_end)); | 298 EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color_end)); |
299 std::vector<std::pair<size_t, BaselineStyle>> expected_baseline_end; | |
300 expected_baseline_end.push_back( | |
301 std::pair<size_t, BaselineStyle>(0, SUPERIOR)); | |
302 EXPECT_TRUE(render_text->baselines().EqualsForTesting(expected_baseline_end)); | |
238 std::vector<std::pair<size_t, bool> > expected_style_end; | 303 std::vector<std::pair<size_t, bool> > expected_style_end; |
239 expected_style_end.push_back(std::pair<size_t, bool>(0, false)); | 304 expected_style_end.push_back(std::pair<size_t, bool>(0, false)); |
240 expected_style_end.push_back(std::pair<size_t, bool>(2, true)); | 305 expected_style_end.push_back(std::pair<size_t, bool>(2, true)); |
241 EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style_end)); | 306 EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style_end)); |
242 | 307 |
243 // Ensure ranged values adjust to accommodate text length changes. | 308 // Ensure ranged values adjust to accommodate text length changes. |
244 render_text->ApplyStyle(ITALIC, true, Range(0, 2)); | 309 render_text->ApplyStyle(ITALIC, true, Range(0, 2)); |
245 render_text->ApplyStyle(ITALIC, true, Range(3, 6)); | 310 render_text->ApplyStyle(ITALIC, true, Range(3, 6)); |
246 render_text->ApplyStyle(ITALIC, true, Range(7, text_length)); | 311 render_text->ApplyStyle(ITALIC, true, Range(7, text_length)); |
247 std::vector<std::pair<size_t, bool> > expected_italic; | 312 std::vector<std::pair<size_t, bool> > expected_italic; |
(...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2563 // Korean character "han". | 2628 // Korean character "han". |
2564 render_text.SetText(WideToUTF16(L"\xd55c")); | 2629 render_text.SetText(WideToUTF16(L"\xd55c")); |
2565 render_text.EnsureLayout(); | 2630 render_text.EnsureLayout(); |
2566 internal::TextRunList* run_list = render_text.GetRunList(); | 2631 internal::TextRunList* run_list = render_text.GetRunList(); |
2567 ASSERT_EQ(1U, run_list->size()); | 2632 ASSERT_EQ(1U, run_list->size()); |
2568 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); | 2633 EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); |
2569 } | 2634 } |
2570 #endif // defined(OS_WIN) | 2635 #endif // defined(OS_WIN) |
2571 | 2636 |
2572 // Ensure that the width reported by RenderText is sufficient for drawing. Draws | 2637 // Ensure that the width reported by RenderText is sufficient for drawing. Draws |
2573 // to a canvas and checks whether any pixel beyond the width is colored. | 2638 // to a canvas and checks whether any pixel beyond the bounding rectangle is |
2639 // colored. | |
2574 TEST_F(RenderTextTest, TextDoesntClip) { | 2640 TEST_F(RenderTextTest, TextDoesntClip) { |
2575 const wchar_t* kTestStrings[] = { L"Save", L"Remove", L"TEST", L"W", L"WWW" }; | 2641 const wchar_t* kTestStrings[] = { |
2642 L" ", | |
msw
2015/03/02 23:05:35
This test now has one case, which only "paints" wh
dschuyler
2015/03/03 23:09:28
Done.
| |
2643 // TODO(mukai): Underscores draw outside GetStringSize; crbug.com/459812. | |
2644 // L"TEST_______", | |
2645 // TODO(mukai): On Windows smoothing draws left of text. | |
2646 // TODO(mukai): On Mac text draws to right of GetStringSize | |
2647 // L"TEST some stuff", | |
2648 // TODO(mukai): On Mac text draws to right of GetStringSize | |
2649 // L"WWWWWWWWWW", | |
2650 // TODO(mukai): On Mac text draws to right of GetStringSize | |
2651 // L"gAXAXAXAXAXAXA", | |
2652 // TODO(mukai): A-Ring draws outside GetStringSize; crbug.com/459812. | |
2653 // L"g\x00C5X\x00C5X\x00C5X\x00C5X\x00C5X\x00C5X\x00C5", | |
2654 // TODO(mukai): On Windows smoothing draws left of text. | |
2655 // L"\x0647\x0654\x0647\x0654\x0647\x0654\x0647\x0654\x0645\x0631\x062D" | |
2656 // L"\x0628\x0627" | |
2657 }; | |
2576 const Size kCanvasSize(300, 50); | 2658 const Size kCanvasSize(300, 50); |
2577 const int kTestWidth = 10; | 2659 const int kTestSize = 10; |
2578 | 2660 |
2579 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 2661 skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
2580 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height())); | 2662 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height())); |
2581 scoped_ptr<Canvas> canvas( | 2663 scoped_ptr<Canvas> canvas( |
2582 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f)); | 2664 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f)); |
2583 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 2665 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
2584 render_text->SetDisplayRect(Rect(kCanvasSize)); | 2666 render_text->SetHorizontalAlignment(ALIGN_LEFT); |
2585 render_text->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
2586 render_text->SetColor(SK_ColorBLACK); | 2667 render_text->SetColor(SK_ColorBLACK); |
2587 | 2668 |
2588 for (auto string : kTestStrings) { | 2669 for (auto string : kTestStrings) { |
2589 surface->getCanvas()->clear(SK_ColorWHITE); | 2670 surface->getCanvas()->clear(SK_ColorWHITE); |
2590 render_text->SetText(WideToUTF16(string)); | 2671 render_text->SetText(WideToUTF16(string)); |
2672 const Size string_size = render_text->GetStringSize(); | |
2673 render_text->ApplyBaselineStyle(SUPERSCRIPT, Range(1, 2)); | |
2674 render_text->ApplyBaselineStyle(SUPERIOR, Range(3, 4)); | |
2675 render_text->ApplyBaselineStyle(INFERIOR, Range(5, 6)); | |
2676 render_text->ApplyBaselineStyle(SUBSCRIPT, Range(7, 8)); | |
2591 render_text->SetStyle(BOLD, true); | 2677 render_text->SetStyle(BOLD, true); |
2678 render_text->SetDisplayRect( | |
2679 Rect(kTestSize, kTestSize, string_size.width(), string_size.height())); | |
2680 // Allow the RenderText to paint outside of its display rect. | |
2681 render_text->set_clip_to_display_rect(false); | |
2682 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width()); | |
2683 | |
2592 render_text->Draw(canvas.get()); | 2684 render_text->Draw(canvas.get()); |
2593 int width = render_text->GetStringSize().width(); | 2685 ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width()); |
2594 ASSERT_LT(width + kTestWidth, kCanvasSize.width()); | 2686 const uint32* buffer = |
2595 const uint32* buffer = static_cast<const uint32*>( | 2687 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr)); |
2596 surface->peekPixels(NULL, NULL)); | |
2597 ASSERT_NE(nullptr, buffer); | 2688 ASSERT_NE(nullptr, buffer); |
2598 | 2689 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(), |
2599 for (int y = 0; y < kCanvasSize.height(); ++y) { | 2690 kCanvasSize.height()); |
2600 // Allow one column of anti-aliased pixels past the expected width. | 2691 // Top side. |
2601 SkColor color = buffer[width + y * kCanvasSize.width()]; | 2692 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(), |
2602 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; | 2693 kTestSize); |
2603 for (int x = 1; x < kTestWidth; ++x) { | 2694 // Bottom side. |
2604 color = buffer[width + x + y * kCanvasSize.width()]; | 2695 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, |
2605 EXPECT_EQ(SK_ColorWHITE, color) << string; | 2696 kTestSize + string_size.height(), |
2606 } | 2697 kCanvasSize.width(), kTestSize); |
2607 } | 2698 // Left side. |
2699 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize, | |
2700 string_size.height()); | |
2701 // Right side. | |
2702 rect_buffer.EnsureSolidRect(SK_ColorWHITE, kTestSize + string_size.width(), | |
2703 kTestSize, kTestSize, string_size.height()); | |
2608 } | 2704 } |
2609 } | 2705 } |
2610 | 2706 |
2707 // Ensure that the text will clip to the display rect. Draws to a canvas and | |
2708 // checks whether any pixel beyond the bounding rectangle is colored. | |
2709 TEST_F(RenderTextTest, TextDoesClip) { | |
2710 const wchar_t* kTestStrings[] = {L"TEST", L"W", L"WWWW", L"gAXAXWWWW"}; | |
2711 const Size kCanvasSize(300, 50); | |
2712 const int kTestSize = 10; | |
2713 | |
2714 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | |
2715 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height())); | |
2716 scoped_ptr<Canvas> canvas( | |
2717 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f)); | |
2718 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | |
2719 render_text->SetHorizontalAlignment(ALIGN_LEFT); | |
2720 render_text->SetColor(SK_ColorBLACK); | |
2721 | |
2722 for (auto string : kTestStrings) { | |
2723 surface->getCanvas()->clear(SK_ColorWHITE); | |
2724 render_text->SetText(WideToUTF16(string)); | |
2725 const Size string_size = render_text->GetStringSize(); | |
2726 int fake_width = string_size.width() / 2; | |
2727 int fake_height = string_size.height() / 2; | |
2728 render_text->SetDisplayRect( | |
2729 Rect(kTestSize, kTestSize, fake_width, fake_height)); | |
2730 render_text->set_clip_to_display_rect(true); | |
2731 render_text->Draw(canvas.get()); | |
2732 ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width()); | |
2733 const uint32* buffer = | |
2734 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr)); | |
2735 ASSERT_NE(nullptr, buffer); | |
2736 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(), | |
2737 kCanvasSize.height()); | |
2738 // Top side. | |
2739 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(), | |
2740 kTestSize); | |
2741 // Bottom side. | |
2742 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize + fake_height, | |
2743 kCanvasSize.width(), kTestSize); | |
2744 // Left side. | |
2745 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize, | |
2746 fake_height); | |
2747 // Right side. | |
2748 rect_buffer.EnsureSolidRect(SK_ColorWHITE, kTestSize + fake_width, | |
2749 kTestSize, kTestSize, fake_height); | |
2750 } | |
2751 } | |
2752 | |
2611 } // namespace gfx | 2753 } // namespace gfx |
OLD | NEW |