| OLD | NEW |
| 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 "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 void BeginTransparencyDisplayItem::replay(GraphicsContext* context) | 12 void BeginTransparencyDisplayItem::replay(GraphicsContext* context) |
| 13 { | 13 { |
| 14 context->save(); | 14 context->save(); |
| 15 context->clip(m_clipRect); | 15 context->clip(m_clipRect); |
| 16 | 16 |
| 17 if (m_hasBlendMode) | 17 bool hasBlendMode = this->hasBlendMode(); |
| 18 if (hasBlendMode) |
| 18 context->setCompositeOperation(context->compositeOperation(), m_blendMod
e); | 19 context->setCompositeOperation(context->compositeOperation(), m_blendMod
e); |
| 19 | 20 |
| 20 context->beginTransparencyLayer(m_opacity); | 21 context->beginTransparencyLayer(m_opacity); |
| 21 | 22 |
| 22 if (m_hasBlendMode) | 23 if (hasBlendMode) |
| 23 context->setCompositeOperation(context->compositeOperation(), WebBlendMo
deNormal); | 24 context->setCompositeOperation(context->compositeOperation(), WebBlendMo
deNormal); |
| 24 #ifdef REVEAL_TRANSPARENCY_LAYERS | 25 #ifdef REVEAL_TRANSPARENCY_LAYERS |
| 25 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)); |
| 26 #endif | 27 #endif |
| 27 } | 28 } |
| 28 | 29 |
| 29 #ifndef NDEBUG | 30 #ifndef NDEBUG |
| 30 WTF::String BeginTransparencyDisplayItem::asDebugString() const | 31 WTF::String BeginTransparencyDisplayItem::asDebugString() const |
| 31 { | 32 { |
| 32 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}", |
| 33 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), | 34 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), |
| 34 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(), |
| 35 m_hasBlendMode, m_blendMode, m_opacity); | 36 hasBlendMode(), m_blendMode, m_opacity); |
| 36 } | 37 } |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 void EndTransparencyDisplayItem::replay(GraphicsContext* context) | 40 void EndTransparencyDisplayItem::replay(GraphicsContext* context) |
| 40 { | 41 { |
| 41 context->endLayer(); | 42 context->endLayer(); |
| 42 context->restore(); | 43 context->restore(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 #ifndef NDEBUG | 46 #ifndef NDEBUG |
| 46 WTF::String EndTransparencyDisplayItem::asDebugString() const | 47 WTF::String EndTransparencyDisplayItem::asDebugString() const |
| 47 { | 48 { |
| 48 return String::format("{%s, type: \"%s\"}", | 49 return String::format("{%s, type: \"%s\"}", |
| 49 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data()); | 50 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data()); |
| 50 } | 51 } |
| 51 #endif | 52 #endif |
| 52 | 53 |
| 53 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |