| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/video_layer_impl.h" | 5 #include "cc/video_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/io_surface_draw_quad.h" | 8 #include "cc/io_surface_draw_quad.h" |
| 9 #include "cc/layer_tree_host_impl.h" | 9 #include "cc/layer_tree_host_impl.h" |
| 10 #include "cc/quad_sink.h" | 10 #include "cc/quad_sink.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 if (!m_frame) | 193 if (!m_frame) |
| 194 return; | 194 return; |
| 195 | 195 |
| 196 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); | 196 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
| 197 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 197 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 198 | 198 |
| 199 // FIXME: When we pass quads out of process, we need to double-buffer, or | 199 // FIXME: When we pass quads out of process, we need to double-buffer, or |
| 200 // otherwise synchonize use of all textures in the quad. | 200 // otherwise synchonize use of all textures in the quad. |
| 201 | 201 |
| 202 gfx::Rect quadRect(gfx::Point(), contentBounds()); | 202 gfx::Rect quadRect(gfx::Point(), contentBounds()); |
| 203 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); |
| 203 gfx::Rect visibleRect = m_frame->visible_rect(); | 204 gfx::Rect visibleRect = m_frame->visible_rect(); |
| 204 gfx::Size codedSize = m_frame->coded_size(); | 205 gfx::Size codedSize = m_frame->coded_size(); |
| 205 | 206 |
| 206 // pixels for macroblocked formats. | 207 // pixels for macroblocked formats. |
| 207 const float texWidthScale = | 208 const float texWidthScale = |
| 208 static_cast<float>(visibleRect.width()) / codedSize.width(); | 209 static_cast<float>(visibleRect.width()) / codedSize.width(); |
| 209 const float texHeightScale = | 210 const float texHeightScale = |
| 210 static_cast<float>(visibleRect.height()) / codedSize.height(); | 211 static_cast<float>(visibleRect.height()) / codedSize.height(); |
| 211 | 212 |
| 212 switch (m_format) { | 213 switch (m_format) { |
| 213 case GL_LUMINANCE: { | 214 case GL_LUMINANCE: { |
| 214 // YUV software decoder. | 215 // YUV software decoder. |
| 215 const FramePlane& yPlane = m_framePlanes[media::VideoFrame::kYPlane]; | 216 const FramePlane& yPlane = m_framePlanes[media::VideoFrame::kYPlane]; |
| 216 const FramePlane& uPlane = m_framePlanes[media::VideoFrame::kUPlane]; | 217 const FramePlane& uPlane = m_framePlanes[media::VideoFrame::kUPlane]; |
| 217 const FramePlane& vPlane = m_framePlanes[media::VideoFrame::kVPlane]; | 218 const FramePlane& vPlane = m_framePlanes[media::VideoFrame::kVPlane]; |
| 218 gfx::SizeF texScale(texWidthScale, texHeightScale); | 219 gfx::SizeF texScale(texWidthScale, texHeightScale); |
| 219 scoped_ptr<YUVVideoDrawQuad> yuvVideoQuad = YUVVideoDrawQuad::create( | 220 scoped_ptr<YUVVideoDrawQuad> yuvVideoQuad = YUVVideoDrawQuad::create( |
| 220 sharedQuadState, quadRect, texScale, yPlane, uPlane, vPlane); | 221 sharedQuadState, quadRect, opaqueRect, texScale, yPlane, uPlane, vPl
ane); |
| 221 quadSink.append(yuvVideoQuad.PassAs<DrawQuad>(), appendQuadsData); | 222 quadSink.append(yuvVideoQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 222 break; | 223 break; |
| 223 } | 224 } |
| 224 case GL_RGBA: { | 225 case GL_RGBA: { |
| 225 // RGBA software decoder. | 226 // RGBA software decoder. |
| 226 const FramePlane& plane = m_framePlanes[media::VideoFrame::kRGBPlane]; | 227 const FramePlane& plane = m_framePlanes[media::VideoFrame::kRGBPlane]; |
| 227 bool premultipliedAlpha = true; | 228 bool premultipliedAlpha = true; |
| 228 gfx::RectF uvRect(0, 0, texWidthScale, texHeightScale); | 229 gfx::RectF uvRect(0, 0, texWidthScale, texHeightScale); |
| 229 bool flipped = false; | 230 bool flipped = false; |
| 230 scoped_ptr<TextureDrawQuad> textureQuad = TextureDrawQuad::create(shared
QuadState, quadRect, plane.resourceId, premultipliedAlpha, uvRect, flipped); | 231 scoped_ptr<TextureDrawQuad> textureQuad = TextureDrawQuad::create(shared
QuadState, quadRect, opaqueRect, plane.resourceId, premultipliedAlpha, uvRect, f
lipped); |
| 231 quadSink.append(textureQuad.PassAs<DrawQuad>(), appendQuadsData); | 232 quadSink.append(textureQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 232 break; | 233 break; |
| 233 } | 234 } |
| 234 case GL_TEXTURE_2D: { | 235 case GL_TEXTURE_2D: { |
| 235 // NativeTexture hardware decoder. | 236 // NativeTexture hardware decoder. |
| 236 bool premultipliedAlpha = true; | 237 bool premultipliedAlpha = true; |
| 237 gfx::RectF uvRect(0, 0, texWidthScale, texHeightScale); | 238 gfx::RectF uvRect(0, 0, texWidthScale, texHeightScale); |
| 238 bool flipped = false; | 239 bool flipped = false; |
| 239 scoped_ptr<TextureDrawQuad> textureQuad = TextureDrawQuad::create(shared
QuadState, quadRect, m_externalTextureResource, premultipliedAlpha, uvRect, flip
ped); | 240 scoped_ptr<TextureDrawQuad> textureQuad = TextureDrawQuad::create(shared
QuadState, quadRect, opaqueRect, m_externalTextureResource, premultipliedAlpha,
uvRect, flipped); |
| 240 quadSink.append(textureQuad.PassAs<DrawQuad>(), appendQuadsData); | 241 quadSink.append(textureQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 241 break; | 242 break; |
| 242 } | 243 } |
| 243 case GL_TEXTURE_RECTANGLE_ARB: { | 244 case GL_TEXTURE_RECTANGLE_ARB: { |
| 244 gfx::Size visibleSize(visibleRect.width(), visibleRect.height()); | 245 gfx::Size visibleSize(visibleRect.width(), visibleRect.height()); |
| 245 scoped_ptr<IOSurfaceDrawQuad> ioSurfaceQuad = IOSurfaceDrawQuad::create(
sharedQuadState, quadRect, visibleSize, m_frame->texture_id(), IOSurfaceDrawQuad
::Unflipped); | 246 scoped_ptr<IOSurfaceDrawQuad> ioSurfaceQuad = IOSurfaceDrawQuad::create(
sharedQuadState, quadRect, opaqueRect, visibleSize, m_frame->texture_id(), IOSur
faceDrawQuad::Unflipped); |
| 246 quadSink.append(ioSurfaceQuad.PassAs<DrawQuad>(), appendQuadsData); | 247 quadSink.append(ioSurfaceQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 247 break; | 248 break; |
| 248 } | 249 } |
| 249 case GL_TEXTURE_EXTERNAL_OES: { | 250 case GL_TEXTURE_EXTERNAL_OES: { |
| 250 // StreamTexture hardware decoder. | 251 // StreamTexture hardware decoder. |
| 251 WebKit::WebTransformationMatrix transform(m_streamTextureMatrix); | 252 WebKit::WebTransformationMatrix transform(m_streamTextureMatrix); |
| 252 transform.scaleNonUniform(texWidthScale, texHeightScale); | 253 transform.scaleNonUniform(texWidthScale, texHeightScale); |
| 253 scoped_ptr<StreamVideoDrawQuad> streamVideoQuad = | 254 scoped_ptr<StreamVideoDrawQuad> streamVideoQuad = |
| 254 StreamVideoDrawQuad::create(sharedQuadState, quadRect, | 255 StreamVideoDrawQuad::create(sharedQuadState, quadRect, opaqueRect, |
| 255 m_frame->texture_id(), | 256 m_frame->texture_id(), |
| 256 transform); | 257 transform); |
| 257 quadSink.append(streamVideoQuad.PassAs<DrawQuad>(), appendQuadsData); | 258 quadSink.append(streamVideoQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 258 break; | 259 break; |
| 259 } | 260 } |
| 260 default: | 261 default: |
| 261 NOTREACHED(); // Someone updated convertVFCFormatToGLenum above but upd
ate this! | 262 NOTREACHED(); // Someone updated convertVFCFormatToGLenum above but upd
ate this! |
| 262 break; | 263 break; |
| 263 } | 264 } |
| 264 } | 265 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 { | 416 { |
| 416 layerTreeHostImpl()->setNeedsRedraw(); | 417 layerTreeHostImpl()->setNeedsRedraw(); |
| 417 } | 418 } |
| 418 | 419 |
| 419 const char* VideoLayerImpl::layerTypeAsString() const | 420 const char* VideoLayerImpl::layerTypeAsString() const |
| 420 { | 421 { |
| 421 return "VideoLayer"; | 422 return "VideoLayer"; |
| 422 } | 423 } |
| 423 | 424 |
| 424 } // namespace cc | 425 } // namespace cc |
| OLD | NEW |