Source/WebCore/ChangeLog

112012-12-27 Huang Dongsung <luxtella@company100.net>
22
 3 [TexMap] Refactor code related to debug border and repaint count. [1/2]
 4 https://bugs.webkit.org/show_bug.cgi?id=105787
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Introduce TextureMapperPaintParameters to reduce the number of parameters of
 9 TextureMapperPlatformLayer::paintToTextureMapper().
 10 Now we can easily add new arguments into TextureMapperPlatformLayer::paintToTextureMapper()
 11 when needed.
 12
 13 No new tests. Refactoring only.
 14
 15 * platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
 16 (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
 17 * platform/graphics/cairo/GraphicsContext3DPrivate.h:
 18 (GraphicsContext3DPrivate):
 19 * platform/graphics/efl/GraphicsContext3DPrivate.cpp:
 20 (GraphicsContext3DPrivate::paintToTextureMapper):
 21 * platform/graphics/efl/GraphicsContext3DPrivate.h:
 22 (GraphicsContext3DPrivate):
 23 * platform/graphics/qt/GraphicsContext3DQt.cpp:
 24 (GraphicsContext3DPrivate):
 25 (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
 26 * platform/graphics/qt/MediaPlayerPrivateQt.cpp:
 27 (WebCore::MediaPlayerPrivateQt::paintToTextureMapper):
 28 * platform/graphics/qt/MediaPlayerPrivateQt.h:
 29 (MediaPlayerPrivateQt):
 30 * platform/graphics/texmap/TextureMapperBackingStore.cpp:
 31 (WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
 32 (WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
 33 * platform/graphics/texmap/TextureMapperBackingStore.h:
 34 (TextureMapperBackingStore):
 35 (TextureMapperSurfaceBackingStore):
 36 (TextureMapperTiledBackingStore):
 37 * platform/graphics/texmap/TextureMapperLayer.cpp:
 38 (WebCore::TextureMapperLayer::paintSelf):
 39 * platform/graphics/texmap/TextureMapperPlatformLayer.h:
 40 (TextureMapperPaintParameters):
 41 (WebCore::TextureMapperPaintParameters::TextureMapperPaintParameters):
 42 (TextureMapperPlatformLayer):
 43
 442012-12-27 Huang Dongsung <luxtella@company100.net>
 45
346 [TexMap] Use a premuliplied color in TextureMapperGL.
447 https://bugs.webkit.org/show_bug.cgi?id=105786
548

Source/WebKit2/ChangeLog

 12012-12-27 Huang Dongsung <luxtella@company100.net>
 2
 3 [TexMap] Refactor code related to debug border and repaint count. [1/2]
 4 https://bugs.webkit.org/show_bug.cgi?id=105787
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This patch changes the signature of TextureMapperPlatformLayer::paintToTextureMapper()
 9 so CoordinatedBackingStore is also changed.
 10
 11 * UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp:
 12 (WebKit::CoordinatedBackingStore::paintTilesToTextureMapper):
 13 (WebKit::CoordinatedBackingStore::paintToTextureMapper):
 14 * UIProcess/CoordinatedGraphics/CoordinatedBackingStore.h:
 15 (CoordinatedBackingStore):
 16
1172012-12-26 Csaba Osztrogonác <ossy@webkit.org>
218
319 Unreviewed Xmas buildfix after r138479.

Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp

@@PlatformGraphicsContext3D GraphicsContext3DPrivate::platformContext()
7878}
7979
8080#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
81 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask)
 81void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TextureMapperPaintParameters& parameters)
8282{
8383 if (!m_glContext)
8484 return;

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
9191 if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
9292 GraphicsContext* context = textureMapper->graphicsContext();
9393 context->save();
94  context->platformContext()->setGlobalAlpha(opacity);
 94 context->platformContext()->setGlobalAlpha(parameters.opacity);
9595
9696 const int height = m_context->m_currentHeight;
9797 const int width = m_context->m_currentWidth;

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
105105 context->translate(0, height);
106106 context->scale(FloatSize(1, -1));
107107
108  context->concatCTM(matrix.toAffineTransform());
 108 context->concatCTM(parameters.modelViewMatrix.toAffineTransform());
109109
110110 m_context->readRenderingResults(pixels.get(), totalBytes);
111111

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
142142 TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
143143 TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
144144 IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
145  texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity, mask);
 145 texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, parameters.modelViewMatrix, parameters.opacity, parameters.mask);
