Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 2509983004: Revert "Change call-sites now that SkCanvas is not ref-counted" (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/canvas.cc ('k') | ui/surface/transport_dib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 3627 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 L"gAXAXAXAXAXAXA", 3638 L"gAXAXAXAXAXAXA",
3639 // TODO(dschuyler): A-Ring draws outside GetStringSize; crbug.com/459812. 3639 // TODO(dschuyler): A-Ring draws outside GetStringSize; crbug.com/459812.
3640 // L"g\x00C5X\x00C5X\x00C5X\x00C5X\x00C5X\x00C5X\x00C5", 3640 // L"g\x00C5X\x00C5X\x00C5X\x00C5X\x00C5X\x00C5X\x00C5",
3641 L"\x0647\x0654\x0647\x0654\x0647\x0654\x0647\x0654\x0645\x0631\x062D" 3641 L"\x0647\x0654\x0647\x0654\x0647\x0654\x0647\x0654\x0645\x0631\x062D"
3642 L"\x0628\x0627"}; 3642 L"\x0628\x0627"};
3643 const Size kCanvasSize(300, 50); 3643 const Size kCanvasSize(300, 50);
3644 const int kTestSize = 10; 3644 const int kTestSize = 10;
3645 3645
3646 sk_sp<SkSurface> surface = 3646 sk_sp<SkSurface> surface =
3647 SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height()); 3647 SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height());
3648 Canvas canvas(surface->getCanvas(), 1.0f); 3648 Canvas canvas(sk_ref_sp(surface->getCanvas()), 1.0f);
3649 RenderText* render_text = GetRenderText(); 3649 RenderText* render_text = GetRenderText();
3650 render_text->SetHorizontalAlignment(ALIGN_LEFT); 3650 render_text->SetHorizontalAlignment(ALIGN_LEFT);
3651 render_text->SetColor(SK_ColorBLACK); 3651 render_text->SetColor(SK_ColorBLACK);
3652 3652
3653 for (auto* string : kTestStrings) { 3653 for (auto* string : kTestStrings) {
3654 surface->getCanvas()->clear(SK_ColorWHITE); 3654 surface->getCanvas()->clear(SK_ColorWHITE);
3655 render_text->SetText(WideToUTF16(string)); 3655 render_text->SetText(WideToUTF16(string));
3656 const Size string_size = render_text->GetStringSize(); 3656 const Size string_size = render_text->GetStringSize();
3657 render_text->ApplyBaselineStyle(SUPERSCRIPT, Range(1, 2)); 3657 render_text->ApplyBaselineStyle(SUPERSCRIPT, Range(1, 2));
3658 render_text->ApplyBaselineStyle(SUPERIOR, Range(3, 4)); 3658 render_text->ApplyBaselineStyle(SUPERIOR, Range(3, 4));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3731 3731
3732 // Ensure that the text will clip to the display rect. Draws to a canvas and 3732 // Ensure that the text will clip to the display rect. Draws to a canvas and
3733 // checks whether any pixel beyond the bounding rectangle is colored. 3733 // checks whether any pixel beyond the bounding rectangle is colored.
3734 TEST_P(RenderTextTest, TextDoesClip) { 3734 TEST_P(RenderTextTest, TextDoesClip) {
3735 const wchar_t* kTestStrings[] = {L"TEST", L"W", L"WWWW", L"gAXAXWWWW"}; 3735 const wchar_t* kTestStrings[] = {L"TEST", L"W", L"WWWW", L"gAXAXWWWW"};
3736 const Size kCanvasSize(300, 50); 3736 const Size kCanvasSize(300, 50);
3737 const int kTestSize = 10; 3737 const int kTestSize = 10;
3738 3738
3739 sk_sp<SkSurface> surface = 3739 sk_sp<SkSurface> surface =
3740 SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height()); 3740 SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height());
3741 Canvas canvas(surface->getCanvas(), 1.0f); 3741 Canvas canvas(sk_ref_sp(surface->getCanvas()), 1.0f);
3742 RenderText* render_text = GetRenderText(); 3742 RenderText* render_text = GetRenderText();
3743 render_text->SetHorizontalAlignment(ALIGN_LEFT); 3743 render_text->SetHorizontalAlignment(ALIGN_LEFT);
3744 render_text->SetColor(SK_ColorBLACK); 3744 render_text->SetColor(SK_ColorBLACK);
3745 3745
3746 for (auto* string : kTestStrings) { 3746 for (auto* string : kTestStrings) {
3747 surface->getCanvas()->clear(SK_ColorWHITE); 3747 surface->getCanvas()->clear(SK_ColorWHITE);
3748 render_text->SetText(WideToUTF16(string)); 3748 render_text->SetText(WideToUTF16(string));
3749 const Size string_size = render_text->GetStringSize(); 3749 const Size string_size = render_text->GetStringSize();
3750 int fake_width = string_size.width() / 2; 3750 int fake_width = string_size.width() / 2;
3751 int fake_height = string_size.height() / 2; 3751 int fake_height = string_size.height() / 2;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
4094 ::testing::Values(RENDER_TEXT_HARFBUZZ), 4094 ::testing::Values(RENDER_TEXT_HARFBUZZ),
4095 PrintRenderTextBackend()); 4095 PrintRenderTextBackend());
4096 #endif 4096 #endif
4097 4097
4098 INSTANTIATE_TEST_CASE_P(, 4098 INSTANTIATE_TEST_CASE_P(,
4099 RenderTextHarfBuzzTest, 4099 RenderTextHarfBuzzTest,
4100 ::testing::Values(RENDER_TEXT_HARFBUZZ), 4100 ::testing::Values(RENDER_TEXT_HARFBUZZ),
4101 PrintRenderTextBackend()); 4101 PrintRenderTextBackend());
4102 4102
4103 } // namespace gfx 4103 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas.cc ('k') | ui/surface/transport_dib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698