| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
| 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "core/svg/graphics/SVGImageChromeClient.h" | 50 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 51 #include "platform/EventDispatchForbiddenScope.h" | 51 #include "platform/EventDispatchForbiddenScope.h" |
| 52 #include "platform/LengthFunctions.h" | 52 #include "platform/LengthFunctions.h" |
| 53 #include "platform/TraceEvent.h" | 53 #include "platform/TraceEvent.h" |
| 54 #include "platform/geometry/IntRect.h" | 54 #include "platform/geometry/IntRect.h" |
| 55 #include "platform/graphics/GraphicsContext.h" | 55 #include "platform/graphics/GraphicsContext.h" |
| 56 #include "platform/graphics/ImageBuffer.h" | 56 #include "platform/graphics/ImageBuffer.h" |
| 57 #include "platform/graphics/ImageObserver.h" | 57 #include "platform/graphics/ImageObserver.h" |
| 58 #include "platform/graphics/paint/ClipRecorder.h" | 58 #include "platform/graphics/paint/ClipRecorder.h" |
| 59 #include "platform/graphics/paint/DisplayItemListContextRecorder.h" | 59 #include "platform/graphics/paint/DisplayItemListContextRecorder.h" |
| 60 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 60 #include "third_party/skia/include/core/SkPicture.h" | 61 #include "third_party/skia/include/core/SkPicture.h" |
| 61 #include "wtf/PassRefPtr.h" | 62 #include "wtf/PassRefPtr.h" |
| 62 | 63 |
| 63 namespace blink { | 64 namespace blink { |
| 64 | 65 |
| 65 SVGImage::SVGImage(ImageObserver* observer) | 66 SVGImage::SVGImage(ImageObserver* observer) |
| 66 : Image(observer) | 67 : Image(observer) |
| 67 { | 68 { |
| 68 } | 69 } |
| 69 | 70 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 const IntSize& repeatSpacing) | 237 const IntSize& repeatSpacing) |
| 237 { | 238 { |
| 238 // Tile adjusted for scaling/stretch. | 239 // Tile adjusted for scaling/stretch. |
| 239 FloatRect tile(srcRect); | 240 FloatRect tile(srcRect); |
| 240 tile.scale(tileScale.width(), tileScale.height()); | 241 tile.scale(tileScale.width(), tileScale.height()); |
| 241 | 242 |
| 242 // Expand the tile to account for repeat spacing. | 243 // Expand the tile to account for repeat spacing. |
| 243 FloatRect spacedTile(tile); | 244 FloatRect spacedTile(tile); |
| 244 spacedTile.expand(repeatSpacing); | 245 spacedTile.expand(repeatSpacing); |
| 245 | 246 |
| 246 OwnPtr<DisplayItemList> displayItemList; | 247 SkPictureBuilder pictureBuilder(spacedTile); |
| 247 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | |
| 248 displayItemList = DisplayItemList::create(); | |
| 249 | |
| 250 // Record using a dedicated GC, to avoid inheriting unwanted state (pending
color filters | |
| 251 // for example must be applied atomically during the final fill/composite ph
ase). | |
| 252 GraphicsContext recordingContext(displayItemList.get()); | |
| 253 recordingContext.beginRecording(spacedTile); | |
| 254 { | 248 { |
| 255 // When generating an expanded tile, make sure we don't draw into the sp
acing area. | 249 // When generating an expanded tile, make sure we don't draw into the sp
acing area. |
| 256 OwnPtr<FloatClipRecorder> clipRecorder; | 250 OwnPtr<FloatClipRecorder> clipRecorder; |
| 257 if (tile != spacedTile) | 251 if (tile != spacedTile) |
| 258 clipRecorder = adoptPtr(new FloatClipRecorder(recordingContext, *thi
s, PaintPhaseForeground, tile)); | 252 clipRecorder = adoptPtr(new FloatClipRecorder(pictureBuilder.context
(), *this, PaintPhaseForeground, tile)); |
| 259 drawForContainer(&recordingContext, containerSize, zoom, tile, srcRect,
SkXfermode::kSrcOver_Mode); | 253 drawForContainer(&pictureBuilder.context(), containerSize, zoom, tile, s
rcRect, SkXfermode::kSrcOver_Mode); |
| 260 } | 254 } |
| 261 | 255 |
| 262 if (displayItemList) | 256 RefPtr<const SkPicture> tilePicture = pictureBuilder.endRecording(); |
| 263 displayItemList->commitNewDisplayItemsAndReplay(recordingContext); | |
| 264 | |
| 265 RefPtr<const SkPicture> tilePicture = recordingContext.endRecording(); | |
| 266 | 257 |
| 267 SkMatrix patternTransform; | 258 SkMatrix patternTransform; |
| 268 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); | 259 patternTransform.setTranslate(phase.x() + spacedTile.x(), phase.y() + spaced
Tile.y()); |
| 269 RefPtr<SkShader> patternShader = adoptRef(SkShader::CreatePictureShader( | 260 RefPtr<SkShader> patternShader = adoptRef(SkShader::CreatePictureShader( |
| 270 tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMod
e, | 261 tilePicture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMod
e, |
| 271 &patternTransform, nullptr)); | 262 &patternTransform, nullptr)); |
| 272 | 263 |
| 273 SkPaint paint; | 264 SkPaint paint; |
| 274 paint.setShader(patternShader.get()); | 265 paint.setShader(patternShader.get()); |
| 275 paint.setXfermodeMode(compositeOp); | 266 paint.setXfermodeMode(compositeOp); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 457 |
| 467 return m_page; | 458 return m_page; |
| 468 } | 459 } |
| 469 | 460 |
| 470 String SVGImage::filenameExtension() const | 461 String SVGImage::filenameExtension() const |
| 471 { | 462 { |
| 472 return "svg"; | 463 return "svg"; |
| 473 } | 464 } |
| 474 | 465 |
| 475 } | 466 } |
| OLD | NEW |