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

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

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

Powered by Google App Engine
This is Rietveld 408576698