OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/software_renderer.h" | 7 #include "cc/software_renderer.h" |
8 | 8 |
9 #include "cc/debug_border_draw_quad.h" | 9 #include "cc/debug_border_draw_quad.h" |
10 #include "cc/render_pass_draw_quad.h" | 10 #include "cc/render_pass_draw_quad.h" |
11 #include "cc/solid_color_draw_quad.h" | 11 #include "cc/solid_color_draw_quad.h" |
12 #include "cc/texture_draw_quad.h" | 12 #include "cc/texture_draw_quad.h" |
13 #include "cc/tile_draw_quad.h" | 13 #include "cc/tile_draw_quad.h" |
| 14 #include "cc/video_frame_draw_quad.h" |
| 15 #include "media/filters/skcanvas_video_renderer.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
16 #include "third_party/skia/include/core/SkMatrix.h" | 18 #include "third_party/skia/include/core/SkMatrix.h" |
17 #include "third_party/skia/include/core/SkShader.h" | 19 #include "third_party/skia/include/core/SkShader.h" |
18 #include "third_party/skia/include/effects/SkLayerRasterizer.h" | 20 #include "third_party/skia/include/effects/SkLayerRasterizer.h" |
19 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
| 22 #include <public/WebCompositorSoftwareOutputDevice.h> |
20 #include <public/WebImage.h> | 23 #include <public/WebImage.h> |
21 #include <public/WebSize.h> | 24 #include <public/WebSize.h> |
22 #include <public/WebTransformationMatrix.h> | 25 #include <public/WebTransformationMatrix.h> |
23 | 26 |
24 using WebKit::WebCompositorSoftwareOutputDevice; | 27 using WebKit::WebCompositorSoftwareOutputDevice; |
25 using WebKit::WebImage; | |
26 using WebKit::WebSize; | 28 using WebKit::WebSize; |
27 using WebKit::WebTransformationMatrix; | 29 using WebKit::WebTransformationMatrix; |
28 | 30 |
29 namespace cc { | 31 namespace cc { |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 SkRect toSkRect(const gfx::RectF& rect) | 35 SkRect toSkRect(const gfx::RectF& rect) |
34 { | 36 { |
35 return SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()); | 37 return SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 break; | 210 break; |
209 case DrawQuad::TextureContent: | 211 case DrawQuad::TextureContent: |
210 drawTextureQuad(frame, TextureDrawQuad::materialCast(quad)); | 212 drawTextureQuad(frame, TextureDrawQuad::materialCast(quad)); |
211 break; | 213 break; |
212 case DrawQuad::TiledContent: | 214 case DrawQuad::TiledContent: |
213 drawTileQuad(frame, TileDrawQuad::materialCast(quad)); | 215 drawTileQuad(frame, TileDrawQuad::materialCast(quad)); |
214 break; | 216 break; |
215 case DrawQuad::RenderPass: | 217 case DrawQuad::RenderPass: |
216 drawRenderPassQuad(frame, RenderPassDrawQuad::materialCast(quad)); | 218 drawRenderPassQuad(frame, RenderPassDrawQuad::materialCast(quad)); |
217 break; | 219 break; |
| 220 case DrawQuad::VideoFrameContent: |
| 221 drawVideoFrameQuad(frame, VideoFrameDrawQuad::materialCast(quad)); |
| 222 break; |
218 default: | 223 default: |
219 drawUnsupportedQuad(frame, quad); | 224 drawUnsupportedQuad(frame, quad); |
220 break; | 225 break; |
221 } | 226 } |
222 | 227 |
223 m_skCurrentCanvas->resetMatrix(); | 228 m_skCurrentCanvas->resetMatrix(); |
224 } | 229 } |
225 | 230 |
226 void SoftwareRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const Debu
gBorderDrawQuad* quad) | 231 void SoftwareRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const Debu
gBorderDrawQuad* quad) |
227 { | 232 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 maskRasterizer->addLayer(maskPaint); | 322 maskRasterizer->addLayer(maskPaint); |
318 | 323 |
319 m_skCurrentPaint.setRasterizer(maskRasterizer); | 324 m_skCurrentPaint.setRasterizer(maskRasterizer); |
320 m_skCurrentCanvas->drawRect(destRect, m_skCurrentPaint); | 325 m_skCurrentCanvas->drawRect(destRect, m_skCurrentPaint); |
321 } else { | 326 } else { |
322 // FIXME: Apply background filters and blend with contents | 327 // FIXME: Apply background filters and blend with contents |
323 m_skCurrentCanvas->drawRect(destRect, m_skCurrentPaint); | 328 m_skCurrentCanvas->drawRect(destRect, m_skCurrentPaint); |
324 } | 329 } |
325 } | 330 } |
326 | 331 |
| 332 void SoftwareRenderer::drawVideoFrameQuad(const DrawingFrame& frame, const Video
FrameDrawQuad* quad) |
| 333 { |
| 334 if (!m_videoRenderer) |
| 335 m_videoRenderer.reset(new media::SkCanvasVideoRenderer); |
| 336 m_videoRenderer->Paint(quad->frame(), m_skCurrentCanvas, quadVertexRect(), |
| 337 quad->opacity() * 255); |
| 338 } |
| 339 |
327 void SoftwareRenderer::drawUnsupportedQuad(const DrawingFrame& frame, const Draw
Quad* quad) | 340 void SoftwareRenderer::drawUnsupportedQuad(const DrawingFrame& frame, const Draw
Quad* quad) |
328 { | 341 { |
329 m_skCurrentPaint.setColor(SK_ColorMAGENTA); | 342 m_skCurrentPaint.setColor(SK_ColorMAGENTA); |
330 m_skCurrentPaint.setAlpha(quad->opacity() * 255); | 343 m_skCurrentPaint.setAlpha(quad->opacity() * 255); |
331 m_skCurrentCanvas->drawRect(toSkRect(quadVertexRect()), m_skCurrentPaint); | 344 m_skCurrentCanvas->drawRect(toSkRect(quadVertexRect()), m_skCurrentPaint); |
332 } | 345 } |
333 | 346 |
334 bool SoftwareRenderer::swapBuffers() | 347 bool SoftwareRenderer::swapBuffers() |
335 { | 348 { |
336 if (Proxy::hasImplThread()) | 349 if (Proxy::hasImplThread()) |
(...skipping 12 matching lines...) Expand all Loading... |
349 } | 362 } |
350 | 363 |
351 void SoftwareRenderer::setVisible(bool visible) | 364 void SoftwareRenderer::setVisible(bool visible) |
352 { | 365 { |
353 if (m_visible == visible) | 366 if (m_visible == visible) |
354 return; | 367 return; |
355 m_visible = visible; | 368 m_visible = visible; |
356 } | 369 } |
357 | 370 |
358 } | 371 } |
OLD | NEW |