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> | |
53 | 52 |
54 namespace blink { | 53 namespace blink { |
55 | 54 |
56 GraphicsContext::GraphicsContext(PaintController& paintController, DisabledMode
disableContextOrPainting, SkMetaData* metaData) | 55 GraphicsContext::GraphicsContext(PaintController& paintController, DisabledMode
disableContextOrPainting, SkMetaData* metaData) |
57 : m_canvas(nullptr) | 56 : m_canvas(nullptr) |
58 , m_paintController(paintController) | 57 , m_paintController(paintController) |
59 , m_paintStateStack() | 58 , m_paintStateStack() |
60 , m_paintStateIndex(0) | 59 , m_paintStateIndex(0) |
61 #if ENABLE(ASSERT) | 60 #if ENABLE(ASSERT) |
62 , m_layerCount(0) | 61 , m_layerCount(0) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 168 } |
170 #endif | 169 #endif |
171 | 170 |
172 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, | 171 void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color
& color, |
173 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, | 172 DrawLooperBuilder::ShadowTransformMode shadowTransformMode, |
174 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode, ShadowMode shadowMode) | 173 DrawLooperBuilder::ShadowAlphaMode shadowAlphaMode, ShadowMode shadowMode) |
175 { | 174 { |
176 if (contextDisabled()) | 175 if (contextDisabled()) |
177 return; | 176 return; |
178 | 177 |
179 std::unique_ptr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::cr
eate(); | 178 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); |
180 if (!color.alpha()) { | 179 if (!color.alpha()) { |
181 // When shadow-only but there is no shadow, we use an empty draw looper | 180 // When shadow-only but there is no shadow, we use an empty draw looper |
182 // to disable rendering of the source primitive. When not shadow-only,
we | 181 // to disable rendering of the source primitive. When not shadow-only,
we |
183 // clear the looper. | 182 // clear the looper. |
184 if (shadowMode != DrawShadowOnly) | 183 if (shadowMode != DrawShadowOnly) |
185 drawLooperBuilder.reset(); | 184 drawLooperBuilder.reset(); |
186 | 185 |
187 setDrawLooper(std::move(drawLooperBuilder)); | 186 setDrawLooper(std::move(drawLooperBuilder)); |
188 return; | 187 return; |
189 } | 188 } |
190 | 189 |
191 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado
wAlphaMode); | 190 drawLooperBuilder->addShadow(offset, blur, color, shadowTransformMode, shado
wAlphaMode); |
192 if (shadowMode == DrawShadowAndForeground) { | 191 if (shadowMode == DrawShadowAndForeground) { |
193 drawLooperBuilder->addUnmodifiedContent(); | 192 drawLooperBuilder->addUnmodifiedContent(); |
194 } | 193 } |
195 setDrawLooper(std::move(drawLooperBuilder)); | 194 setDrawLooper(std::move(drawLooperBuilder)); |
196 } | 195 } |
197 | 196 |
198 void GraphicsContext::setDrawLooper(std::unique_ptr<DrawLooperBuilder> drawLoope
rBuilder) | 197 void GraphicsContext::setDrawLooper(PassOwnPtr<DrawLooperBuilder> drawLooperBuil
der) |
199 { | 198 { |
200 if (contextDisabled()) | 199 if (contextDisabled()) |
201 return; | 200 return; |
202 | 201 |
203 mutableState()->setDrawLooper(drawLooperBuilder ? drawLooperBuilder->detachD
rawLooper() : nullptr); | 202 mutableState()->setDrawLooper(drawLooperBuilder ? drawLooperBuilder->detachD
rawLooper() : nullptr); |
204 } | 203 } |
205 | 204 |
206 SkColorFilter* GraphicsContext::colorFilter() const | 205 SkColorFilter* GraphicsContext::colorFilter() const |
207 { | 206 { |
208 return immutableState()->colorFilter(); | 207 return immutableState()->colorFilter(); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if (rect.isRounded()) { | 426 if (rect.isRounded()) { |
428 clipRoundedRect(rect); | 427 clipRoundedRect(rect); |
429 if (shadowSpread < 0) | 428 if (shadowSpread < 0) |
430 roundedHole.expandRadii(-shadowSpread); | 429 roundedHole.expandRadii(-shadowSpread); |
431 else | 430 else |
432 roundedHole.shrinkRadii(shadowSpread); | 431 roundedHole.shrinkRadii(shadowSpread); |
433 } else { | 432 } else { |
434 clip(rect.rect()); | 433 clip(rect.rect()); |
435 } | 434 } |
436 | 435 |
437 std::unique_ptr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::cr
eate(); | 436 OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create(); |
438 drawLooperBuilder->addShadow(FloatSize(shadowOffset), shadowBlur, shadowColo
r, | 437 drawLooperBuilder->addShadow(FloatSize(shadowOffset), shadowBlur, shadowColo
r, |
439 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg
noresAlpha); | 438 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIg
noresAlpha); |
440 setDrawLooper(std::move(drawLooperBuilder)); | 439 setDrawLooper(std::move(drawLooperBuilder)); |
441 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); | 440 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); |
442 } | 441 } |
443 | 442 |
444 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) | 443 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) |
445 { | 444 { |
446 if (contextDisabled()) | 445 if (contextDisabled()) |
447 return; | 446 return; |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 static const SkPMColor colors[] = { | 1330 static const SkPMColor colors[] = { |
1332 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1331 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
1333 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1332 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
1334 }; | 1333 }; |
1335 | 1334 |
1336 return colors[index]; | 1335 return colors[index]; |
1337 } | 1336 } |
1338 #endif | 1337 #endif |
1339 | 1338 |
1340 } // namespace blink | 1339 } // namespace blink |
OLD | NEW |