146146#endif // USE(ACCELERATED_COMPOSITING_GL)
147147}
148148#endif // USE(ACCELERATED_COMPOSITING)

Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h

@@public:
4444 GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
4545
4646#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
47  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 47 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TextureMapperPaintParameters&);
4848#endif
4949
5050private:

Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp

@@bool GraphicsContext3DPrivate::makeContextCurrent()
116116}
117117
118118#if USE(TEXTURE_MAPPER_GL)
119 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */)
 119void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TextureMapperPaintParameters&)
120120{
121121 notImplemented();
122122}

Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h

@@public:
5151 PlatformLayer* platformLayer() const;
5252#endif
5353#if USE(TEXTURE_MAPPER_GL)
54  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 54 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TextureMapperPaintParameters&);
5555#endif
5656#if USE(GRAPHICS_SURFACE)
5757 virtual IntSize platformLayerSize() const;

Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

@@public:
6565 ~GraphicsContext3DPrivate();
6666
6767#if USE(ACCELERATED_COMPOSITING)
68  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 68 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TextureMapperPaintParameters&);
6969#endif
7070#if USE(GRAPHICS_SURFACE)
7171 virtual IntSize platformLayerSize() const;

@@static inline quint32 swapBgrToRgb(quint32 pixel)
208208}
209209
210210#if USE(ACCELERATED_COMPOSITING)
211 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask)
 211void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TextureMapperPaintParameters& parameters)
212212{
213213 m_context->markLayerComposited();
214214 blitMultisampleFramebufferAndRestoreContext();

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
230230 currentContext->makeCurrent(currentSurface);
231231
232232 TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
233  m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, matrix, opacity, mask);
 233 m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, parameters.modelViewMatrix, parameters.opacity, parameters.mask);
234234#endif
235235 return;
236236 }

@@void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
238238 GraphicsContext* context = textureMapper->graphicsContext();
239239 QPainter* painter = context->platformContext();
240240 painter->save();
241  painter->setTransform(matrix);
242  painter->setOpacity(opacity);
 241 painter->setTransform(parameters.modelViewMatrix);
 242 painter->setOpacity(parameters.opacity);
243243
244244 const int height = m_context->m_currentHeight;
245245 const int width = m_context->m_currentWidth;

Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp

@@void MediaPlayerPrivateQt::paintCurrentFrameInContext(GraphicsContext* context,
645645}
646646
647647#if USE(ACCELERATED_COMPOSITING)
648 void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture*)
 648void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TextureMapperPaintParameters&)
649649{
650650}
651651#endif

Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h

@@public:
109109 virtual void acceleratedRenderingStateChanged() { }
110110 // Const-casting here is safe, since all of TextureMapperPlatformLayer's functions are const.g
111111 virtual PlatformLayer* platformLayer() const { return 0; }
112  virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 112 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TextureMapperPaintParameters&);
113113#endif
114114
115115 virtual PlatformMedia platformMedia() const;

Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp

@@PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
5252 return emptyTexture;
5353}
5454
55 void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 55void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TextureMapperPaintParameters& parameters)
5656{
5757 if (m_graphicsSurface)
58  m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
 58 m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, parameters.modelViewMatrix, parameters.opacity, parameters.mask);
5959}
6060#endif
6161

