Changeset 79882 in webkit
- Timestamp:
- Feb 28, 2011 10:30:18 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r79880 r79882 1 2011-02-28 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r79877. 4 http://trac.webkit.org/changeset/79877 5 https://bugs.webkit.org/show_bug.cgi?id=55388 6 7 Breaks chromium build (Requested by antonm_ on #webkit). 8 9 * WebCore.gypi: 10 * platform/graphics/chromium/ContentLayerChromium.cpp: 11 (WebCore::ContentLayerChromium::updateContentsIfDirty): 12 (WebCore::ContentLayerChromium::resizeUploadBufferForImage): 13 (WebCore::ContentLayerChromium::resizeUploadBuffer): 14 (WebCore::SkBitmapConditionalAutoLockerPixels::SkBitmapConditionalAutoLockerPixels): 15 (WebCore::SkBitmapConditionalAutoLockerPixels::~SkBitmapConditionalAutoLockerPixels): 16 (WebCore::SkBitmapConditionalAutoLockerPixels::lockPixels): 17 (WebCore::ContentLayerChromium::updateTextureIfNeeded): 18 (WebCore::ContentLayerChromium::draw): 19 * platform/graphics/chromium/ContentLayerChromium.h: 20 * platform/graphics/chromium/ImageLayerChromium.cpp: 21 (WebCore::ImageLayerChromium::updateContentsIfDirty): 22 * platform/graphics/chromium/ImageLayerChromium.h: 23 * platform/graphics/chromium/LayerTilerChromium.cpp: 24 (WebCore::LayerTilerChromium::contentRectToTileIndices): 25 (WebCore::LayerTilerChromium::update): 26 * platform/graphics/chromium/LayerTilerChromium.h: 27 * platform/graphics/chromium/PlatformCanvas.cpp: Removed. 28 * platform/graphics/chromium/PlatformCanvas.h: Removed. 29 * platform/graphics/chromium/PlatformImage.cpp: Removed. 30 * platform/graphics/chromium/PlatformImage.h: Removed. 31 1 32 2011-02-28 Pavel Podivilov <podivilov@chromium.org> 2 33 -
trunk/Source/WebCore/WebCore.gypi
r79877 r79882 2623 2623 'platform/graphics/chromium/MediaPlayerPrivateChromium.h', 2624 2624 'platform/graphics/chromium/PlatformIcon.h', 2625 'platform/graphics/chromium/PlatformCanvas.cpp',2626 'platform/graphics/chromium/PlatformCanvas.h',2627 'platform/graphics/chromium/PlatformImage.cpp',2628 'platform/graphics/chromium/PlatformImage.h',2629 2625 'platform/graphics/chromium/PluginLayerChromium.cpp', 2630 2626 'platform/graphics/chromium/PluginLayerChromium.h', -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r79877 r79882 41 41 #include "RenderLayerBacking.h" 42 42 43 #if USE(SKIA) 44 #include "NativeImageSkia.h" 45 #include "PlatformContextSkia.h" 46 #include "SkColorPriv.h" 47 #include "skia/ext/platform_canvas.h" 48 #elif PLATFORM(CG) 49 #include <CoreGraphics/CGBitmapContext.h> 50 #endif 51 43 52 namespace WebCore { 44 53 … … 128 137 129 138 // If we need to resize the upload buffer we have to repaint everything. 130 if (m_ canvas.size()!= visibleRectInLayerCoords.size()) {139 if (m_uploadBufferSize != visibleRectInLayerCoords.size()) { 131 140 resizeUploadBuffer(visibleRectInLayerCoords.size()); 132 141 m_dirtyRect = boundsRect; … … 153 162 // If the texture needs to be reallocated then we must redraw the entire 154 163 // contents of the layer. 155 if (m_ canvas.size()!= bounds()) {164 if (m_uploadBufferSize != bounds()) { 156 165 resizeUploadBuffer(bounds()); 157 166 dirtyRect = boundsRect; … … 167 176 return; 168 177 169 PlatformCanvas::Painter painter(&m_canvas); 170 painter.context()->save(); 171 painter.context()->translate(-paintingOffset.x(), -paintingOffset.y()); 172 painter.context()->clearRect(dirtyRect); 173 painter.context()->clip(dirtyRect); 174 175 m_owner->paintGraphicsLayerContents(*painter.context(), dirtyRect); 176 painter.context()->restore(); 177 } 178 178 #if USE(SKIA) 179 OwnPtr<PlatformContextSkia> skiaContext; 180 181 skiaContext.set(new PlatformContextSkia(m_uploadPixelCanvas.get())); 182 183 // This is needed to get text to show up correctly. 184 skiaContext->setDrawingToImageBuffer(true); 185 186 GraphicsContext graphicsContext(reinterpret_cast<PlatformGraphicsContext*>(skiaContext.get())); 187 188 #elif PLATFORM(CG) 189 // FIXME: Do we need to clear the dirty rectangle in the upload buffer? 190 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); 191 size_t rowBytes = m_uploadBufferSize.width() * 4; 192 RetainPtr<CGContextRef> contextCG(AdoptCF, CGBitmapContextCreate(m_uploadPixelData->data(), 193 m_uploadBufferSize.width(), m_uploadBufferSize.height(), 8, rowBytes, 194 colorSpace.get(), 195 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); 196 CGContextTranslateCTM(contextCG.get(), 0, m_uploadBufferSize.height()); 197 CGContextScaleCTM(contextCG.get(), 1, -1); 198 199 GraphicsContext graphicsContext(contextCG.get()); 200 #else 201 #error "Need to implement for your platform." 202 #endif 203 204 graphicsContext.save(); 205 graphicsContext.translate(-paintingOffset.x(), -paintingOffset.y()); 206 graphicsContext.clearRect(dirtyRect); 207 graphicsContext.clip(dirtyRect); 208 209 m_owner->paintGraphicsLayerContents(graphicsContext, dirtyRect); 210 graphicsContext.restore(); 211 } 212 213 void ContentLayerChromium::resizeUploadBufferForImage(const IntSize& size) 214 { 215 size_t bufferSize = size.width() * size.height() * 4; 216 m_uploadPixelData = new Vector<uint8_t>(bufferSize); 217 #if PLATFORM(CG) 218 memset(m_uploadPixelData->data(), 0, bufferSize); 219 #endif 220 m_uploadBufferSize = size; 221 } 179 222 void ContentLayerChromium::resizeUploadBuffer(const IntSize& size) 180 223 { 181 m_canvas.resize(size); 182 } 224 #if USE(SKIA) 225 m_uploadPixelCanvas = new skia::PlatformCanvas(size.width(), size.height(), false); 226 m_uploadBufferSize = size; 227 #else 228 resizeUploadBufferForImage(size); 229 #endif 230 } 231 232 #if USE(SKIA) 233 class SkBitmapConditionalAutoLockerPixels { 234 WTF_MAKE_NONCOPYABLE(SkBitmapConditionalAutoLockerPixels); 235 public: 236 SkBitmapConditionalAutoLockerPixels() 237 : m_bitmap(0) 238 { 239 } 240 241 ~SkBitmapConditionalAutoLockerPixels() 242 { 243 if (m_bitmap) 244 m_bitmap->unlockPixels(); 245 } 246 247 void lockPixels(const SkBitmap* bitmap) 248 { 249 bitmap->lockPixels(); 250 m_bitmap = bitmap; 251 } 252 253 private: 254 const SkBitmap* m_bitmap; 255 }; 256 #endif 183 257 184 258 void ContentLayerChromium::updateTextureIfNeeded() 185 259 { 186 PlatformCanvas::AutoLocker locker(&m_canvas); 187 updateTexture(locker.pixels(), m_canvas.size()); 188 } 189 190 void ContentLayerChromium::updateTexture(const uint8_t* pixels, const IntSize& size) 191 { 260 uint8_t* pixels = 0; 261 #if USE(SKIA) 262 SkBitmapConditionalAutoLockerPixels locker; 263 #endif 264 if (!m_uploadUpdateRect.isEmpty()) { 265 #if USE(SKIA) 266 if (m_uploadPixelCanvas) { 267 const SkBitmap& bitmap = m_uploadPixelCanvas->getDevice()->accessBitmap(false); 268 locker.lockPixels(&bitmap); 269 // FIXME: do we need to support more image configurations? 270 if (bitmap.config() == SkBitmap::kARGB_8888_Config) 271 pixels = static_cast<uint8_t*>(bitmap.getPixels()); 272 } 273 #endif 274 if (m_uploadPixelData) 275 pixels = m_uploadPixelData->data(); 276 } 277 192 278 if (!pixels) 193 279 return; … … 198 284 199 285 // If we have to allocate a new texture we have to upload the full contents. 200 if (!m_contentsTexture->isValid( size, GraphicsContext3D::RGBA))201 m_uploadUpdateRect = IntRect(IntPoint(0, 0), size);202 203 if (!m_contentsTexture->reserve( size, GraphicsContext3D::RGBA)) {286 if (!m_contentsTexture->isValid(m_uploadBufferSize, GraphicsContext3D::RGBA)) 287 m_uploadUpdateRect = IntRect(IntPoint(0, 0), m_uploadBufferSize); 288 289 if (!m_contentsTexture->reserve(m_uploadBufferSize, GraphicsContext3D::RGBA)) { 204 290 m_skipsDraw = true; 205 291 return; 206 292 } 207 293 208 IntRect srcRect = IntRect(IntPoint(0, 0), size);294 IntRect srcRect = IntRect(IntPoint(0, 0), m_uploadBufferSize); 209 295 if (requiresClippedUpdateRect()) 210 296 srcRect = m_visibleRectInLayerCoords; 211 297 212 const size_t destStride = size.width() * 4;298 const size_t destStride = m_uploadUpdateRect.width() * 4; 213 299 const size_t srcStride = srcRect.width() * 4; 214 300 215 constuint8_t* uploadPixels = pixels + srcStride * m_uploadUpdateRect.x();301 uint8_t* uploadPixels = pixels + srcStride * m_uploadUpdateRect.x(); 216 302 Vector<uint8_t> uploadBuffer; 217 303 if (srcStride != destStride) { … … 219 305 for (int row = 0; row < m_uploadUpdateRect.height(); ++row) { 220 306 size_t srcOffset = (m_uploadUpdateRect.y() + row) * srcStride + m_uploadUpdateRect.x() * 4; 221 ASSERT(srcOffset + destStride <= static_cast<size_t>( size.width() * size.height() * 4));307 ASSERT(srcOffset + destStride <= static_cast<size_t>(m_uploadBufferSize.width() * m_uploadBufferSize.height() * 4)); 222 308 size_t destOffset = row * destStride; 223 309 ASSERT(destOffset + destStride <= uploadBuffer.size()); … … 241 327 void ContentLayerChromium::draw() 242 328 { 329 updateTextureIfNeeded(); 330 243 331 if (m_skipsDraw) 244 332 return; -
trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
r79877 r79882 36 36 37 37 #include "LayerChromium.h" 38 #include "PlatformCanvas.h"39 38 #include "TextureManager.h" 40 39 … … 66 65 bool requiresClippedUpdateRect() const; 67 66 void resizeUploadBuffer(const IntSize&); 67 void resizeUploadBufferForImage(const IntSize&); 68 68 69 69 OwnPtr<LayerTexture> m_contentsTexture; 70 70 bool m_skipsDraw; 71 71 72 // The size of the upload buffer (also the size of our backing texture). 73 IntSize m_uploadBufferSize; 72 74 // The portion of the upload buffer that has a pending update, in the coordinates of the texture. 73 75 IntRect m_uploadUpdateRect; 74 75 virtual void updateTextureIfNeeded(); 76 void updateTexture(const uint8_t* pixels, const IntSize&); 76 // On platforms using Skia, we use the skia::PlatformCanvas for content layers 77 // and the m_uploadPixelData buffer for image layers. 78 // FIXME: We should be using memory we control for all uploads. 79 #if USE(SKIA) 80 OwnPtr<skia::PlatformCanvas> m_uploadPixelCanvas; 81 #endif 82 OwnPtr<Vector<uint8_t> > m_uploadPixelData; 77 83 78 84 private: 79 PlatformCanvas m_canvas;85 void updateTextureIfNeeded(); 80 86 81 87 IntRect m_visibleRectInLayerCoords; -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
r79877 r79882 39 39 #include "LayerTexture.h" 40 40 41 #if USE(SKIA) 42 #include "NativeImageSkia.h" 43 #include "PlatformContextSkia.h" 44 #endif 45 46 #if PLATFORM(CG) 47 #include <CoreGraphics/CGBitmapContext.h> 48 #include <CoreGraphics/CGContext.h> 49 #include <CoreGraphics/CGImage.h> 50 #include <wtf/RetainPtr.h> 51 #endif 52 41 53 namespace WebCore { 42 54 … … 73 85 } 74 86 75 m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame()); 76 } 87 NativeImagePtr nativeImage = m_contents->nativeImageForCurrentFrame(); 77 88 78 void ImageLayerChromium::updateTextureIfNeeded() 79 { 80 updateTexture(m_decodedImage.pixels(), m_decodedImage.size()); 89 #if USE(SKIA) 90 // The layer contains an Image. 91 NativeImageSkia* skiaImage = static_cast<NativeImageSkia*>(nativeImage); 92 const SkBitmap* skiaBitmap = skiaImage; 93 IntSize bitmapSize(skiaBitmap->width(), skiaBitmap->height()); 94 ASSERT(skiaBitmap); 95 #elif PLATFORM(CG) 96 // NativeImagePtr is a CGImageRef on Mac OS X. 97 int width = CGImageGetWidth(nativeImage); 98 int height = CGImageGetHeight(nativeImage); 99 IntSize bitmapSize(width, height); 100 #endif 101 102 if (m_uploadBufferSize != bitmapSize) 103 resizeUploadBufferForImage(bitmapSize); 104 m_uploadUpdateRect = IntRect(IntPoint(0, 0), bitmapSize); 105 106 #if USE(SKIA) 107 SkAutoLockPixels lock(*skiaBitmap); 108 // FIXME: do we need to support more image configurations? 109 ASSERT(skiaBitmap->config()== SkBitmap::kARGB_8888_Config); 110 skiaBitmap->copyPixelsTo(m_uploadPixelData->data(), m_uploadPixelData->size()); 111 #elif PLATFORM(CG) 112 // FIXME: we should get rid of this temporary copy where possible. 113 int tempRowBytes = width * 4; 114 // Note we do not zero this vector since we are going to 115 // completely overwrite its contents with the image below. 116 // Try to reuse the color space from the image to preserve its colors. 117 // Some images use a color space (such as indexed) unsupported by the bitmap context. 118 RetainPtr<CGColorSpaceRef> colorSpaceReleaser; 119 CGColorSpaceRef colorSpace = CGImageGetColorSpace(nativeImage); 120 CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); 121 switch (colorSpaceModel) { 122 case kCGColorSpaceModelMonochrome: 123 case kCGColorSpaceModelRGB: 124 case kCGColorSpaceModelCMYK: 125 case kCGColorSpaceModelLab: 126 case kCGColorSpaceModelDeviceN: 127 break; 128 default: 129 colorSpaceReleaser.adoptCF(CGColorSpaceCreateDeviceRGB()); 130 colorSpace = colorSpaceReleaser.get(); 131 break; 132 } 133 RetainPtr<CGContextRef> tempContext(AdoptCF, CGBitmapContextCreate(m_uploadPixelData->data(), 134 width, height, 8, tempRowBytes, 135 colorSpace, 136 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); 137 CGContextSetBlendMode(tempContext.get(), kCGBlendModeCopy); 138 CGContextDrawImage(tempContext.get(), 139 CGRectMake(0, 0, static_cast<CGFloat>(width), static_cast<CGFloat>(height)), 140 nativeImage); 141 #else 142 #error "Need to implement for your platform." 143 #endif 81 144 } 82 145 -
trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
r79877 r79882 36 36 37 37 #include "ContentLayerChromium.h" 38 #include "PlatformImage.h"39 38 40 39 #if PLATFORM(CG) … … 57 56 58 57 private: 59 virtual void updateTextureIfNeeded();60 61 58 ImageLayerChromium(GraphicsLayerChromium* owner); 62 59 63 PlatformImage m_decodedImage;64 60 RefPtr<Image> m_contents; 65 61 }; -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp
r79877 r79882 36 36 #include "LayerTexture.h" 37 37 38 #if USE(SKIA) 39 #include "NativeImageSkia.h" 40 #include "PlatformContextSkia.h" 41 #elif PLATFORM(CG) 42 #include <CoreGraphics/CGBitmapContext.h> 43 #endif 44 38 45 #include <wtf/PassOwnArrayPtr.h> 39 46 … … 142 149 left = m_tilingData.tileXIndexFromSrcCoord(layerRect.x()); 143 150 top = m_tilingData.tileYIndexFromSrcCoord(layerRect.y()); 144 right = m_tilingData.tileXIndexFromSrcCoord(layerRect.maxX() - 1);145 bottom = m_tilingData.tileYIndexFromSrcCoord(layerRect.maxY() - 1);151 right = m_tilingData.tileXIndexFromSrcCoord(layerRect.maxX()); 152 bottom = m_tilingData.tileYIndexFromSrcCoord(layerRect.maxY()); 146 153 } 147 154 … … 264 271 265 272 const IntRect paintRect = layerRectToContentRect(dirtyLayerRect); 266 267 m_canvas.resize(paintRect.size()); 268 PlatformCanvas::Painter canvasPainter(&m_canvas); 269 canvasPainter.context()->translate(-paintRect.x(), -paintRect.y()); 270 painter.paint(*canvasPainter.context(), paintRect); 271 272 PlatformCanvas::AutoLocker locker(&m_canvas); 273 updateFromPixels(paintRect, locker.pixels()); 274 } 275 276 void LayerTilerChromium::updateFromPixels(const IntRect& paintRect, const uint8_t* paintPixels) 277 { 273 GraphicsContext3D* context = layerRendererContext(); 274 #if USE(SKIA) 275 OwnPtr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas(paintRect.width(), paintRect.height(), false)); 276 OwnPtr<PlatformContextSkia> skiaContext(new PlatformContextSkia(canvas.get())); 277 OwnPtr<GraphicsContext> graphicsContext(new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(skiaContext.get()))); 278 279 // Bring the canvas into the coordinate system of the paint rect. 280 canvas->translate(static_cast<SkScalar>(-paintRect.x()), static_cast<SkScalar>(-paintRect.y())); 281 282 painter.paint(*graphicsContext, paintRect); 283 284 // Get the contents of the updated rect. 285 const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(false); 286 ASSERT(bitmap.width() == paintRect.width() && bitmap.height() == paintRect.height()); 287 if (bitmap.width() != paintRect.width() || bitmap.height() != paintRect.height()) 288 CRASH(); 289 uint8_t* paintPixels = static_cast<uint8_t*>(bitmap.getPixels()); 290 if (!paintPixels) 291 CRASH(); 292 #elif PLATFORM(CG) 293 Vector<uint8_t> canvasPixels; 294 int rowBytes = 4 * paintRect.width(); 295 canvasPixels.resize(rowBytes * paintRect.height()); 296 memset(canvasPixels.data(), 0, canvasPixels.size()); 297 RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); 298 RetainPtr<CGContextRef> m_cgContext; 299 m_cgContext.adoptCF(CGBitmapContextCreate(canvasPixels.data(), 300 paintRect.width(), paintRect.height(), 8, rowBytes, 301 colorSpace.get(), 302 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); 303 CGContextTranslateCTM(m_cgContext.get(), 0, paintRect.height()); 304 CGContextScaleCTM(m_cgContext.get(), 1, -1); 305 OwnPtr<GraphicsContext> m_graphicsContext(new GraphicsContext(m_cgContext.get())); 306 307 // Bring the CoreGraphics context into the coordinate system of the paint rect. 308 CGContextTranslateCTM(m_cgContext.get(), -paintRect.x(), -paintRect.y()); 309 painter.paint(*m_graphicsContext, paintRect); 310 311 // Get the contents of the updated rect. 312 ASSERT(static_cast<int>(CGBitmapContextGetWidth(m_cgContext.get())) == paintRect.width() && static_cast<int>(CGBitmapContextGetHeight(m_cgContext.get())) == paintRect.height()); 313 uint8_t* paintPixels = static_cast<uint8_t*>(canvasPixels.data()); 314 #else 315 #error "Need to implement for your platform." 316 #endif 317 278 318 // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. 279 319 if (!m_tiles.size()) 280 320 return; 281 321 282 GraphicsContext3D* context = layerRendererContext();283 284 int left, top, right, bottom;285 contentRectToTileIndices(paintRect, left, top, right, bottom);286 322 for (int j = top; j <= bottom; ++j) { 287 323 for (int i = left; i <= right; ++i) { … … 323 359 CRASH(); 324 360 325 constuint8_t* pixelSource;361 uint8_t* pixelSource; 326 362 if (paintRect.width() == sourceRect.width() && !paintOffset.x()) 327 363 pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()]; -
trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h
r79877 r79882 32 32 #include "LayerChromium.h" 33 33 #include "LayerTexture.h" 34 #include "PlatformCanvas.h"35 34 #include "TilingData.h" 36 35 #include <wtf/OwnArrayPtr.h> … … 58 57 void invalidateEntireLayer(); 59 58 void update(TilePaintInterface& painter, const IntRect& contentRect); 60 void updateFromPixels(const IntRect& paintRect, const uint8_t* pixels);61 59 void draw(const IntRect& contentRect); 62 60 … … 128 126 Vector<OwnPtr<Tile> > m_unusedTiles; 129 127 130 PlatformCanvas m_canvas;131 132 128 // Cache a tile-sized pixel buffer to draw into. 133 129 OwnArrayPtr<uint8_t> m_tilePixels;
Note: See TracChangeset
for help on using the changeset viewer.