Changeset 83649 in webkit
- Timestamp:
- Apr 12, 2011 3:27:04 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83645 r83649 1 2011-04-12 Alok Priyadarshi <alokp@chromium.org> 2 3 Reviewed by James Robinson. 4 5 Remove dependency on chromium skia::PlatformCanvas 6 https://bugs.webkit.org/show_bug.cgi?id=57563 7 8 This patch does not change any functionality, just the type of object skia::PlatformCanvas -> SkCanvas. 9 The object is still being created by a factory method skia::CreateBitmapCanvas defined in Chromium. 10 We will eventually define an API that every port using skia will define. 11 12 * platform/graphics/chromium/FontChromiumWin.cpp: 13 (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::initializeForGDI): 14 (WebCore::TransparencyAwareFontPainter::TransparencyAwareFontPainter::~TransparencyAwareFontPainter): 15 (WebCore::Font::drawComplexText): 16 * platform/graphics/chromium/ImageBufferData.h: 17 * platform/graphics/chromium/LayerChromium.h: 18 * platform/graphics/chromium/LayerRendererChromium.h: 19 * platform/graphics/chromium/PlatformCanvas.cpp: 20 (WebCore::PlatformCanvas::resize): 21 * platform/graphics/chromium/PlatformCanvas.h: 22 * platform/graphics/chromium/TransparencyWin.cpp: 23 (WebCore::TransparencyWin::compositeTextComposite): 24 (WebCore::TransparencyWin::makeLayerOpaque): 25 * platform/graphics/skia/ImageBufferSkia.cpp: 26 (WebCore::ImageBuffer::ImageBuffer): 27 * platform/graphics/skia/ImageSkia.cpp: 28 (WebCore::paintSkBitmap): 29 (WebCore::Image::drawPattern): 30 * platform/graphics/skia/PlatformContextSkia.cpp: 31 (WebCore::PlatformContextSkia::PlatformContextSkia): 32 (WebCore::PlatformContextSkia::setCanvas): 33 (WebCore::PlatformContextSkia::isNativeFontRenderingAllowed): 34 * platform/graphics/skia/PlatformContextSkia.h: 35 (WebCore::PlatformContextSkia::canvas): 36 (WebCore::PlatformContextSkia::printing): 37 (WebCore::PlatformContextSkia::setPrinting): 38 1 39 2011-04-11 Stephanie Lewis <slewis@apple.com> 2 40 -
trunk/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
r83541 r83649 166 166 // Set up the DC, using the one from the transparency helper. 167 167 if (m_transparency.platformContext()) { 168 m_hdc = m_transparency.platformContext()->canvas()->beginPlatformPaint();168 m_hdc = skia::BeginPlatformPaint(m_transparency.platformContext()->canvas()); 169 169 SetTextColor(m_hdc, skia::SkColorToCOLORREF(color)); 170 170 SetBkMode(m_hdc, TRANSPARENT); … … 180 180 m_graphicsContext->endTransparencyLayer(); 181 181 m_graphicsContext->restore(); 182 m_platformContext->canvas()->endPlatformPaint();182 skia::EndPlatformPaint(m_platformContext->canvas()); 183 183 } 184 184 … … 543 543 state.draw(graphicsContext, hdc, lroundf(point.x()), lroundf(point.y() - fontMetrics().ascent()), from, to); 544 544 545 context->canvas()->endPlatformPaint();545 skia::EndPlatformPaint(context->canvas()); 546 546 } 547 547 -
trunk/Source/WebCore/platform/graphics/chromium/ImageBufferData.h
r39899 r83649 34 34 #include "PlatformContextSkia.h" 35 35 36 #include "skia/ext/platform_canvas.h"37 38 36 namespace WebCore { 39 37 … … 42 40 ImageBufferData(const IntSize&); 43 41 44 skia::PlatformCanvasm_canvas;42 OwnPtr<SkCanvas> m_canvas; 45 43 PlatformContextSkia m_platformContext; 46 44 }; -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r83511 r83649 51 51 #include <wtf/text/WTFString.h> 52 52 53 54 namespace skia {55 class PlatformCanvas;56 }57 58 53 namespace WebCore { 59 54 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r83552 r83649 195 195 196 196 #if USE(SKIA) 197 OwnPtr< skia::PlatformCanvas> m_rootLayerCanvas;197 OwnPtr<SkCanvas> m_rootLayerCanvas; 198 198 OwnPtr<PlatformContextSkia> m_rootLayerSkiaContext; 199 199 OwnPtr<GraphicsContext> m_rootLayerGraphicsContext; -
trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp
r83511 r83649 53 53 m_size = size; 54 54 #if USE(SKIA) 55 m_skiaCanvas = new skia::PlatformCanvas(size.width(), size.height(), false);55 m_skiaCanvas = skia::CreateBitmapCanvas(size.width(), size.height(), false); 56 56 #elif PLATFORM(CG) 57 57 size_t bufferSize = size.width() * size.height() * 4; -
trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h
r83511 r83649 40 40 41 41 #if USE(SKIA) 42 namespace skia { class PlatformCanvas; }43 42 class SkBitmap; 43 class SkCanvas; 44 44 #endif 45 45 … … 98 98 private: 99 99 #if USE(SKIA) 100 OwnPtr< skia::PlatformCanvas> m_skiaCanvas;100 OwnPtr<SkCanvas> m_skiaCanvas; 101 101 #elif PLATFORM(CG) 102 102 OwnArrayPtr<uint8_t> m_pixelData; -
trunk/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp
r77402 r83649 50 50 const int maxCachedBufferPixelSize = 65536; 51 51 52 inline skia::PlatformCanvas* canvasForContext(const GraphicsContext& context)52 inline SkCanvas* canvasForContext(const GraphicsContext& context) 53 53 { 54 54 return context.platformContext()->canvas(); … … 57 57 inline const SkBitmap& bitmapForContext(const GraphicsContext& context) 58 58 { 59 return canvasForContext(context)->getTop PlatformDevice().accessBitmap(false);59 return canvasForContext(context)->getTopDevice()->accessBitmap(false); 60 60 } 61 61 … … 467 467 return; 468 468 469 const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->canvas()->getTop PlatformDevice().accessBitmap(true);469 const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->canvas()->getTopDevice()->accessBitmap(true); 470 470 SkColor textColor = m_textCompositeColor.rgb(); 471 471 for (int y = 0; y < m_layerSize.height(); y++) { … … 503 503 504 504 SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()-> 505 canvas()->getTop PlatformDevice().accessBitmap(true));505 canvas()->getTopDevice()->accessBitmap(true)); 506 506 for (int y = 0; y < m_layerSize.height(); y++) { 507 507 uint32_t* row = bitmap.getAddr32(0, y); -
trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
r83582 r83649 67 67 , m_size(size) 68 68 { 69 if (!m_data.m_canvas.initialize(size.width(), size.height(), false)) { 69 SkCanvas* canvas = skia::CreateBitmapCanvas(size.width(), size.height(), false); 70 if (!canvas) { 70 71 success = false; 71 72 return; 72 73 } 73 74 74 m_data.m_platformContext.setCanvas(&m_data.m_canvas); 75 m_data.m_canvas = canvas; 76 m_data.m_platformContext.setCanvas(m_data.m_canvas.get()); 75 77 m_context.set(new GraphicsContext(&m_data.m_platformContext)); 76 78 m_context->platformContext()->setDrawingToImageBuffer(true); … … 79 81 // required, but the canvas is currently filled with the magic transparency 80 82 // color. Can we have another way to manage this? 81 m_data.m_canvas .drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);83 m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); 82 84 success = true; 83 85 } -
trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp
r81489 r83649 263 263 paint.setLooper(platformContext->getDrawLooper()); 264 264 265 skia::PlatformCanvas* canvas = platformContext->canvas(); 266 267 ResamplingMode resampling = platformContext->isPrinting() ? RESAMPLE_NONE : 265 SkCanvas* canvas = platformContext->canvas(); 266 267 ResamplingMode resampling; 268 #if ENABLE(SKIA_GPU) 269 resampling = RESAMPLE_LINEAR; 270 #else 271 resampling = platformContext->printing() ? RESAMPLE_NONE : 268 272 computeResamplingMode(platformContext, bitmap, srcRect.width(), srcRect.height(), 269 273 SkScalarToFloat(destRect.width()), 270 274 SkScalarToFloat(destRect.height())); 275 #endif 271 276 if (resampling == RESAMPLE_AWESOME) { 272 277 drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect); … … 364 369 // Compute the resampling mode. 365 370 ResamplingMode resampling; 366 if (context->platformContext()->isPrinting()) 371 #if ENABLE(SKIA_GPU) 372 resampling = RESAMPLE_LINEAR; 373 #else 374 if (context->platformContext()->printing()) 367 375 resampling = RESAMPLE_LINEAR; 368 376 else { … … 371 379 destBitmapWidth, destBitmapHeight); 372 380 } 381 #endif 373 382 374 383 // Load the transform WebKit requested. -
trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
r82751 r83649 214 214 215 215 // Danger: canvas can be NULL. 216 PlatformContextSkia::PlatformContextSkia( skia::PlatformCanvas* canvas)216 PlatformContextSkia::PlatformContextSkia(SkCanvas* canvas) 217 217 : m_canvas(canvas) 218 , m_printing(false) 218 219 , m_drawingToImageBuffer(false) 219 220 , m_useGPU(false) … … 241 242 } 242 243 243 void PlatformContextSkia::setCanvas( skia::PlatformCanvas* canvas)244 void PlatformContextSkia::setCanvas(SkCanvas* canvas) 244 245 { 245 246 m_canvas = canvas; … … 610 611 } 611 612 612 bool PlatformContextSkia::isPrinting()613 {614 #if ENABLE(SKIA_GPU)615 return true;616 #else617 return m_canvas->getTopPlatformDevice().IsVectorial();618 #endif619 }620 621 613 bool PlatformContextSkia::isNativeFontRenderingAllowed() 622 614 { … … 624 616 return false; 625 617 #else 626 return m_canvas->getTopPlatformDevice().IsNativeFontRenderingAllowed();618 return skia::SupportsPlatformPaint(m_canvas); 627 619 #endif 628 620 } -
trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
r83409 r83649 73 73 // For printing, there shouldn't be any canvas. canvas can be NULL. If you 74 74 // supply a NULL canvas, you can also call setCanvas later. 75 PlatformContextSkia( skia::PlatformCanvas*);75 PlatformContextSkia(SkCanvas*); 76 76 ~PlatformContextSkia(); 77 77 78 78 // Sets the canvas associated with this context. Use when supplying NULL 79 79 // to the constructor. 80 void setCanvas( skia::PlatformCanvas*);80 void setCanvas(SkCanvas*); 81 81 82 82 // If false we're rendering to a GraphicsContext for a web page, if false … … 148 148 149 149 // Returns the canvas used for painting, NOT guaranteed to be non-null. 150 skia::PlatformCanvas* canvas() { return m_canvas; }150 SkCanvas* canvas() { return m_canvas; } 151 151 152 152 InterpolationQuality interpolationQuality() const; … … 164 164 // context. Bitmap shouldn't be resampled when printing to keep the best 165 165 // possible quality. 166 bool isPrinting(); 166 bool printing() const { return m_printing; } 167 void setPrinting(bool p) { m_printing = p; } 167 168 168 169 // Returns if the context allows rendering of fonts using native platform … … 186 187 #endif 187 188 // Call these before making a call that manipulates the underlying 188 // skia::PlatformCanvas or WebCore::GLES2Canvas189 // SkCanvas or WebCore::GLES2Canvas 189 190 void prepareForSoftwareDraw() const; 190 191 void prepareForHardwareDraw() const; 191 // Call to force the skia::PlatformCanvas to contain all rendering results.192 // Call to force the SkCanvas to contain all rendering results. 192 193 void syncSoftwareCanvas() const; 193 194 void markDirtyRect(const IntRect& rect); … … 206 207 207 208 // NULL indicates painting is disabled. Never delete this object. 208 skia::PlatformCanvas* m_canvas;209 SkCanvas* m_canvas; 209 210 210 211 // States stack. Enables local drawing state change with save()/restore() … … 219 220 IntSize m_imageResamplingHintSrcSize; 220 221 FloatSize m_imageResamplingHintDstSize; 222 bool m_printing; 221 223 bool m_drawingToImageBuffer; 222 224 bool m_useGPU; -
trunk/Source/WebKit/chromium/ChangeLog
r83642 r83649 1 2011-04-12 Alok Priyadarshi <alokp@chromium.org> 2 3 Reviewed by James Robinson. 4 5 Remove dependency on chromium skia::PlatformCanvas 6 https://bugs.webkit.org/show_bug.cgi?id=57563 7 8 * public/WebCanvas.h: 9 * src/WebFrameImpl.cpp: 10 (WebKit::WebFrameImpl::printPage): 11 * tests/TransparencyWinTest.cpp: 12 (WebCore::drawNativeRect): 13 (WebCore::getPixelAt): 14 (WebCore::clearTopLayerAlphaChannel): 15 (WebCore::clearTopLayerAlphaPixel): 16 (WebCore::TEST): 17 1 18 2011-04-12 Adam Barth <abarth@webkit.org> 2 19 -
trunk/Source/WebKit/chromium/public/WebCanvas.h
r50668 r83649 35 35 36 36 #if WEBKIT_USING_SKIA 37 namespace skia { class PlatformCanvas; } 37 class SkCanvas; 38 38 #elif WEBKIT_USING_CG 39 39 struct CGContext; … … 43 43 44 44 #if WEBKIT_USING_SKIA 45 typedef skia::PlatformCanvas WebCanvas;45 typedef SkCanvas WebCanvas; 46 46 #elif WEBKIT_USING_CG 47 47 typedef struct CGContext WebCanvas; -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r83366 r83649 1410 1410 } 1411 1411 1412 return m_printContext->spoolPage(GraphicsContextBuilder(canvas).context(), page); 1412 GraphicsContextBuilder builder(canvas); 1413 GraphicsContext& gc = builder.context(); 1414 #if WEBKIT_USING_SKIA 1415 gc.platformContext()->setPrinting(true); 1416 #endif 1417 1418 return m_printContext->spoolPage(gc, page); 1413 1419 } 1414 1420 -
trunk/Source/WebKit/chromium/tests/TransparencyWinTest.cpp
r77402 r83649 51 51 int x, int y, int w, int h) 52 52 { 53 skia::PlatformCanvas* canvas = context->platformContext()->canvas();54 HDC dc = canvas->beginPlatformPaint();53 SkCanvas* canvas = context->platformContext()->canvas(); 54 HDC dc = skia::BeginPlatformPaint(canvas); 55 55 56 56 RECT innerRc; … … 62 62 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); 63 63 64 canvas->endPlatformPaint();64 skia::EndPlatformPaint(canvas); 65 65 } 66 66 67 67 static Color getPixelAt(GraphicsContext* context, int x, int y) 68 68 { 69 const SkBitmap& bitmap = context->platformContext()->canvas()-> 70 getTopPlatformDevice().accessBitmap(false); 69 const SkBitmap& bitmap = context->platformContext()->canvas()->getTopDevice()->accessBitmap(false); 71 70 return Color(*reinterpret_cast<const RGBA32*>(bitmap.getAddr32(x, y))); 72 71 } … … 76 75 static void clearTopLayerAlphaChannel(GraphicsContext* context) 77 76 { 78 SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()-> 79 canvas()->getTopPlatformDevice().accessBitmap(false)); 77 SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->canvas()->getTopDevice()->accessBitmap(false)); 80 78 for (int y = 0; y < bitmap.height(); y++) { 81 79 uint32_t* row = bitmap.getAddr32(0, y); … … 88 86 static void clearTopLayerAlphaPixel(GraphicsContext* context, int x, int y) 89 87 { 90 SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()-> 91 canvas()->getTopPlatformDevice().accessBitmap(false)); 88 SkBitmap& bitmap = const_cast<SkBitmap&>(context->platformContext()->canvas()->getTopDevice()->accessBitmap(false)); 92 89 *bitmap.getAddr32(x, y) &= 0x00FFFFFF; 93 90 } … … 560 557 // clearTopLayerAlphaChannel because that will actually clear the whole 561 558 // canvas (since we have no extra layer!). 562 SkBitmap& bitmap = const_cast<SkBitmap&>(helper.context()-> 563 platformContext()->canvas()->getTopPlatformDevice(). 564 accessBitmap(false)); 559 SkBitmap& bitmap = const_cast<SkBitmap&>(helper.context()->platformContext()->canvas()->getTopDevice()->accessBitmap(false)); 565 560 *bitmap.getAddr32(2, 2) &= 0x00FFFFFF; 566 561 helper.composite();
Note: See TracChangeset
for help on using the changeset viewer.