@@unsigned TextureMapperBackingStore::calculateExposedTileEdges(const FloatRect& t
133133 return exposedEdges;
134134}
135135
136 void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 136void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TextureMapperPaintParameters& parameters)
137137{
138138 updateContentsFromImageIfNeeded(textureMapper);
139  TransformationMatrix adjustedTransform = transform;
 139 TransformationMatrix adjustedTransform = parameters.modelViewMatrix;
140140 adjustedTransform.multiply(TransformationMatrix::rectToRect(rect(), targetRect));
141141 for (size_t i = 0; i < m_tiles.size(); ++i) {
142  m_tiles[i].paint(textureMapper, adjustedTransform, opacity, mask, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
 142 m_tiles[i].paint(textureMapper, adjustedTransform, parameters.opacity, parameters.mask, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
143143 if (m_drawsDebugBorders)
144144 textureMapper->drawBorder(m_debugBorderColor, m_debugBorderWidth, m_tiles[i].rect(), adjustedTransform);
145145 }

Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h

@@class GraphicsLayer;
3939class TextureMapperBackingStore : public TextureMapperPlatformLayer, public RefCounted<TextureMapperBackingStore> {
4040public:
4141 virtual PassRefPtr<BitmapTexture> texture() const = 0;
42  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) = 0;
 42 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TextureMapperPaintParameters&) = 0;
4343 virtual ~TextureMapperBackingStore() { }
4444
4545protected:

@@public:
5353 void setGraphicsSurface(PassRefPtr<GraphicsSurface>);
5454 void swapBuffersIfNeeded(uint32_t frontBuffer);
5555 virtual PassRefPtr<BitmapTexture> texture() const;
56  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
 56 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TextureMapperPaintParameters&);
5757 virtual ~TextureMapperSurfaceBackingStore() { }
5858
5959private:

@@public:
9393 virtual ~TextureMapperTiledBackingStore() { }
9494
9595 virtual PassRefPtr<BitmapTexture> texture() const OVERRIDE;
96  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
 96 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TextureMapperPaintParameters&) OVERRIDE;
9797 void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
9898 void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
9999

Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

@@void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
115115 transform.multiply(options.transform);
116116 transform.multiply(m_effectiveTransform.combined());
117117
118  float opacity = options.opacity;
119  RefPtr<BitmapTexture> mask = options.mask;
 118 TextureMapperPaintParameters parameters;
 119 parameters.modelViewMatrix = transform;
 120 parameters.opacity = options.opacity;
 121 parameters.mask = options.mask.get();
120122
121123 if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty()) {
122124 if (!m_state.solidColor.alpha())

@@void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
125127 Color color = m_state.solidColor;
126128 float r, g, b, a;
127129 color.getRGBA(r, g, b, a);
128  color = Color(r * opacity, g * opacity, b * opacity, a * opacity);
129  options.textureMapper->drawSolidColor(m_state.contentsRect, transform, color);
 130 color = Color(r * parameters.opacity, g * parameters.opacity, b * parameters.opacity, a * parameters.opacity);
 131 options.textureMapper->drawSolidColor(m_state.contentsRect, parameters.modelViewMatrix, color);
130132 return;
131133 }
132134
133135 if (m_backingStore) {
134136 ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_state.size.isEmpty());
135137 ASSERT(!layerRect().isEmpty());
136  m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, opacity, mask.get());
 138 m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), parameters);
137139 }
138140
139141 if (m_contentsLayer) {
140142 ASSERT(!layerRect().isEmpty());
141  m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, opacity, mask.get());
 143 m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, parameters);
142144 }
143145}
144146

Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h

2424#include "GraphicsSurface.h"
2525#endif
2626
 27#include "TextureMapper.h"
2728#include "TransformationMatrix.h"
2829
2930namespace WebCore {
3031
31 class TextureMapper;
32 class BitmapTexture;
 32class TextureMapperPaintParameters {
 33public:
 34 TransformationMatrix modelViewMatrix;
 35 float opacity;
 36 BitmapTexture* mask;
 37
 38 TextureMapperPaintParameters()
 39 : opacity(1)
 40 , mask(0)
 41 { }
 42};
3343
3444class TextureMapperPlatformLayer {
3545public:
3646 virtual ~TextureMapperPlatformLayer() { }
37  virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0, BitmapTexture* mask = 0) = 0;
 47 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TextureMapperPaintParameters&) = 0;
3848 virtual void swapBuffers() { }
3949#if USE(GRAPHICS_SURFACE)
4050 virtual IntSize platformLayerSize() const { return IntSize(); }

Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp

