• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2008, Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef SkiaFontWin_h
32 #define SkiaFontWin_h
33 
34 #include <windows.h>
35 #include <usp10.h>
36 
37 class SkPath;
38 class SkPoint;
39 
40 namespace WebCore {
41 
42 class GraphicsContext;
43 class PlatformContextSkia;
44 
45 // FIXME: Rename file to SkiaWinOutlineCache
46 class SkiaWinOutlineCache {
47 public:
48     static const SkPath* lookupOrCreatePathForGlyph(HDC, HFONT, WORD);
49     // Removes any cached glyphs from the outline cache corresponding to the
50     // given font handle.
51     static void removePathsForFont(HFONT);
52 
53 private:
54     SkiaWinOutlineCache();
55 };
56 
57 // The functions below are used for more complex font drawing (effects such as
58 // stroking and more complex transforms) than Windows supports directly.  Since
59 // Windows drawing is faster you should use windowsCanHandleTextDrawing first to
60 // check if using Skia is required at all.
61 // Note that the text will look different (no ClearType) so this should only be
62 // used when necessary.
63 //
64 // When you call a Skia* text drawing function, various glyph outlines will be
65 // cached. As a result, you should call SkiaWinOutlineCache::removePathsForFont
66 // when the font is destroyed so that the cache does not outlive the font (since
67 // the HFONTs are recycled).
68 //
69 // Remember that Skia's text drawing origin is the baseline, like WebKit, not
70 // the top, like Windows.
71 
72 // Returns true if the fillColor and shadowColor are opaque and the text-shadow
73 // is not blurred.
74 bool windowsCanHandleDrawTextShadow(GraphicsContext*);
75 
76 // Returns true if advanced font rendering is recommended.
77 bool windowsCanHandleTextDrawing(GraphicsContext*);
78 
79 // Returns true if advanced font rendering is recommended if shadows are
80 // disregarded.
81 bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext*);
82 
83 // Note that the offsets parameter is optional.  If not NULL it represents a
84 // per glyph offset (such as returned by ScriptPlace Windows API function).
85 //
86 // Returns true of the text was drawn successfully. False indicates an error
87 // from Windows.
88 bool paintSkiaText(GraphicsContext* graphicsContext,
89                    HFONT hfont,
90                    int numGlyphs,
91                    const WORD* glyphs,
92                    const int* advances,
93                    const GOFFSET* offsets,
94                    const SkPoint* origin);
95 
96 }  // namespace WebCore
97 
98 #endif  // SkiaFontWin_h
99