/src/mozilla-central/gfx/2d/RecordedEvent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "RecordedEventImpl.h" |
8 | | |
9 | | #include "PathRecording.h" |
10 | | #include "RecordingTypes.h" |
11 | | #include "Tools.h" |
12 | | #include "Filters.h" |
13 | | #include "Logging.h" |
14 | | #include "ScaledFontBase.h" |
15 | | #include "SFNTData.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace gfx { |
19 | | |
20 | | using namespace std; |
21 | | |
22 | | RecordedEvent * |
23 | 0 | RecordedEvent::LoadEventFromStream(std::istream &aStream, EventType aType) { |
24 | 0 | return LoadEvent(aStream, aType); |
25 | 0 | } |
26 | | |
27 | | RecordedEvent * |
28 | 0 | RecordedEvent::LoadEventFromStream(EventStream& aStream, EventType aType) { |
29 | 0 | return LoadEvent(aStream, aType); |
30 | 0 | } |
31 | | |
32 | | string |
33 | | RecordedEvent::GetEventName(EventType aType) |
34 | | { |
35 | | switch (aType) { |
36 | | case DRAWTARGETCREATION: |
37 | | return "DrawTarget Creation"; |
38 | | case DRAWTARGETDESTRUCTION: |
39 | | return "DrawTarget Destruction"; |
40 | | case FILLRECT: |
41 | | return "FillRect"; |
42 | | case STROKERECT: |
43 | | return "StrokeRect"; |
44 | | case STROKELINE: |
45 | | return "StrokeLine"; |
46 | | case CLEARRECT: |
47 | | return "ClearRect"; |
48 | | case COPYSURFACE: |
49 | | return "CopySurface"; |
50 | | case SETTRANSFORM: |
51 | | return "SetTransform"; |
52 | | case PUSHCLIP: |
53 | | return "PushClip"; |
54 | | case PUSHCLIPRECT: |
55 | | return "PushClipRect"; |
56 | | case POPCLIP: |
57 | | return "PopClip"; |
58 | | case FILL: |
59 | | return "Fill"; |
60 | | case FILLGLYPHS: |
61 | | return "FillGlyphs"; |
62 | | case MASK: |
63 | | return "Mask"; |
64 | | case STROKE: |
65 | | return "Stroke"; |
66 | | case DRAWSURFACE: |
67 | | return "DrawSurface"; |
68 | | case DRAWSURFACEWITHSHADOW: |
69 | | return "DrawSurfaceWithShadow"; |
70 | | case DRAWFILTER: |
71 | | return "DrawFilter"; |
72 | | case PATHCREATION: |
73 | | return "PathCreation"; |
74 | | case PATHDESTRUCTION: |
75 | | return "PathDestruction"; |
76 | | case SOURCESURFACECREATION: |
77 | | return "SourceSurfaceCreation"; |
78 | | case SOURCESURFACEDESTRUCTION: |
79 | | return "SourceSurfaceDestruction"; |
80 | | case FILTERNODECREATION: |
81 | | return "FilterNodeCreation"; |
82 | | case FILTERNODEDESTRUCTION: |
83 | | return "FilterNodeDestruction"; |
84 | | case GRADIENTSTOPSCREATION: |
85 | | return "GradientStopsCreation"; |
86 | | case GRADIENTSTOPSDESTRUCTION: |
87 | | return "GradientStopsDestruction"; |
88 | | case SNAPSHOT: |
89 | | return "Snapshot"; |
90 | | case SCALEDFONTCREATION: |
91 | | return "ScaledFontCreation"; |
92 | | case SCALEDFONTDESTRUCTION: |
93 | | return "ScaledFontDestruction"; |
94 | | case MASKSURFACE: |
95 | | return "MaskSurface"; |
96 | | case FILTERNODESETATTRIBUTE: |
97 | | return "SetAttribute"; |
98 | | case FILTERNODESETINPUT: |
99 | | return "SetInput"; |
100 | | case CREATESIMILARDRAWTARGET: |
101 | | return "CreateSimilarDrawTarget"; |
102 | | case FONTDATA: |
103 | | return "FontData"; |
104 | | case FONTDESC: |
105 | | return "FontDescriptor"; |
106 | | case PUSHLAYER: |
107 | | return "PushLayer"; |
108 | | case POPLAYER: |
109 | | return "PopLayer"; |
110 | | case UNSCALEDFONTCREATION: |
111 | | return "UnscaledFontCreation"; |
112 | | case UNSCALEDFONTDESTRUCTION: |
113 | | return "UnscaledFontDestruction"; |
114 | | case EXTERNALSURFACECREATION: |
115 | | return "ExternalSourceSurfaceCreation"; |
116 | | default: |
117 | | return "Unknown"; |
118 | | } |
119 | | } |
120 | | |
121 | | template<class S> |
122 | 0 | void RecordedEvent::RecordUnscaledFontImpl(UnscaledFont *aUnscaledFont, S& aOutput) { |
123 | 0 | RecordedFontData fontData(aUnscaledFont); |
124 | 0 | RecordedFontDetails fontDetails; |
125 | 0 | if (fontData.GetFontDetails(fontDetails)) { |
126 | 0 | // Try to serialise the whole font, just in case this is a web font that |
127 | 0 | // is not present on the system. |
128 | 0 | WriteElement(aOutput, fontData.mType); |
129 | 0 | fontData.RecordToStream(aOutput); |
130 | 0 |
|
131 | 0 | auto r = RecordedUnscaledFontCreation(aUnscaledFont, fontDetails); |
132 | 0 | WriteElement(aOutput, r.mType); |
133 | 0 | r.RecordToStream(aOutput); |
134 | 0 | } else { |
135 | 0 | // If that fails, record just the font description and try to load it from |
136 | 0 | // the system on the other side. |
137 | 0 | RecordedFontDescriptor fontDesc(aUnscaledFont); |
138 | 0 | if (fontDesc.IsValid()) { |
139 | 0 | WriteElement(aOutput, fontDesc.RecordedEvent::mType); |
140 | 0 | fontDesc.RecordToStream(aOutput); |
141 | 0 | } else { |
142 | 0 | gfxWarning() << "DrawTargetRecording::FillGlyphs failed to serialise UnscaledFont"; |
143 | 0 | } |
144 | 0 | } |
145 | 0 | } Unexecuted instantiation: void mozilla::gfx::RecordedEvent::RecordUnscaledFontImpl<std::__1::basic_ostream<char, std::__1::char_traits<char> > >(mozilla::gfx::UnscaledFont*, std::__1::basic_ostream<char, std::__1::char_traits<char> >&) Unexecuted instantiation: void mozilla::gfx::RecordedEvent::RecordUnscaledFontImpl<mozilla::gfx::MemStream>(mozilla::gfx::UnscaledFont*, mozilla::gfx::MemStream&) |
146 | | |
147 | 0 | void RecordedEvent::RecordUnscaledFont(UnscaledFont *aUnscaledFont, std::ostream *aOutput) { |
148 | 0 | RecordUnscaledFontImpl(aUnscaledFont, *aOutput); |
149 | 0 | } |
150 | | |
151 | 0 | void RecordedEvent::RecordUnscaledFont(UnscaledFont *aUnscaledFont, MemStream &aOutput) { |
152 | 0 | RecordUnscaledFontImpl(aUnscaledFont, aOutput); |
153 | 0 | } |
154 | | |
155 | | already_AddRefed<DrawTarget> |
156 | | Translator::CreateDrawTarget(ReferencePtr aRefPtr, const IntSize &aSize, |
157 | | SurfaceFormat aFormat) |
158 | 0 | { |
159 | 0 | RefPtr<DrawTarget> newDT = |
160 | 0 | GetReferenceDrawTarget()->CreateSimilarDrawTarget(aSize, aFormat); |
161 | 0 | AddDrawTarget(aRefPtr, newDT); |
162 | 0 | return newDT.forget(); |
163 | 0 | } |
164 | | |
165 | | } |
166 | | } |