diff options
author | Derek Sollenberger <djsollen@google.com> | 2010-12-17 13:44:51 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2010-12-20 08:21:42 -0500 |
commit | 6ca0f0452f06325e4abd3acca40a0a2f13fb644c (patch) | |
tree | 26831dc6154fdcb44181b40e27790f03e02e96b9 /WebCore/platform/graphics | |
parent | ab1ac7bfdac5723904e94d61f42e9c2d9f15fdb4 (diff) | |
download | external_webkit-6ca0f0452f06325e4abd3acca40a0a2f13fb644c.zip external_webkit-6ca0f0452f06325e4abd3acca40a0a2f13fb644c.tar.gz external_webkit-6ca0f0452f06325e4abd3acca40a0a2f13fb644c.tar.bz2 |
Add initial support for OpenGL plugins.
bug: 2907737
Change-Id: I6f4f21146c834554db5ecb67fed8994f1cdc2cfe
Diffstat (limited to 'WebCore/platform/graphics')
7 files changed, 199 insertions, 8 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 1efbecc..2fa1215 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -751,6 +751,18 @@ void GraphicsLayerAndroid::setContentsToImage(Image* image) } } +void GraphicsLayerAndroid::setContentsToMedia(PlatformLayer* mediaLayer) +{ + if (m_contentLayer != mediaLayer) { + m_contentLayer->unref(); + m_contentLayer = mediaLayer; + m_contentLayer->ref(); + setNeedsDisplay(); + } + + askForSync(); +} + PlatformLayer* GraphicsLayerAndroid::platformLayer() const { LOG("platformLayer"); diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index a243d65..ce6bac1 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -100,6 +100,7 @@ public: virtual void resumeAnimations(); virtual void setContentsToImage(Image*); + virtual void setContentsToMedia(PlatformLayer*); virtual PlatformLayer* platformLayer() const; void pauseDisplay(bool state); diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 69822b5..b62575f 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -14,6 +14,7 @@ #include "SkPaint.h" #include "SkPicture.h" #include "TilesManager.h" +#include "MediaLayer.h" #include <wtf/CurrentTime.h> #define LAYER_DEBUG // Add diagonals for debugging @@ -619,6 +620,12 @@ bool LayerAndroid::drawGL(SkMatrix& matrix) m_texture->consumerRelease(); } + return drawChildrenGL(matrix); +} + + +bool LayerAndroid::drawChildrenGL(SkMatrix& matrix) +{ bool askPaint = false; int count = this->countChildren(); if (count > 0) { diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 3d1c5af..fb6c4c7 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -112,8 +112,9 @@ public: bool needsTexture(); void checkForObsolescence(); - bool drawGL(SkMatrix&); - void paintBitmapGL(); + virtual bool drawGL(SkMatrix&); + bool drawChildrenGL(SkMatrix&); + virtual void paintBitmapGL(); void updateGLPositions(const TransformationMatrix& parentMatrix, float opacity); void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } @@ -223,6 +224,8 @@ public: unsigned int pictureUsed() { return m_pictureUsed; } void contentDraw(SkCanvas*); + virtual bool isMedia() const { return false; } + protected: virtual void onDraw(SkCanvas*, SkScalar opacity); diff --git a/WebCore/platform/graphics/android/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp new file mode 100644 index 0000000..9c370a5 --- /dev/null +++ b/WebCore/platform/graphics/android/MediaLayer.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "config.h" +#include "MediaLayer.h" +#include "TilesManager.h" + +#if USE(ACCELERATED_COMPOSITING) + +#include <wtf/CurrentTime.h> + +#define LAYER_DEBUG +#undef LAYER_DEBUG + +#ifdef DEBUG + +#include <cutils/log.h> +#include <wtf/text/CString.h> + +#undef XLOG +#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "MediaLayer", __VA_ARGS__) + +#else + +#undef XLOG +#define XLOG(...) + +#endif // DEBUG + +namespace WebCore { + +MediaLayer::MediaLayer() : LayerAndroid(false) +{ + m_bufferedTexture = new MediaTexture(EGL_NO_CONTEXT); + m_bufferedTexture->incStrong(this); + m_currentTextureInfo = 0; + XLOG("Creating Media Layer %p", this); +} + +MediaLayer::MediaLayer(const MediaLayer& layer) : LayerAndroid(layer) +{ + m_bufferedTexture = layer.getTexture(); + m_bufferedTexture->incStrong(this); + m_currentTextureInfo = 0; + XLOG("Creating Media Layer Copy %p -> %p", &layer, this); +} + +MediaLayer::~MediaLayer() +{ + XLOG("Deleting Media Layer"); + m_bufferedTexture->decStrong(this); +} + +bool MediaLayer::drawGL(SkMatrix& matrix) +{ + if (m_bufferedTexture) { + TextureInfo* textureInfo = m_bufferedTexture->consumerLock(); + if (textureInfo) { + SkRect rect; + rect.set(0, 0, getSize().width(), getSize().height()); + TransformationMatrix m = drawTransform(); + TilesManager::instance()->shader()->drawLayerQuad(m, rect, + textureInfo->m_textureId, + 1.0f); //TODO fix this m_drawOpacity + } + m_bufferedTexture->consumerRelease(); + } + + drawChildrenGL(matrix); + + //TODO allow plugins to specify when they should be drawn + return true; +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/WebCore/platform/graphics/android/MediaLayer.h b/WebCore/platform/graphics/android/MediaLayer.h new file mode 100644 index 0000000..2ff3197 --- /dev/null +++ b/WebCore/platform/graphics/android/MediaLayer.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MediaLayer_h +#define MediaLayer_h + +#if USE(ACCELERATED_COMPOSITING) + +#include "RefPtr.h" +#include "DoubleBufferedTexture.h" +#include "LayerAndroid.h" +#include <utils/RefBase.h> + + +namespace WebCore { + +class MediaTexture : public DoubleBufferedTexture, + public android::LightRefBase<MediaTexture> { + +public: + MediaTexture(EGLContext sharedContext) : DoubleBufferedTexture(sharedContext) { }; +}; + + +class MediaLayer : public LayerAndroid { + +public: + MediaLayer(); + MediaLayer(const MediaLayer& layer); + virtual ~MediaLayer(); + + virtual bool drawGL(SkMatrix&); + virtual void paintBitmapGL() const { }; + + virtual bool isMedia() const { return true; } + virtual LayerAndroid* copy() const { return new MediaLayer(*this); } + + MediaTexture* getTexture() const { return m_bufferedTexture; } + + void setCurrentTextureInfo(TextureInfo* info) { m_currentTextureInfo = info; } + TextureInfo* getCurrentTextureInfo() const { return m_currentTextureInfo; } + + +private: + + // GL textures management + MediaTexture* m_bufferedTexture; + + TextureInfo* m_currentTextureInfo; + +}; + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) + +#endif // MediaLayer_h diff --git a/WebCore/platform/graphics/android/SharedTexture.cpp b/WebCore/platform/graphics/android/SharedTexture.cpp index 76d6da0..41b4af1 100644 --- a/WebCore/platform/graphics/android/SharedTexture.cpp +++ b/WebCore/platform/graphics/android/SharedTexture.cpp @@ -63,17 +63,16 @@ bool TextureInfo::operator==(const TextureInfo& otherTexture) SharedTexture::SharedTexture() { - m_display = eglGetCurrentDisplay(); m_eglImage = EGL_NO_IMAGE_KHR; m_isNewImage = true; m_syncObject = EGL_NO_SYNC_KHR; - m_supportsEGLImage = GLUtils::isEGLImageSupported(); - m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported(); - // TODO temporarily disable fence sync until nvidia implementation is complete + // Defer initialization of these values until we initialize the source + // texture. This ensures that this initialization happens in the appropriate + // thread. + m_display = 0; + m_supportsEGLImage = false; m_supportsEGLFenceSyncKHR = false; - - LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR); } // called by the consumer when it no longer wants to consume and after it has @@ -90,6 +89,16 @@ SharedTexture::~SharedTexture() void SharedTexture::initSourceTexture() { + + m_display = eglGetCurrentDisplay(); + m_supportsEGLImage = GLUtils::isEGLImageSupported(); + m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported(); + + //TODO temporarily disable fence sync until nvidia implementation is complete + m_supportsEGLFenceSyncKHR = false; + + LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR); + glGenTextures(1, &m_sourceTexture.m_textureId); } |