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

Side by Side Diff: core/fxge/skia/fx_skia_device_unittest.cpp

Issue 2158023002: Pdfium: Fix fonts leaking on ClosePage. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix xfa tests. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium 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 "core/fxge/include/cfx_fontcache.h"
6 #include "core/fxge/include/cfx_fxgedevice.h" 5 #include "core/fxge/include/cfx_fxgedevice.h"
7 #include "core/fxge/include/cfx_graphstatedata.h" 6 #include "core/fxge/include/cfx_graphstatedata.h"
8 #include "core/fxge/include/cfx_pathdata.h" 7 #include "core/fxge/include/cfx_pathdata.h"
9 #include "core/fxge/include/cfx_renderdevice.h" 8 #include "core/fxge/include/cfx_renderdevice.h"
10 #include "core/fxge/skia/fx_skia_device.h" 9 #include "core/fxge/skia/fx_skia_device.h"
11 #include "fpdfsdk/include/fsdk_define.h" 10 #include "fpdfsdk/include/fsdk_define.h"
12 #include "public/fpdfview.h" 11 #include "public/fpdfview.h"
13 #include "testing/fx_string_testhelpers.h" 12 #include "testing/fx_string_testhelpers.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/core/SkPictureRecorder.h" 14 #include "third_party/skia/include/core/SkPictureRecorder.h"
(...skipping 16 matching lines...) Expand all
32 void EmptyTest(CFX_SkiaDeviceDriver* driver, const State&) { 31 void EmptyTest(CFX_SkiaDeviceDriver* driver, const State&) {
33 driver->SaveState(); 32 driver->SaveState();
34 driver->RestoreState(true); 33 driver->RestoreState(true);
35 driver->RestoreState(false); 34 driver->RestoreState(false);
36 } 35 }
37 36
38 void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) { 37 void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) {
39 FXTEXT_CHARPOS charPos[] = {{{0, 0, 0, 0}, 0, 1, 1, 4, false, false}}; 38 FXTEXT_CHARPOS charPos[] = {{{0, 0, 0, 0}, 0, 1, 1, 4, false, false}};
40 CFX_Font font; 39 CFX_Font font;
41 FX_FLOAT fontSize = 1; 40 FX_FLOAT fontSize = 1;
42 CFX_FontCache cache;
43 CFX_PathData clipPath, clipPath2; 41 CFX_PathData clipPath, clipPath2;
44 clipPath.AppendRect(0, 0, 3, 1); 42 clipPath.AppendRect(0, 0, 3, 1);
45 clipPath2.AppendRect(0, 0, 2, 1); 43 clipPath2.AppendRect(0, 0, 2, 1);
46 CFX_Matrix clipMatrix; 44 CFX_Matrix clipMatrix;
47 CFX_Matrix clipMatrix2(1, 0, 0, 1, 0, 1); 45 CFX_Matrix clipMatrix2(1, 0, 0, 1, 0, 1);
48 driver->SaveState(); 46 driver->SaveState();
49 CFX_PathData path1; 47 CFX_PathData path1;
50 path1.AppendRect(0, 0, 1, 2); 48 path1.AppendRect(0, 0, 1, 2);
51 CFX_Matrix matrix, matrix2; 49 CFX_Matrix matrix, matrix2;
52 matrix2.Translate(1, 0); 50 matrix2.Translate(1, 0);
53 CFX_GraphStateData graphState; 51 CFX_GraphStateData graphState;
54 if (state.m_save == State::Save::kYes) 52 if (state.m_save == State::Save::kYes)
55 driver->SaveState(); 53 driver->SaveState();
56 if (state.m_clip != State::Clip::kNo) 54 if (state.m_clip != State::Clip::kNo)
57 driver->SetClip_PathFill(&clipPath, &clipMatrix, 0); 55 driver->SetClip_PathFill(&clipPath, &clipMatrix, 0);
58 if (state.m_graphic == State::Graphic::kPath) { 56 if (state.m_graphic == State::Graphic::kPath) {
59 driver->DrawPath(&path1, &matrix, &graphState, 0xFF112233, 0, 57 driver->DrawPath(&path1, &matrix, &graphState, 0xFF112233, 0,
60 FXFILL_WINDING, 0); 58 FXFILL_WINDING, 0);
61 } else if (state.m_graphic == State::Graphic::kText) { 59 } else if (state.m_graphic == State::Graphic::kText) {
62 driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, &cache, 60 driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, &matrix,
63 &matrix, fontSize, 0xFF445566); 61 fontSize, 0xFF445566);
64 } 62 }
65 if (state.m_save == State::Save::kYes) 63 if (state.m_save == State::Save::kYes)
66 driver->RestoreState(true); 64 driver->RestoreState(true);
67 CFX_PathData path2; 65 CFX_PathData path2;
68 path2.AppendRect(0, 0, 2, 2); 66 path2.AppendRect(0, 0, 2, 2);
69 if (state.m_change == State::Change::kYes) { 67 if (state.m_change == State::Change::kYes) {
70 if (state.m_graphic == State::Graphic::kPath) 68 if (state.m_graphic == State::Graphic::kPath)
71 graphState.m_LineCap = CFX_GraphStateData::LineCapRound; 69 graphState.m_LineCap = CFX_GraphStateData::LineCapRound;
72 else if (state.m_graphic == State::Graphic::kText) 70 else if (state.m_graphic == State::Graphic::kText)
73 fontSize = 2; 71 fontSize = 2;
74 } 72 }
75 if (state.m_clip == State::Clip::kSame) 73 if (state.m_clip == State::Clip::kSame)
76 driver->SetClip_PathFill(&clipPath, &clipMatrix, 0); 74 driver->SetClip_PathFill(&clipPath, &clipMatrix, 0);
77 else if (state.m_clip == State::Clip::kDifferentPath) 75 else if (state.m_clip == State::Clip::kDifferentPath)
78 driver->SetClip_PathFill(&clipPath2, &clipMatrix, 0); 76 driver->SetClip_PathFill(&clipPath2, &clipMatrix, 0);
79 else if (state.m_clip == State::Clip::kDifferentMatrix) 77 else if (state.m_clip == State::Clip::kDifferentMatrix)
80 driver->SetClip_PathFill(&clipPath, &clipMatrix2, 0); 78 driver->SetClip_PathFill(&clipPath, &clipMatrix2, 0);
81 if (state.m_graphic == State::Graphic::kPath) { 79 if (state.m_graphic == State::Graphic::kPath) {
82 driver->DrawPath(&path2, &matrix2, &graphState, 0xFF112233, 0, 80 driver->DrawPath(&path2, &matrix2, &graphState, 0xFF112233, 0,
83 FXFILL_WINDING, 0); 81 FXFILL_WINDING, 0);
84 } else if (state.m_graphic == State::Graphic::kText) { 82 } else if (state.m_graphic == State::Graphic::kText) {
85 driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, &cache, 83 driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, &matrix2,
86 &matrix2, fontSize, 0xFF445566); 84 fontSize, 0xFF445566);
87 } 85 }
88 if (state.m_save == State::Save::kYes) 86 if (state.m_save == State::Save::kYes)
89 driver->RestoreState(false); 87 driver->RestoreState(false);
90 driver->RestoreState(false); 88 driver->RestoreState(false);
91 } 89 }
92 90
93 void OutOfSequenceClipTest(CFX_SkiaDeviceDriver* driver, const State&) { 91 void OutOfSequenceClipTest(CFX_SkiaDeviceDriver* driver, const State&) {
94 CFX_PathData clipPath; 92 CFX_PathData clipPath;
95 clipPath.AppendRect(1, 0, 3, 1); 93 clipPath.AppendRect(1, 0, 3, 1);
96 CFX_Matrix clipMatrix; 94 CFX_Matrix clipMatrix;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 Harness(&CommonTest, 157 Harness(&CommonTest,
160 {State::Change::kNo, State::Save::kYes, State::Clip::kDifferentMatrix, 158 {State::Change::kNo, State::Save::kYes, State::Clip::kDifferentMatrix,
161 State::Graphic::kText, 0xFF445566}); 159 State::Graphic::kText, 0xFF445566});
162 Harness(&CommonTest, {State::Change::kNo, State::Save::kYes, 160 Harness(&CommonTest, {State::Change::kNo, State::Save::kYes,
163 State::Clip::kSame, State::Graphic::kText, 0xFF445566}); 161 State::Clip::kSame, State::Graphic::kText, 0xFF445566});
164 } 162 }
165 163
166 TEST(fxge, SkiaStateOOSClip) { 164 TEST(fxge, SkiaStateOOSClip) {
167 Harness(&OutOfSequenceClipTest, {}); 165 Harness(&OutOfSequenceClipTest, {});
168 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698