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

Side by Side Diff: Source/core/paint/TransparencyDisplayItem.cpp

Issue 744163002: Enable fast/images with slimming paint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: New Types! Created 6 years, 1 month 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
« no previous file with comments | « Source/core/paint/TransparencyDisplayItem.h ('k') | Source/core/paint/ViewDisplayList.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 "config.h" 5 #include "config.h"
6 #include "core/paint/TransparencyDisplayItem.h" 6 #include "core/paint/TransparencyDisplayItem.h"
7 7
8 #include "core/rendering/RenderObject.h"
9 #include "core/rendering/RenderView.h"
10 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/graphics/GraphicsContext.h" 11 #include "platform/graphics/GraphicsContext.h"
9 12
10 namespace blink { 13 namespace blink {
11 14
12 void BeginTransparencyDisplayItem::replay(GraphicsContext* context) 15 void BeginTransparencyDisplayItem::replay(GraphicsContext* context)
13 { 16 {
14 context->save();
15 context->clip(m_clipRect);
16
17 bool hasBlendMode = this->hasBlendMode(); 17 bool hasBlendMode = this->hasBlendMode();
18 if (hasBlendMode) 18 if (hasBlendMode)
19 context->setCompositeOperation(context->compositeOperation(), m_blendMod e); 19 context->setCompositeOperation(context->compositeOperation(), m_blendMod e);
20 20
21 context->beginTransparencyLayer(m_opacity); 21 context->beginTransparencyLayer(m_opacity);
22 22
23 if (hasBlendMode) 23 if (hasBlendMode)
24 context->setCompositeOperation(context->compositeOperation(), WebBlendMo deNormal); 24 context->setCompositeOperation(context->compositeOperation(), WebBlendMo deNormal);
25 #ifdef REVEAL_TRANSPARENCY_LAYERS 25 #ifdef REVEAL_TRANSPARENCY_LAYERS
26 context->fillRect(clipRect, Color(0.0f, 0.0f, 0.5f, 0.2f)); 26 context->fillRect(clipRect, Color(0.0f, 0.0f, 0.5f, 0.2f));
leviw_travelin_and_unemployed 2014/11/21 22:15:50 How much do we care about this? If we delete this
chrishtr 2014/11/21 22:17:42 Is this ever #defined? I can't find it in codesear
27 #endif 27 #endif
28 } 28 }
29 29
30 #ifndef NDEBUG 30 #ifndef NDEBUG
31 WTF::String BeginTransparencyDisplayItem::asDebugString() const 31 WTF::String BeginTransparencyDisplayItem::asDebugString() const
32 { 32 {
33 return String::format("{%s, type: \"%s\", clip bounds: [%f,%f,%f,%f], hasBle ndMode: %d, blendMode: %d, opacity: %f}", 33 return String::format("{%s, type: \"%s\", clip bounds: [%f,%f,%f,%f], hasBle ndMode: %d, blendMode: %d, opacity: %f}",
34 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data(), 34 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data(),
35 m_clipRect.x().toFloat(), m_clipRect.y().toFloat(), m_clipRect.width().t oFloat(), m_clipRect.height().toFloat(), 35 m_clipRect.x().toFloat(), m_clipRect.y().toFloat(), m_clipRect.width().t oFloat(), m_clipRect.height().toFloat(),
36 hasBlendMode(), m_blendMode, m_opacity); 36 hasBlendMode(), m_blendMode, m_opacity);
37 } 37 }
38 #endif 38 #endif
39 39
40 void EndTransparencyDisplayItem::replay(GraphicsContext* context) 40 void EndTransparencyDisplayItem::replay(GraphicsContext* context)
41 { 41 {
42 context->endLayer(); 42 context->endLayer();
43 context->restore();
44 } 43 }
45 44
46 #ifndef NDEBUG 45 #ifndef NDEBUG
47 WTF::String EndTransparencyDisplayItem::asDebugString() const 46 WTF::String EndTransparencyDisplayItem::asDebugString() const
48 { 47 {
49 return String::format("{%s, type: \"%s\"}", 48 return String::format("{%s, type: \"%s\"}",
50 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data()); 49 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type()) .utf8().data());
51 } 50 }
52 #endif 51 #endif
53 52
53 TransparencyRecorder::TransparencyRecorder(GraphicsContext* graphicsContext, con st RenderObject* renderer, DisplayItem::Type type, const LayoutRect& clipRect, c onst WebBlendMode& blendMode, const float opacity)
54 : m_renderer(renderer)
55 , m_type(type)
56 , m_graphicsContext(graphicsContext)
57 {
58 OwnPtr<BeginTransparencyDisplayItem> beginTransparencyDisplayItem = adoptPtr (new BeginTransparencyDisplayItem(renderer, type, clipRect, blendMode, opacity)) ;
59 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
60 renderer->view()->viewDisplayList().add(beginTransparencyDisplayItem.rel ease());
61 else
62 beginTransparencyDisplayItem->replay(graphicsContext);
63 }
64
65 TransparencyRecorder::~TransparencyRecorder()
66 {
67 OwnPtr<EndTransparencyDisplayItem> endTransparencyDisplayItem = adoptPtr(new EndTransparencyDisplayItem(m_renderer, m_type));
68 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
69 m_renderer->view()->viewDisplayList().add(endTransparencyDisplayItem.rel ease());
70 else
71 endTransparencyDisplayItem->replay(m_graphicsContext);
72 }
73
54 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/TransparencyDisplayItem.h ('k') | Source/core/paint/ViewDisplayList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698