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

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

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 #include "config.h"
32 #include "ThemeHelperChromiumWin.h"
33
34 #include "FloatRect.h"
35 #include "GraphicsContext.h"
36
37 namespace WebCore {
38
39 ThemeHelperWin::ThemeHelperWin(GraphicsContext* context, const IntRect& rect)
40 : m_orgContext(context)
41 , m_orgMatrix(context->getCTM())
42 , m_orgRect(rect)
43 {
44 if (m_orgMatrix.b() != 0 || m_orgMatrix.c() != 0) { // Check for skew.
45 // Complicated effects, make a copy and draw the bitmap there.
46 m_type = COPY;
47 m_rect.setSize(rect.size());
48
49 m_newBuffer.set(ImageBuffer::create(rect.size(), false).release());
50
51 // Theme drawing messes with the transparency.
52 // FIXME: Ideally, we would leave this transparent, but I was
53 // having problems with button drawing, so we fill with white. Buttons
54 // looked good with transparent here and no fixing up of the alpha
55 // later, but text areas didn't. This makes text areas look good but
56 // gives buttons a white halo. Is there a way to fix this? I think
57 // buttons actually have antialised edges which is just not possible
58 // to handle on a transparent background given that it messes with the
59 // alpha channel.
60 FloatRect newContextRect(0, 0, rect.width(), rect.height());
61 GraphicsContext* newContext = m_newBuffer->context();
62 newContext->setFillColor(Color::white);
63 newContext->fillRect(newContextRect);
64
65 return;
66 }
67
68 if (m_orgMatrix.a() != 1.0 || m_orgMatrix.d() != 1.0) { // Check for scale.
69 // Only a scaling is applied.
70 m_type = SCALE;
71
72 // Save the transformed coordinates to draw.
73 m_rect = m_orgMatrix.mapRect(rect);
74
75 m_orgContext->save();
76 m_orgContext->concatCTM(m_orgContext->getCTM().inverse());
77 return;
78 }
79
80 // Nothing interesting.
81 m_rect = rect;
82 m_type = ORIGINAL;
83 }
84
85 ThemeHelperWin::~ThemeHelperWin()
86 {
87 switch (m_type) {
88 case SCALE:
89 m_orgContext->restore();
90 break;
91 case COPY: {
92 // Copy the duplicate bitmap with our control to the original canvas.
93 FloatRect destRect(m_orgRect);
94 m_newBuffer->context()->platformContext()->canvas()->
95 getTopPlatformDevice().fixupAlphaBeforeCompositing();
96 m_orgContext->drawImage(m_newBuffer->image(), destRect);
97 break;
98 }
99 case ORIGINAL:
100 break;
101 }
102 }
103
104 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698