@@static bool shouldShowTileDebugVisuals()
119119 return false;
120120}
121121
122 void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const FloatRect& rect)
 122void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TextureMapperPaintParameters& parameters, const FloatRect& rect)
123123{
124124 for (size_t i = 0; i < tiles.size(); ++i) {
125125 TextureMapperTile* tile = tiles[i];
126  tile->paint(textureMapper, transform, opacity, mask, calculateExposedTileEdges(rect, tile->rect()));
 126 tile->paint(textureMapper, parameters.modelViewMatrix, parameters.opacity, parameters.mask, calculateExposedTileEdges(rect, tile->rect()));
127127 static bool shouldDebug = shouldShowTileDebugVisuals();
128128 if (!shouldDebug)
129129 continue;
130130
131  textureMapper->drawBorder(Color(0xFF, 0, 0), 2, tile->rect(), transform);
132  textureMapper->drawRepaintCounter(static_cast<CoordinatedBackingStoreTile*>(tile)->repaintCount(), 8, tile->rect().location(), transform);
 131 textureMapper->drawBorder(Color(0xFF, 0, 0), 2, tile->rect(), parameters.modelViewMatrix);
 132 textureMapper->drawRepaintCounter(static_cast<CoordinatedBackingStoreTile*>(tile)->repaintCount(), 8, tile->rect().location(), parameters.modelViewMatrix);
133133 }
134134}
135135
136 void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 136void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TextureMapperPaintParameters& parameters)
137137{
138138 if (m_tiles.isEmpty())
139139 return;

@@void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper,
158158
159159 // Only show the previous tile if the opacity is high, otherwise effect looks like a bug.
160160 // We show the previous-scale tile anyway if it doesn't intersect with any current-scale tile.
161  if (opacity < 0.95 && coveredRect.intersects(tile.rect()))
 161 if (parameters.opacity < 0.95 && coveredRect.intersects(tile.rect()))
162162 continue;
163163
164164 previousTilesToPaint.append(&tile);
165165 }
166166
167167 FloatRect rectOnContents(FloatPoint::zero(), m_size);
168  TransformationMatrix adjustedTransform = transform;
 168 TextureMapperPaintParameters adjustedParameters = parameters;
169169 // targetRect is on the contents coordinate system, so we must compare two rects on the contents coordinate system.
170170 // See TiledBackingStore.
171  adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
 171 adjustedParameters.modelViewMatrix.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
172172
173  paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedTransform, opacity, mask, rectOnContents);
174  paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedTransform, opacity, mask, rectOnContents);
 173 paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedParameters, rectOnContents);
 174 paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedParameters, rectOnContents);
175175}
176176
177177void CoordinatedBackingStore::commitTileOperations(TextureMapper* textureMapper)

Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.h

@@public:
6565 void commitTileOperations(WebCore::TextureMapper*);
6666 PassRefPtr<WebCore::BitmapTexture> texture() const;
6767 void setSize(const WebCore::FloatSize&);
68  virtual void paintToTextureMapper(WebCore::TextureMapper*, const WebCore::FloatRect&, const WebCore::TransformationMatrix&, float, WebCore::BitmapTexture*);
 68 virtual void paintToTextureMapper(WebCore::TextureMapper*, const WebCore::FloatRect&, const WebCore::TextureMapperPaintParameters&);
6969
7070private:
7171 CoordinatedBackingStore()
7272 : m_scale(1.)
7373 { }
74  void paintTilesToTextureMapper(Vector<WebCore::TextureMapperTile*>&, WebCore::TextureMapper*, const WebCore::TransformationMatrix&, float, WebCore::BitmapTexture*, const WebCore::FloatRect&);
 74 void paintTilesToTextureMapper(Vector<WebCore::TextureMapperTile*>&, WebCore::TextureMapper*, const WebCore::TextureMapperPaintParameters&, const WebCore::FloatRect&);
7575
7676 HashMap<uint32_t, CoordinatedBackingStoreTile> m_tiles;
7777 HashSet<uint32_t> m_tilesToRemove;