OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2008-2009 Torch Mobile, Inc. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "platform/PlatformExport.h" | 31 #include "platform/PlatformExport.h" |
32 #include "platform/fonts/Font.h" | 32 #include "platform/fonts/Font.h" |
33 #include "platform/graphics/DashArray.h" | 33 #include "platform/graphics/DashArray.h" |
34 #include "platform/graphics/DrawLooperBuilder.h" | 34 #include "platform/graphics/DrawLooperBuilder.h" |
35 #include "platform/graphics/GraphicsContextState.h" | 35 #include "platform/graphics/GraphicsContextState.h" |
36 #include "platform/graphics/ImageOrientation.h" | 36 #include "platform/graphics/ImageOrientation.h" |
37 #include "platform/graphics/skia/SkiaUtils.h" | 37 #include "platform/graphics/skia/SkiaUtils.h" |
38 #include "third_party/skia/include/core/SkMetaData.h" | 38 #include "third_party/skia/include/core/SkMetaData.h" |
39 #include "third_party/skia/include/core/SkPictureRecorder.h" | 39 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 40 #include "third_party/skia/include/core/SkRefCnt.h" |
40 #include "third_party/skia/include/core/SkRegion.h" | 41 #include "third_party/skia/include/core/SkRegion.h" |
41 #include "wtf/Allocator.h" | 42 #include "wtf/Allocator.h" |
42 #include "wtf/Forward.h" | 43 #include "wtf/Forward.h" |
43 #include "wtf/Noncopyable.h" | 44 #include "wtf/Noncopyable.h" |
44 #include <memory> | 45 #include <memory> |
45 | 46 |
46 class SkBitmap; | 47 class SkBitmap; |
47 class SkImage; | 48 class SkImage; |
48 class SkPaint; | 49 class SkPaint; |
49 class SkPath; | 50 class SkPath; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 void strokeEllipse(const FloatRect&); | 145 void strokeEllipse(const FloatRect&); |
145 | 146 |
146 void fillRect(const FloatRect&); | 147 void fillRect(const FloatRect&); |
147 void fillRect(const FloatRect&, const Color&, SkXfermode::Mode = SkXfermode:
:kSrcOver_Mode); | 148 void fillRect(const FloatRect&, const Color&, SkXfermode::Mode = SkXfermode:
:kSrcOver_Mode); |
148 void fillRoundedRect(const FloatRoundedRect&, const Color&); | 149 void fillRoundedRect(const FloatRoundedRect&, const Color&); |
149 void fillDRRect(const FloatRoundedRect&, const FloatRoundedRect&, const Colo
r&); | 150 void fillDRRect(const FloatRoundedRect&, const FloatRoundedRect&, const Colo
r&); |
150 | 151 |
151 void strokeRect(const FloatRect&, float lineWidth); | 152 void strokeRect(const FloatRect&, float lineWidth); |
152 | 153 |
153 void drawPicture(const SkPicture*); | 154 void drawPicture(const SkPicture*); |
154 void compositePicture(PassRefPtr<SkPicture>, const FloatRect& dest, const Fl
oatRect& src, SkXfermode::Mode); | 155 void compositePicture(sk_sp<SkPicture>, const FloatRect& dest, const FloatRe
ct& src, SkXfermode::Mode); |
155 | 156 |
156 void drawImage(Image*, const FloatRect& destRect, const FloatRect* srcRect =
nullptr, | 157 void drawImage(Image*, const FloatRect& destRect, const FloatRect* srcRect =
nullptr, |
157 SkXfermode::Mode = SkXfermode::kSrcOver_Mode, RespectImageOrientationEnu
m = DoNotRespectImageOrientation); | 158 SkXfermode::Mode = SkXfermode::kSrcOver_Mode, RespectImageOrientationEnu
m = DoNotRespectImageOrientation); |
158 void drawImageRRect(Image*, const FloatRoundedRect& dest, const FloatRect& s
rcRect, | 159 void drawImageRRect(Image*, const FloatRoundedRect& dest, const FloatRect& s
rcRect, |
159 SkXfermode::Mode = SkXfermode::kSrcOver_Mode, RespectImageOrientationEnu
m = DoNotRespectImageOrientation); | 160 SkXfermode::Mode = SkXfermode::kSrcOver_Mode, RespectImageOrientationEnu
m = DoNotRespectImageOrientation); |
160 void drawTiledImage(Image*, const FloatRect& destRect, const FloatPoint& src
Point, const FloatSize& tileSize, | 161 void drawTiledImage(Image*, const FloatRect& destRect, const FloatPoint& src
Point, const FloatSize& tileSize, |
161 SkXfermode::Mode = SkXfermode::kSrcOver_Mode, const FloatSize& repeatSpa
cing = FloatSize()); | 162 SkXfermode::Mode = SkXfermode::kSrcOver_Mode, const FloatSize& repeatSpa
cing = FloatSize()); |
162 void drawTiledImage(Image*, const FloatRect& destRect, const FloatRect& srcR
ect, | 163 void drawTiledImage(Image*, const FloatRect& destRect, const FloatRect& srcR
ect, |
163 const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::Stretch
Tile, Image::TileRule vRule = Image::StretchTile, | 164 const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::Stretch
Tile, Image::TileRule vRule = Image::StretchTile, |
164 SkXfermode::Mode = SkXfermode::kSrcOver_Mode); | 165 SkXfermode::Mode = SkXfermode::kSrcOver_Mode); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 const FloatRect* = 0, ColorFilter = ColorFilterNone, sk_sp<SkImageFilter
> = nullptr); | 200 const FloatRect* = 0, ColorFilter = ColorFilterNone, sk_sp<SkImageFilter
> = nullptr); |
200 void endLayer(); | 201 void endLayer(); |
201 | 202 |
202 // Instead of being dispatched to the active canvas, draw commands following
beginRecording() | 203 // Instead of being dispatched to the active canvas, draw commands following
beginRecording() |
203 // are stored in a display list that can be replayed at a later time. Pass i
n the bounding | 204 // are stored in a display list that can be replayed at a later time. Pass i
n the bounding |
204 // rectangle for the content in the list. | 205 // rectangle for the content in the list. |
205 void beginRecording(const FloatRect&); | 206 void beginRecording(const FloatRect&); |
206 // Returns a picture with any recorded draw commands since the prerequisite
call to | 207 // Returns a picture with any recorded draw commands since the prerequisite
call to |
207 // beginRecording(). The picture is guaranteed to be non-null (but not nece
ssarily non-empty), | 208 // beginRecording(). The picture is guaranteed to be non-null (but not nece
ssarily non-empty), |
208 // even when the context is disabled. | 209 // even when the context is disabled. |
209 PassRefPtr<SkPicture> endRecording(); | 210 sk_sp<SkPicture> endRecording(); |
210 | 211 |
211 void setShadow(const FloatSize& offset, float blur, const Color&, | 212 void setShadow(const FloatSize& offset, float blur, const Color&, |
212 DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec
tsTransforms, | 213 DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespec
tsTransforms, |
213 DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl
pha, ShadowMode = DrawShadowAndForeground); | 214 DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAl
pha, ShadowMode = DrawShadowAndForeground); |
214 | 215 |
215 // It is assumed that this draw looper is used only for shadows | 216 // It is assumed that this draw looper is used only for shadows |
216 // (i.e. a draw looper is set if and only if there is a shadow). | 217 // (i.e. a draw looper is set if and only if there is a shadow). |
217 // The builder passed into this method will be destroyed. | 218 // The builder passed into this method will be destroyed. |
218 void setDrawLooper(std::unique_ptr<DrawLooperBuilder>); | 219 void setDrawLooper(std::unique_ptr<DrawLooperBuilder>); |
219 | 220 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 #if OS(MACOSX) | 269 #if OS(MACOSX) |
269 static int focusRingWidth(int width) { return width; } | 270 static int focusRingWidth(int width) { return width; } |
270 #else | 271 #else |
271 static int focusRingWidth(int width) { return 1; } | 272 static int focusRingWidth(int width) { return 1; } |
272 #endif | 273 #endif |
273 | 274 |
274 #if DCHECK_IS_ON() | 275 #if DCHECK_IS_ON() |
275 void setInDrawingRecorder(bool); | 276 void setInDrawingRecorder(bool); |
276 #endif | 277 #endif |
277 | 278 |
278 static PassRefPtr<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFi
lter); | 279 static sk_sp<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFilter)
; |
279 | 280 |
280 private: | 281 private: |
281 const GraphicsContextState* immutableState() const { return m_paintState; } | 282 const GraphicsContextState* immutableState() const { return m_paintState; } |
282 | 283 |
283 GraphicsContextState* mutableState() | 284 GraphicsContextState* mutableState() |
284 { | 285 { |
285 realizePaintSave(); | 286 realizePaintSave(); |
286 return m_paintState; | 287 return m_paintState; |
287 } | 288 } |
288 | 289 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 364 |
364 float m_deviceScaleFactor; | 365 float m_deviceScaleFactor; |
365 | 366 |
366 unsigned m_printing : 1; | 367 unsigned m_printing : 1; |
367 unsigned m_hasMetaData : 1; | 368 unsigned m_hasMetaData : 1; |
368 }; | 369 }; |
369 | 370 |
370 } // namespace blink | 371 } // namespace blink |
371 | 372 |
372 #endif // GraphicsContext_h | 373 #endif // GraphicsContext_h |
OLD | NEW |