[Skia] Enable fxge.SkiaStateText for Skia
Currently fxge.SkiaStateText fails because `font` doesn't contain any
data and CFX_SkiaDeviceDriver::DrawDeviceText() becomes a no-op.
This CL makes `font` load data from "Noto Sans CJK JP" and draw a
glyph at a larger font size, so that we can make sure the position
(0, 0) will be painted. This CL also disables anti-aliasing for text
rendering, so that any painted area will be filled with one expected
color instead of transitional colors.
Bug: pdfium:1500
Change-Id: I4e63e5be0d18bf47cebd1b7b818644b3b1e030c2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/109830
Commit-Queue: Nigi <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp
index 8fba0e4..ca38a1e 100644
--- a/core/fxge/skia/fx_skia_device_embeddertest.cpp
+++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/render/cpdf_pagerendercontext.h"
+#include "core/fxcrt/fx_codepage.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_fillrenderoptions.h"
#include "core/fxge/cfx_font.h"
@@ -59,11 +60,14 @@
void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) {
TextCharPos charPos[1];
charPos[0].m_Origin = CFX_PointF(0, 1);
- charPos[0].m_GlyphIndex = 1;
+ charPos[0].m_GlyphIndex = 0;
charPos[0].m_FontCharWidth = 4;
CFX_Font font;
- float fontSize = 1;
+ font.LoadSubst("Courier", /*bTrueType=*/true, /*flags=*/0,
+ /*weight=*/400, /*italic_angle=*/0, FX_CodePage::kShiftJIS,
+ /*bVertical=*/false);
+ float fontSize = 20;
CFX_Path clipPath;
CFX_Path clipPath2;
clipPath.AppendRect(0, 0, 3, 1);
@@ -78,7 +82,10 @@
CFX_Matrix matrix2;
matrix2.Translate(1, 0);
CFX_GraphStateData graphState;
- static constexpr CFX_TextRenderOptions kTextOptions;
+ // Turn off anti-aliasing so that pixels with transitional colors can be
+ // avoided.
+ static constexpr CFX_TextRenderOptions kTextOptions(
+ CFX_TextRenderOptions::kAliasing);
if (state.m_save == State::Save::kYes)
driver->SaveState();
if (state.m_clip != State::Clip::kNo)
@@ -221,8 +228,7 @@
State::Graphic::kPath, 0xFF112233});
}
-// TODO(crbug.com/pdfium/11): Fix this test and enable.
-TEST(fxge, DISABLED_SkiaStateText) {
+TEST(fxge, SkiaStateText) {
if (!CFX_DefaultRenderDevice::SkiaIsDefaultRenderer())
return;