本文整理汇总了C++中ShaderProgram::drawQuad方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::drawQuad方法的具体用法?C++ ShaderProgram::drawQuad怎么用?C++ ShaderProgram::drawQuad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::drawQuad方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showPreparingAnimation
void VideoLayerAndroid::showPreparingAnimation(const SkRect& rect,
const SkRect innerRect)
{
ShaderProgram* shader = TilesManager::instance()->shader();
VideoLayerManager* manager = TilesManager::instance()->videoLayerManager();
// Paint the video content's background.
PureColorQuadData backGroundQuadData(Color(128, 128, 128, 255), LayerQuad,
&m_drawTransform, &rect);
shader->drawQuad(&backGroundQuadData);
TransformationMatrix addReverseRotation;
TransformationMatrix addRotation = m_drawTransform;
addRotation.translate(innerRect.fLeft, innerRect.fTop);
double halfButtonSize = manager->getButtonSize() / 2;
addRotation.translate(halfButtonSize, halfButtonSize);
addReverseRotation = addRotation;
addRotation.rotate(m_rotateDegree);
addRotation.translate(-halfButtonSize, -halfButtonSize);
SkRect size = SkRect::MakeWH(innerRect.width(), innerRect.height());
TextureQuadData spinnerQuadData(manager->getSpinnerOuterTextureId(),
GL_TEXTURE_2D, GL_LINEAR,
LayerQuad, &addRotation, &size);
shader->drawQuad(&spinnerQuadData);
addReverseRotation.rotate(-m_rotateDegree);
addReverseRotation.translate(-halfButtonSize, -halfButtonSize);
spinnerQuadData.updateTextureId(manager->getSpinnerInnerTextureId());
spinnerQuadData.updateDrawMatrix(&addReverseRotation);
shader->drawQuad(&spinnerQuadData);
m_rotateDegree += ROTATESTEP;
}
示例2: captureImage
/*
//Seems a SAMSUNG change BEGIN
bool VideoLayerAndroid::captureImage(PlatformWebGLVideoTexture* tex, VideoImageCallback callback)
{
if (m_playerState == PLAYING && m_surfaceTexture.get()) {
Locker<WTF::Mutex> lock(m_mutexRef->mutex);
bool ret = (tex->*callback)(m_surfaceTexture);
glFinish();
return ret;
}
return false;
}
//Seems a SAMSUNG change END
*/
bool VideoLayerAndroid::drawGL(bool layerTilesDisabled)
{
// Lazily allocated the textures.
TilesManager* tilesManager = TilesManager::instance();
VideoLayerManager* manager = tilesManager->videoLayerManager();
manager->initGLResourcesIfNeeded();
ShaderProgram* shader = tilesManager->shader();
SkRect rect = SkRect::MakeSize(getSize());
GLfloat surfaceMatrix[16];
// Calculate the video rect based on the aspect ratio and the element rect.
SkRect videoRect = calVideoRect(rect);
PureColorQuadData pureColorQuadData(Color(0, 0, 0, 255), LayerQuad,
&m_drawTransform, &rect);
if (videoRect != rect) {
// Paint the whole video element with black color when video content
// can't cover the whole area.
shader->drawQuad(&pureColorQuadData);
}
// Inner rect is for the progressing / play / pause animation.
SkRect innerRect = SkRect::MakeWH(manager->getButtonSize(),
manager->getButtonSize());
if (innerRect.contains(videoRect))
innerRect = videoRect;
double buttonSize = manager->getButtonSize();
innerRect.offset(videoRect.fLeft + (videoRect.width() - buttonSize) / 2,
videoRect.fTop + (videoRect.height() - buttonSize) / 2);
// When we are drawing the animation of the play/pause button in the
// middle of the video, we need to ask for redraw.
bool needRedraw = false;
TextureQuadData iconQuadData(0, GL_TEXTURE_2D, GL_LINEAR, LayerQuad,
&m_drawTransform, &innerRect);
// Draw the poster image, the progressing image or the Video depending
// on the player's state.
if (m_playerState == PREPARING) {
// Show the progressing animation, with two rotating circles
showPreparingAnimation(videoRect, innerRect);
needRedraw = true;
} else if (m_playerState == PLAYING && m_surfaceTexture.get()) {
// Show the real video.
Locker<WTF::Mutex> lock(m_mutexRef->mutex);//Seems a SAMSUNG change
m_surfaceTexture->updateTexImage();
m_surfaceTexture->getTransformMatrix(surfaceMatrix);
GLuint textureId = manager->getTextureId(uniqueId());
shader->drawVideoLayerQuad(m_drawTransform, surfaceMatrix,
videoRect, textureId);
manager->updateMatrix(uniqueId(), surfaceMatrix);
// Use the scale to control the fading the sizing during animation
double scale = manager->drawIcon(uniqueId(), PlayIcon);
if (scale) {
innerRect.inset(manager->getButtonSize() / 4 * scale,
manager->getButtonSize() / 4 * scale);
iconQuadData.updateTextureId(manager->getPlayTextureId());
iconQuadData.updateOpacity(scale);
shader->drawQuad(&iconQuadData);
needRedraw = true;
}
glFinish(); //we can look probably at using a fence here //Seems a SAMSUNG change
} else {
GLuint textureId = manager->getTextureId(uniqueId());
GLfloat* matrix = manager->getMatrix(uniqueId());
if (textureId && matrix) {
// Show the screen shot for each video.
shader->drawVideoLayerQuad(m_drawTransform, matrix,
videoRect, textureId);
} else {
// Show the static poster b/c there is no screen shot available.
pureColorQuadData.updateColor(Color(128, 128, 128, 255));
shader->drawQuad(&pureColorQuadData);
iconQuadData.updateTextureId(manager->getPosterTextureId());
iconQuadData.updateOpacity(1.0);
shader->drawQuad(&iconQuadData);
}
// Use the scale to control the fading and the sizing during animation.
double scale = manager->drawIcon(uniqueId(), PauseIcon);
if (scale) {
innerRect.inset(manager->getButtonSize() / 4 * scale,
manager->getButtonSize() / 4 * scale);
//.........这里部分代码省略.........