| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/buffers.h" | 5 #include "media/base/buffers.h" |
| 6 #include "media/base/yuv_convert.h" | 6 #include "media/base/yuv_convert.h" |
| 7 #include "webkit/glue/media/video_renderer_impl.h" | 7 #include "webkit/glue/media/video_renderer_impl.h" |
| 8 #include "webkit/glue/webmediaplayer_impl.h" | 8 #include "webkit/glue/webmediaplayer_impl.h" |
| 9 | 9 |
| 10 namespace webkit_glue { | 10 namespace webkit_glue { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 FastPaint(video_frame, canvas, dest_rect); | 64 FastPaint(video_frame, canvas, dest_rect); |
| 65 } else { | 65 } else { |
| 66 SlowPaint(video_frame, canvas, dest_rect); | 66 SlowPaint(video_frame, canvas, dest_rect); |
| 67 } | 67 } |
| 68 video_frame = NULL; | 68 video_frame = NULL; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 // CanFastPaint is a helper method to determine the conditions for fast | 72 // CanFastPaint is a helper method to determine the conditions for fast |
| 73 // painting. The conditions are: | 73 // painting. The conditions are: |
| 74 // 1. No skew in canvas matrix. | 74 // 1. No skew in canvas matrix. |
| 75 // 2. Canvas has pixel format ARGB8888. | 75 // 2. No flipping nor mirroring. |
| 76 // 3. Canvas is opaque. | 76 // 3. Canvas has pixel format ARGB8888. |
| 77 // 4. Canvas is opaque. |
| 78 // TODO(hclam): The fast paint method should support flipping and mirroring. |
| 79 // Disable the flipping and mirroring checks once we have it. |
| 77 bool VideoRendererImpl::CanFastPaint(skia::PlatformCanvas* canvas, | 80 bool VideoRendererImpl::CanFastPaint(skia::PlatformCanvas* canvas, |
| 78 const gfx::Rect& dest_rect) { | 81 const gfx::Rect& dest_rect) { |
| 79 const SkMatrix& total_matrix = canvas->getTotalMatrix(); | 82 const SkMatrix& total_matrix = canvas->getTotalMatrix(); |
| 83 // Perform the following checks here: |
| 84 // 1. Check for skewing factors of the transformation matrix. They should be |
| 85 // zero. |
| 86 // 2. Check for mirroring and flipping. Make sure they are greater than zero. |
| 80 if (SkScalarNearlyZero(total_matrix.getSkewX()) && | 87 if (SkScalarNearlyZero(total_matrix.getSkewX()) && |
| 81 SkScalarNearlyZero(total_matrix.getSkewY())) { | 88 SkScalarNearlyZero(total_matrix.getSkewY()) && |
| 89 total_matrix.getScaleX() > 0 && |
| 90 total_matrix.getScaleY() > 0) { |
| 82 // Get the properties of the SkDevice and the clip rect. | 91 // Get the properties of the SkDevice and the clip rect. |
| 83 SkDevice* device = canvas->getDevice(); | 92 SkDevice* device = canvas->getDevice(); |
| 84 | 93 |
| 85 // Get the boundary of the device. | 94 // Get the boundary of the device. |
| 86 SkIRect device_rect; | 95 SkIRect device_rect; |
| 87 device->getBounds(&device_rect); | 96 device->getBounds(&device_rect); |
| 88 | 97 |
| 89 // Get the pixel config of the device. | 98 // Get the pixel config of the device. |
| 90 const SkBitmap::Config config = device->config(); | 99 const SkBitmap::Config config = device->config(); |
| 91 // Get the total clip rect associated with the canvas. | 100 // Get the total clip rect associated with the canvas. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Transform destination rect to local coordinates. | 279 // Transform destination rect to local coordinates. |
| 271 SkRect transformed_rect; | 280 SkRect transformed_rect; |
| 272 SkRect skia_dest_rect; | 281 SkRect skia_dest_rect; |
| 273 skia_dest_rect.iset(src_rect.x(), src_rect.y(), | 282 skia_dest_rect.iset(src_rect.x(), src_rect.y(), |
| 274 src_rect.right(), src_rect.bottom()); | 283 src_rect.right(), src_rect.bottom()); |
| 275 matrix.mapRect(&transformed_rect, skia_dest_rect); | 284 matrix.mapRect(&transformed_rect, skia_dest_rect); |
| 276 transformed_rect.round(dest_rect); | 285 transformed_rect.round(dest_rect); |
| 277 } | 286 } |
| 278 | 287 |
| 279 } // namespace webkit_glue | 288 } // namespace webkit_glue |
| OLD | NEW |