| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "third_party/skia/include/core/SkData.h" | 42 #include "third_party/skia/include/core/SkData.h" |
| 43 #include "third_party/skia/include/core/SkPicture.h" | 43 #include "third_party/skia/include/core/SkPicture.h" |
| 44 #include "third_party/skia/include/core/SkPictureRecorder.h" | 44 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 45 #include "third_party/skia/include/core/SkRRect.h" | 45 #include "third_party/skia/include/core/SkRRect.h" |
| 46 #include "third_party/skia/include/core/SkRefCnt.h" | 46 #include "third_party/skia/include/core/SkRefCnt.h" |
| 47 #include "third_party/skia/include/effects/SkLumaColorFilter.h" | 47 #include "third_party/skia/include/effects/SkLumaColorFilter.h" |
| 48 #include "third_party/skia/include/effects/SkPictureImageFilter.h" | 48 #include "third_party/skia/include/effects/SkPictureImageFilter.h" |
| 49 #include "third_party/skia/include/utils/SkNullCanvas.h" | 49 #include "third_party/skia/include/utils/SkNullCanvas.h" |
| 50 #include "wtf/Assertions.h" | 50 #include "wtf/Assertions.h" |
| 51 #include "wtf/MathExtras.h" | 51 #include "wtf/MathExtras.h" |
| 52 #include <memory> |
| 52 | 53 |
| 53 namespace blink { | 54 namespace blink { |
| 54 | 55 |
| 55 GraphicsContext::GraphicsContext(PaintController& paintController, DisabledMode
disableContextOrPainting, SkMetaData* metaData) | 56 GraphicsContext::GraphicsContext(PaintController& paintController, DisabledMode
disableContextOrPainting, SkMetaData* metaData) |
| 56 : m_canvas(nullptr) | 57 : m_canvas(nullptr) |
| 57 , m_paintController(paintController) | 58 , m_paintController(paintController) |
| 58 , m_paintStateStack() | 59 , m_paintStateStack() |
| 59 , m_paintStateIndex(0) | 60 , m_paintStateIndex(0) |
| 60 #if ENABLE(ASSERT) | 61 #if ENABLE(ASSERT) |
| 61 , m_layerCount(0) | 62 , m_layerCount(0) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 169 } |
| 169 #endif | 170 #endif |
| 170 | 171 |
| 171 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, | 172 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, |
| 172 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, | 173 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, |
| 173 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode, ShadowMode shadowMode) | 174 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode, ShadowMode shadowMode) |
| 174 { | 175 { |
| 175 if (contextDisabled()) | 176 if (contextDisabled()) |
| 176 return; | 177 return; |
| 177 | 178 |
| 178 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); | 179 std::unique_ptr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::cr
eate(); |
| 179 if (!color.alpha()) { | 180 if (!color.alpha()) { |
| 180 // When shadow-only but there is no shadow, we use an empty draw looper | 181 // When shadow-only but there is no shadow, we use an empty draw looper |
| 181 // to disable rendering of the source primitive. When not shadow-only,
we | 182 // to disable rendering of the source primitive. When not shadow-only,
we |
| 182 // clear the looper. | 183 // clear the looper. |
| 183 if (shadowMode != DrawShadowOnly) | 184 if (shadowMode != DrawShadowOnly) |
| 184 drawLooperBuilder.reset(); | 185 drawLooperBuilder.reset(); |
| 185 | 186 |
| 186 setDrawLooper(std::move(drawLooperBuilder)); | 187 setDrawLooper(std::move(drawLooperBuilder)); |
| 187 return; | 188 return; |
| 188 } | 189 } |
| 189 | 190 |
| 190 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado
wAlphaMode); | 191 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado
wAlphaMode); |
| 191 if (shadowMode == DrawShadowAndForeground) { | 192 if (shadowMode == DrawShadowAndForeground) { |
| 192 drawLooperBuilder->addUnmodifiedContent(); | 193 drawLooperBuilder->addUnmodifiedContent(); |
| 193 } | 194 } |
| 194 setDrawLooper(std::move(drawLooperBuilder)); | 195 setDrawLooper(std::move(drawLooperBuilder)); |
| 195 } | 196 } |
| 196 | 197 |
| 197 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil
der) | 198 void GraphicsContext::setDrawLooper(std::unique_ptr<DrawLooperBuilder> drawLoope
rBuilder) |
| 198 { | 199 { |
| 199 if (contextDisabled()) | 200 if (contextDisabled()) |
| 200 return; | 201 return; |
| 201 | 202 |
| 202 mutableState()->setDrawLooper(drawLooperBuilder ? drawLooperBuilder->detachD
rawLooper() : nullptr); | 203 mutableState()->setDrawLooper(drawLooperBuilder ? drawLooperBuilder->detachD
rawLooper() : nullptr); |
| 203 } | 204 } |
| 204 | 205 |
| 205 SkColorFilter* GraphicsContext::colorFilter() const | 206 SkColorFilter* GraphicsContext::colorFilter() const |
| 206 { | 207 { |
| 207 return immutableState()->colorFilter(); | 208 return immutableState()->colorFilter(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (rect.isRounded()) { | 427 if (rect.isRounded()) { |
| 427 clipRoundedRect(rect); | 428 clipRoundedRect(rect); |
| 428 if (shadowSpread < 0) | 429 if (shadowSpread < 0) |
| 429 roundedHole.expandRadii(-shadowSpread); | 430 roundedHole.expandRadii(-shadowSpread); |
| 430 else | 431 else |
| 431 roundedHole.shrinkRadii(shadowSpread); | 432 roundedHole.shrinkRadii(shadowSpread); |
| 432 } else { | 433 } else { |
| 433 clip(rect.rect()); | 434 clip(rect.rect()); |
| 434 } | 435 } |
| 435 | 436 |
| 436 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); | 437 std::unique_ptr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::cr
eate(); |
| 437 drawLooperBuilder->addShadow(FloatSize(shadowOffset), shadowBlur, shadowColo
r, | 438 drawLooperBuilder->addShadow(FloatSize(shadowOffset), shadowBlur, shadowColo
r, |
| 438 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg
noresAlpha); | 439 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg
noresAlpha); |
| 439 setDrawLooper(std::move(drawLooperBuilder)); | 440 setDrawLooper(std::move(drawLooperBuilder)); |
| 440 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); | 441 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); |
| 441 } | 442 } |
| 442 | 443 |
| 443 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) | 444 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) |
| 444 { | 445 { |
| 445 if (contextDisabled()) | 446 if (contextDisabled()) |
| 446 return; | 447 return; |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 static const SkPMColor colors[] = { | 1331 static const SkPMColor colors[] = { |
| 1331 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1332 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1332 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1333 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1333 }; | 1334 }; |
| 1334 | 1335 |
| 1335 return colors[index]; | 1336 return colors[index]; |
| 1336 } | 1337 } |
| 1337 #endif | 1338 #endif |
| 1338 | 1339 |
| 1339 } // namespace blink | 1340 } // namespace blink |
| OLD | NEW |