Diff
Modified: trunk/Source/WebCore/ChangeLog (101114 => 101115)
--- trunk/Source/WebCore/ChangeLog 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/ChangeLog 2011-11-24 02:31:49 UTC (rev 101115)
@@ -1,3 +1,29 @@
+2011-11-23 Ami Fischman <[email protected]>
+
+ Teach VideoLayerChromium how to render native texture (to support HW video decode).
+ https://bugs.webkit.org/show_bug.cgi?id=73043
+
+ Reviewed by Kenneth Russell.
+
+ No new tests. (depends on chromium support landing, and supporting HW being available)
+
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::drawLayersOntoRenderSurfaces):
+ (WebCore::LayerRendererChromium::videoLayerNativeTextureProgram):
+ * platform/graphics/chromium/LayerRendererChromium.h:
+ * platform/graphics/chromium/VideoFrameChromium.h:
+ * platform/graphics/chromium/VideoLayerChromium.cpp:
+ (WebCore::VideoLayerChromium::VideoLayerChromium):
+ (WebCore::VideoLayerChromium::updateCompositorResources):
+ (WebCore::VideoLayerChromium::pushPropertiesTo):
+ (WebCore::VideoLayerChromium::determineTextureFormat):
+ * platform/graphics/chromium/VideoLayerChromium.h:
+ * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
+ (WebCore::CCVideoLayerImpl::setNativeTexture):
+ (WebCore::CCVideoLayerImpl::draw):
+ (WebCore::CCVideoLayerImpl::drawNativeTexture):
+ * platform/graphics/chromium/cc/CCVideoLayerImpl.h:
+
2011-11-23 Vincent Scheib <[email protected]>
Pointer Lock: Plumb movement coordinates from PlatformMouseEvent to MouseEvents.
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp 2011-11-24 02:31:49 UTC (rev 101115)
@@ -320,7 +320,7 @@
void LayerRendererChromium::drawLayersOntoRenderSurfaces(CCLayerImpl* rootDrawLayer, const CCLayerList& renderSurfaceLayerList)
{
TRACE_EVENT("LayerRendererChromium::drawLayersOntoRenderSurfaces", this, 0);
-
+
// Update the contents of the render surfaces. We traverse the render surfaces
// from back to front to guarantee that nested render surfaces get rendered in
// the correct order.
@@ -880,7 +880,18 @@
return m_videoLayerYUVProgram.get();
}
+const CCVideoLayerImpl::NativeTextureProgram* LayerRendererChromium::videoLayerNativeTextureProgram()
+{
+ if (!m_videoLayerNativeTextureProgram)
+ m_videoLayerNativeTextureProgram = adoptPtr(new CCVideoLayerImpl::NativeTextureProgram(m_context.get()));
+ if (!m_videoLayerNativeTextureProgram->initialized()) {
+ TRACE_EVENT("LayerRendererChromium::videoLayerNativeTextureProgram::initialize", this, 0);
+ m_videoLayerNativeTextureProgram->initialize(m_context.get());
+ }
+ return m_videoLayerNativeTextureProgram.get();
+}
+
void LayerRendererChromium::cleanupSharedObjects()
{
makeContextCurrent();
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h 2011-11-24 02:31:49 UTC (rev 101115)
@@ -132,6 +132,7 @@
const CCPluginLayerImpl::TexRectProgramFlip* pluginLayerTexRectProgramFlip();
const CCVideoLayerImpl::RGBAProgram* videoLayerRGBAProgram();
const CCVideoLayerImpl::YUVProgram* videoLayerYUVProgram();
+ const CCVideoLayerImpl::NativeTextureProgram* videoLayerNativeTextureProgram();
void getFramebufferPixels(void *pixels, const IntRect&);
@@ -225,6 +226,7 @@
OwnPtr<CCRenderSurface::ProgramAA> m_renderSurfaceProgramAA;
OwnPtr<CCVideoLayerImpl::RGBAProgram> m_videoLayerRGBAProgram;
OwnPtr<CCVideoLayerImpl::YUVProgram> m_videoLayerYUVProgram;
+ OwnPtr<CCVideoLayerImpl::NativeTextureProgram> m_videoLayerNativeTextureProgram;
OwnPtr<TextureManager> m_renderSurfaceTextureManager;
OwnPtr<TrackingTextureAllocator> m_contentsTextureAllocator;
Modified: trunk/Source/WebCore/platform/graphics/chromium/VideoFrameChromium.h (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/VideoFrameChromium.h 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/VideoFrameChromium.h 2011-11-24 02:31:49 UTC (rev 101115)
@@ -59,6 +59,8 @@
NV12,
Empty,
ASCII,
+ I420,
+ NativeTexture,
};
virtual ~VideoFrameChromium();
@@ -72,6 +74,7 @@
virtual const void* data(unsigned plane) const = 0;
virtual const IntSize requiredTextureSize(unsigned plane) const = 0;
virtual bool hasPaddingBytes(unsigned plane) const = 0;
+ virtual unsigned textureId() const = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp 2011-11-24 02:31:49 UTC (rev 101115)
@@ -57,6 +57,7 @@
, m_frameFormat(VideoFrameChromium::Invalid)
, m_provider(provider)
, m_planes(0)
+ , m_nativeTextureId(0)
{
}
@@ -113,6 +114,15 @@
return;
}
+ if (textureFormat == GraphicsContext3D::TEXTURE_2D) {
+ m_nativeTextureId = frame->textureId();
+ m_nativeTextureSize = IntSize(frame->width(), frame->height());
+ m_nativeTextureVisibleSize = IntSize(frame->width(), frame->height());
+ resetNeedsDisplay();
+ m_provider->putCurrentFrame(frame);
+ return;
+ }
+
// Allocate textures for planes if they are not allocated already, or
// reallocate textures that are the wrong size for the frame.
bool texturesReserved = reserveTextures(frame, textureFormat);
@@ -155,6 +165,8 @@
}
for (unsigned i = m_planes; i < MaxPlanes; ++i)
videoLayer->setTexture(i, 0, IntSize(), IntSize());
+ if (m_frameFormat == VideoFrameChromium::NativeTexture)
+ videoLayer->setNativeTexture(m_nativeTextureId, m_nativeTextureSize, m_nativeTextureVisibleSize);
}
void VideoLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
@@ -177,6 +189,8 @@
return GraphicsContext3D::LUMINANCE;
case VideoFrameChromium::RGBA:
return GraphicsContext3D::RGBA;
+ case VideoFrameChromium::NativeTexture:
+ return GraphicsContext3D::TEXTURE_2D;
default:
break;
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h 2011-11-24 02:31:49 UTC (rev 101115)
@@ -85,6 +85,10 @@
enum { MaxPlanes = 3 };
Texture m_textures[MaxPlanes];
unsigned m_planes;
+
+ unsigned m_nativeTextureId;
+ IntSize m_nativeTextureSize;
+ IntSize m_nativeTextureVisibleSize;
};
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp 2011-11-24 02:31:49 UTC (rev 101115)
@@ -77,6 +77,13 @@
m_textures[index].visibleSize = visibleSize;
}
+void CCVideoLayerImpl::setNativeTexture(Platform3DObject textureId, const IntSize& size, const IntSize& visibleSize)
+{
+ m_nativeTextureId = textureId;
+ m_nativeTextureSize = size;
+ m_nativeTextureVisibleSize = visibleSize;
+}
+
void CCVideoLayerImpl::draw(LayerRendererChromium* layerRenderer)
{
ASSERT(CCProxy::isImplThread());
@@ -92,6 +99,9 @@
case VideoFrameChromium::RGBA:
drawRGBA(layerRenderer);
break;
+ case VideoFrameChromium::NativeTexture:
+ drawNativeTexture(layerRenderer);
+ break;
default:
// FIXME: Implement other paths.
notImplemented();
@@ -163,7 +173,28 @@
-1);
}
+void CCVideoLayerImpl::drawNativeTexture(LayerRendererChromium* layerRenderer) const
+{
+ const NativeTextureProgram* program = layerRenderer->videoLayerNativeTextureProgram();
+ ASSERT(program && program->initialized());
+ GraphicsContext3D* context = layerRenderer->context();
+
+ GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
+ GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_nativeTextureId));
+
+ GLC(context, context->useProgram(program->program()));
+ float widthScaleFactor = static_cast<float>(m_nativeTextureVisibleSize.width()) / m_nativeTextureSize.width();
+ GLC(context, context->uniform4f(program->vertexShader().texTransformLocation(), 0, 0, widthScaleFactor, 1));
+
+ GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
+
+ layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
+ program->vertexShader().matrixLocation(),
+ program->fragmentShader().alphaLocation(),
+ -1);
+}
+
void CCVideoLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
{
writeIndent(ts, indent);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h (101114 => 101115)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h 2011-11-24 02:31:49 UTC (rev 101115)
@@ -46,6 +46,7 @@
typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexFlipAlpha> RGBAProgram;
typedef ProgramBinding<VertexShaderPosTexYUVStretch, FragmentShaderYUVVideo> YUVProgram;
+ typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexFlipAlpha> NativeTextureProgram;
virtual void draw(LayerRendererChromium*);
@@ -54,6 +55,7 @@
void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
void setFrameFormat(VideoFrameChromium::Format format) { m_frameFormat = format; }
void setTexture(size_t, Platform3DObject textureId, const IntSize&, const IntSize& visibleSize);
+ void setNativeTexture(Platform3DObject textureId, const IntSize&, const IntSize& visibleSize);
private:
explicit CCVideoLayerImpl(int);
@@ -68,6 +70,7 @@
void drawYUV(LayerRendererChromium*) const;
void drawRGBA(LayerRendererChromium*) const;
+ void drawNativeTexture(LayerRendererChromium*) const;
static const float yuv2RGB[9];
static const float yuvAdjust[3];
@@ -75,6 +78,10 @@
bool m_skipsDraw;
VideoFrameChromium::Format m_frameFormat;
Texture m_textures[3];
+
+ Platform3DObject m_nativeTextureId;
+ IntSize m_nativeTextureSize;
+ IntSize m_nativeTextureVisibleSize;
};
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (101114 => 101115)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-11-24 02:31:49 UTC (rev 101115)
@@ -1,3 +1,15 @@
+2011-11-23 Ami Fischman <[email protected]>
+
+ Teach VideoLayerChromium how to render native texture (to support HW video decode).
+ https://bugs.webkit.org/show_bug.cgi?id=73043
+
+ Reviewed by Kenneth Russell.
+
+ * public/WebVideoFrame.h:
+ * src/VideoFrameChromiumImpl.cpp:
+ (WebKit::VideoFrameChromiumImpl::textureId):
+ * src/VideoFrameChromiumImpl.h:
+
2011-11-23 Vincent Scheib <[email protected]>
Pointer Lock: Plumb movement coordinates from PlatformMouseEvent to MouseEvents.
Modified: trunk/Source/WebKit/chromium/public/WebVideoFrame.h (101114 => 101115)
--- trunk/Source/WebKit/chromium/public/WebVideoFrame.h 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebKit/chromium/public/WebVideoFrame.h 2011-11-24 02:31:49 UTC (rev 101115)
@@ -49,15 +49,18 @@
FormatNV12,
FormatEmpty,
FormatASCII,
+ FormatI420,
+ FormatNativeTexture,
};
virtual ~WebVideoFrame() { }
- virtual Format format() const = 0;
- virtual unsigned width() const = 0;
- virtual unsigned height() const = 0;
- virtual unsigned planes() const = 0;
- virtual int stride(unsigned plane) const = 0;
- virtual const void* data(unsigned plane) const = 0;
+ virtual Format format() const { return FormatInvalid; }
+ virtual unsigned width() const { return 0; }
+ virtual unsigned height() const { return 0; }
+ virtual unsigned planes() const { return 0; }
+ virtual int stride(unsigned plane) const { return 0; }
+ virtual const void* data(unsigned plane) const { return 0; }
+ virtual unsigned textureId() const { return 0; }
};
} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp (101114 => 101115)
--- trunk/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp 2011-11-24 02:31:49 UTC (rev 101115)
@@ -121,4 +121,11 @@
return false;
}
+unsigned VideoFrameChromiumImpl::textureId() const
+{
+ if (m_webVideoFrame)
+ return m_webVideoFrame->textureId();
+ return 0;
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h (101114 => 101115)
--- trunk/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h 2011-11-24 02:29:36 UTC (rev 101114)
+++ trunk/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h 2011-11-24 02:31:49 UTC (rev 101115)
@@ -57,6 +57,7 @@
virtual const void* data(unsigned plane) const;
virtual const WebCore::IntSize requiredTextureSize(unsigned plane) const;
virtual bool hasPaddingBytes(unsigned plane) const;
+ virtual unsigned textureId() const;
private:
WebVideoFrame* m_webVideoFrame;