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

Side by Side Diff: third_party/WebKit/WebCore/platform/graphics/chromium/ThemeHelperChromiumWin.h

Issue 21201: Transparency (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2008, 2009, 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 ThemeHelperWin_h
32 #define ThemeHelperWin_h
33
34 #include "TransformationMatrix.h"
35 #include "ImageBuffer.h"
36 #include "IntRect.h"
37 #include <wtf/OwnPtr.h>
38
39 namespace WebCore {
40
41 class GraphicsContext;
42 class IntRect;
43
44 // Helps drawing theme elements like buttons and scroll bars. This will handle
45 // translations and scalings that Windows might not, by either making Windows
46 // draw the appropriate sized control, or by rendering it into an off-screen
47 // context and transforming it ourselves.
48 class ThemeHelperWin {
49 enum Type {
50 // Use the original canvas with no changes. This is the normal mode.
51 ORIGINAL,
52
53 // Use the original canvas but scale the rectangle of the control so
54 // that it will be the correct size, undoing any scale already on the
55 // canvas. This will have the effect of just drawing the control bigger
56 // or smaller and not actually expanding or contracting the pixels in
57 // it. This usually looks better.
58 SCALE,
59
60 // Make a copy of the control and then transform it ourselves after
61 // Windows draws it. This allows us to get complex effects.
62 COPY,
63 };
64
65 public:
66 // Prepares drawing a control with the given rect to the given context.
67 ThemeHelperWin(GraphicsContext* context, const IntRect& rect);
68 ~ThemeHelperWin();
69
70 // Returns the context to draw the control into, which may be the original
71 // or the copy, depending on the mode.
72 GraphicsContext* context()
73 {
74 return m_newBuffer.get() ? m_newBuffer->context() : m_orgContext;
75 }
76
77 // Returns the rectangle in which to draw into the canvas() by Windows.
78 const IntRect& rect() { return m_rect; }
79
80 private:
81 Type m_type;
82
83 // The original canvas to wrote to. Not owned by this class.
84 GraphicsContext* m_orgContext;
85 TransformationMatrix m_orgMatrix;
86 IntRect m_orgRect;
87
88 // When m_type == COPY, this will be a new surface owned by this class that
89 // represents the copy.
90 OwnPtr<ImageBuffer> m_newBuffer;
91
92 // The control rectangle in the coordinate space of canvas().
93 IntRect m_rect;
94 };
95
96 } // namespace WebCore
97
98 #endif // ThemeHelperWin_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698