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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 2758413002: cc/paint: Remove PaintCanvas::peekPixels. (Closed)
Patch Set: canvas Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« ui/gfx/canvas.h ('K') | « ui/gfx/canvas_paint_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index d83fd6ca5a9f3e68b247bc64ede0f002174c29cf..2400f222a1185c7b277cc25e53f077c39b2ecfe5 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -3759,15 +3759,17 @@ TEST_P(RenderTextTest, TextDoesntClip) {
const Size kCanvasSize(300, 50);
const int kTestSize = 10;
- sk_sp<cc::PaintSurface> surface = cc::PaintSurface::MakeRasterN32Premul(
- kCanvasSize.width(), kCanvasSize.height());
- Canvas canvas(surface->getCanvas(), 1.0f);
+ SkBitmap bitmap;
+ bitmap.allocPixels(
+ SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height()));
+ cc::SkiaPaintCanvas paint_canvas(bitmap);
+ Canvas canvas(&paint_canvas, 1.0f);
RenderText* render_text = GetRenderText();
render_text->SetHorizontalAlignment(ALIGN_LEFT);
render_text->SetColor(SK_ColorBLACK);
for (auto* string : kTestStrings) {
- surface->getCanvas()->clear(SK_ColorWHITE);
+ paint_canvas.clear(SK_ColorWHITE);
render_text->SetText(WideToUTF16(string));
const Size string_size = render_text->GetStringSize();
render_text->ApplyBaselineStyle(SUPERSCRIPT, Range(1, 2));
@@ -3784,7 +3786,7 @@ TEST_P(RenderTextTest, TextDoesntClip) {
render_text->Draw(&canvas);
ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width());
SkPixmap pixmap;
- surface->getCanvas()->peekPixels(&pixmap);
+ bitmap.peekPixels(&pixmap);
const uint32_t* buffer = static_cast<const uint32_t*>(pixmap.addr());
ASSERT_NE(nullptr, buffer);
TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(),
@@ -3852,15 +3854,17 @@ TEST_P(RenderTextTest, TextDoesClip) {
const Size kCanvasSize(300, 50);
const int kTestSize = 10;
- sk_sp<cc::PaintSurface> surface = cc::PaintSurface::MakeRasterN32Premul(
- kCanvasSize.width(), kCanvasSize.height());
- Canvas canvas(surface->getCanvas(), 1.0f);
+ SkBitmap bitmap;
+ bitmap.allocPixels(
+ SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height()));
+ cc::SkiaPaintCanvas paint_canvas(bitmap);
+ Canvas canvas(&paint_canvas, 1.0f);
RenderText* render_text = GetRenderText();
render_text->SetHorizontalAlignment(ALIGN_LEFT);
render_text->SetColor(SK_ColorBLACK);
for (auto* string : kTestStrings) {
- surface->getCanvas()->clear(SK_ColorWHITE);
+ paint_canvas.clear(SK_ColorWHITE);
render_text->SetText(WideToUTF16(string));
const Size string_size = render_text->GetStringSize();
int fake_width = string_size.width() / 2;
@@ -3871,7 +3875,7 @@ TEST_P(RenderTextTest, TextDoesClip) {
render_text->Draw(&canvas);
ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width());
SkPixmap pixmap;
- surface->getCanvas()->peekPixels(&pixmap);
+ bitmap.peekPixels(&pixmap);
const uint32_t* buffer = static_cast<const uint32_t*>(pixmap.addr());
ASSERT_NE(nullptr, buffer);
TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(),
« ui/gfx/canvas.h ('K') | « ui/gfx/canvas_paint_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698