| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 5 #ifndef MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
| 6 #define MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 6 #define MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 unsigned int type, | 92 unsigned int type, |
| 93 bool premultiply_alpha, | 93 bool premultiply_alpha, |
| 94 bool flip_y); | 94 bool flip_y); |
| 95 | 95 |
| 96 // In general, We hold the most recently painted frame to increase the | 96 // In general, We hold the most recently painted frame to increase the |
| 97 // performance for the case that the same frame needs to be painted | 97 // performance for the case that the same frame needs to be painted |
| 98 // repeatedly. Call this function if you are sure the most recent frame will | 98 // repeatedly. Call this function if you are sure the most recent frame will |
| 99 // never be painted again, so we can release the resource. | 99 // never be painted again, so we can release the resource. |
| 100 void ResetCache(); | 100 void ResetCache(); |
| 101 | 101 |
| 102 void CorrectLastImageDimensions(const SkIRect& visible_rect); |
| 103 |
| 104 // Used for unit test. |
| 105 SkISize LastImageDimensionsForTesting(); |
| 106 |
| 102 private: | 107 private: |
| 103 // Update the cache holding the most-recently-painted frame. Returns false | 108 // Update the cache holding the most-recently-painted frame. Returns false |
| 104 // if the image couldn't be updated. | 109 // if the image couldn't be updated. |
| 105 bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame, | 110 bool UpdateLastImage(const scoped_refptr<VideoFrame>& video_frame, |
| 106 const Context3D& context_3d); | 111 const Context3D& context_3d); |
| 107 | 112 |
| 108 // Last image used to draw to the canvas. | 113 // Last image used to draw to the canvas. |
| 109 sk_sp<SkImage> last_image_; | 114 sk_sp<SkImage> last_image_; |
| 110 // Timestamp of the videoframe used to generate |last_image_|. | 115 // Timestamp of the videoframe used to generate |last_image_|. |
| 111 base::TimeDelta last_timestamp_ = media::kNoTimestamp; | 116 base::TimeDelta last_timestamp_ = media::kNoTimestamp; |
| 112 // If |last_image_| is not used for a while, it's deleted to save memory. | 117 // If |last_image_| is not used for a while, it's deleted to save memory. |
| 113 base::DelayTimer last_image_deleting_timer_; | 118 base::DelayTimer last_image_deleting_timer_; |
| 114 | 119 |
| 115 // Used for DCHECKs to ensure method calls executed in the correct thread. | 120 // Used for DCHECKs to ensure method calls executed in the correct thread. |
| 116 base::ThreadChecker thread_checker_; | 121 base::ThreadChecker thread_checker_; |
| 117 | 122 |
| 123 // Used for unit test. |
| 124 SkISize last_image_dimensions_for_testing_; |
| 125 |
| 118 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 126 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
| 119 }; | 127 }; |
| 120 | 128 |
| 121 } // namespace media | 129 } // namespace media |
| 122 | 130 |
| 123 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 131 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
| OLD | NEW |