Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "third_party/khronos/GLES2/gl2.h" | 22 #include "third_party/khronos/GLES2/gl2.h" |
| 23 #include "third_party/khronos/GLES2/gl2ext.h" | 23 #include "third_party/khronos/GLES2/gl2ext.h" |
| 24 #include "ui/gfx/geometry/size_conversions.h" | 24 #include "ui/gfx/geometry/size_conversions.h" |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const ResourceFormat kRGBResourceFormat = RGBA_8888; | 30 const ResourceFormat kRGBResourceFormat = RGBA_8888; |
| 31 | 31 |
| 32 // This key is used to mark the userdata in VideoFrame to indicate that its | |
| 33 // content has been cached in VideoResourceUpdater. | |
| 34 const char kResourceUploadedKey[] = "ResourceUploadedFlag"; | |
| 35 | |
| 32 VideoFrameExternalResources::ResourceType ResourceTypeForVideoFrame( | 36 VideoFrameExternalResources::ResourceType ResourceTypeForVideoFrame( |
| 33 media::VideoFrame* video_frame) { | 37 media::VideoFrame* video_frame) { |
| 34 switch (video_frame->format()) { | 38 switch (video_frame->format()) { |
| 35 case media::PIXEL_FORMAT_ARGB: | 39 case media::PIXEL_FORMAT_ARGB: |
| 36 case media::PIXEL_FORMAT_XRGB: | 40 case media::PIXEL_FORMAT_XRGB: |
| 37 case media::PIXEL_FORMAT_UYVY: | 41 case media::PIXEL_FORMAT_UYVY: |
| 38 switch (video_frame->mailbox_holder(0).texture_target) { | 42 switch (video_frame->mailbox_holder(0).texture_target) { |
| 39 case GL_TEXTURE_2D: | 43 case GL_TEXTURE_2D: |
| 40 return (video_frame->format() == media::PIXEL_FORMAT_XRGB) | 44 return (video_frame->format() == media::PIXEL_FORMAT_XRGB) |
| 41 ? VideoFrameExternalResources::RGB_RESOURCE | 45 ? VideoFrameExternalResources::RGB_RESOURCE |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 frame_ptr(nullptr), | 131 frame_ptr(nullptr), |
| 128 plane_index(0u) { | 132 plane_index(0u) { |
| 129 } | 133 } |
| 130 | 134 |
| 131 bool VideoResourceUpdater::PlaneResourceMatchesUniqueID( | 135 bool VideoResourceUpdater::PlaneResourceMatchesUniqueID( |
| 132 const PlaneResource& plane_resource, | 136 const PlaneResource& plane_resource, |
| 133 const media::VideoFrame* video_frame, | 137 const media::VideoFrame* video_frame, |
| 134 size_t plane_index) { | 138 size_t plane_index) { |
| 135 return plane_resource.frame_ptr == video_frame && | 139 return plane_resource.frame_ptr == video_frame && |
| 136 plane_resource.plane_index == plane_index && | 140 plane_resource.plane_index == plane_index && |
| 137 plane_resource.timestamp == video_frame->timestamp(); | 141 plane_resource.timestamp == video_frame->timestamp() && |
|
danakj
2016/02/23 23:55:09
Can you instead just return false if the timestamp
xjz
2016/02/24 00:01:28
The actual timestamp could be 0. It is difficult t
danakj
2016/02/24 00:07:08
Oh :/ I don't really like cc setting things on a V
xjz
2016/02/24 21:57:58
This sounds equivalent to asking decoders correctl
| |
| 142 video_frame->GetUserData(kResourceUploadedKey); | |
| 138 } | 143 } |
| 139 | 144 |
| 140 void VideoResourceUpdater::SetPlaneResourceUniqueId( | 145 void VideoResourceUpdater::SetPlaneResourceUniqueId( |
| 141 const media::VideoFrame* video_frame, | 146 media::VideoFrame* video_frame, |
| 142 size_t plane_index, | 147 size_t plane_index, |
| 143 PlaneResource* plane_resource) { | 148 PlaneResource* plane_resource) { |
| 144 plane_resource->frame_ptr = video_frame; | 149 plane_resource->frame_ptr = video_frame; |
| 145 plane_resource->plane_index = plane_index; | 150 plane_resource->plane_index = plane_index; |
| 146 plane_resource->timestamp = video_frame->timestamp(); | 151 plane_resource->timestamp = video_frame->timestamp(); |
| 152 video_frame->SetUserData(kResourceUploadedKey, | |
| 153 new base::SupportsUserData::Data()); | |
| 147 } | 154 } |
| 148 | 155 |
| 149 VideoFrameExternalResources::VideoFrameExternalResources() | 156 VideoFrameExternalResources::VideoFrameExternalResources() |
| 150 : type(NONE), | 157 : type(NONE), |
| 151 read_lock_fences_enabled(false), | 158 read_lock_fences_enabled(false), |
| 152 offset(0.0f), | 159 offset(0.0f), |
| 153 multiplier(1.0f) {} | 160 multiplier(1.0f) {} |
| 154 | 161 |
| 155 VideoFrameExternalResources::~VideoFrameExternalResources() {} | 162 VideoFrameExternalResources::~VideoFrameExternalResources() {} |
| 156 | 163 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 resource_it->ref_count = 0; | 688 resource_it->ref_count = 0; |
| 682 updater->DeleteResource(resource_it); | 689 updater->DeleteResource(resource_it); |
| 683 return; | 690 return; |
| 684 } | 691 } |
| 685 | 692 |
| 686 --resource_it->ref_count; | 693 --resource_it->ref_count; |
| 687 DCHECK_GE(resource_it->ref_count, 0); | 694 DCHECK_GE(resource_it->ref_count, 0); |
| 688 } | 695 } |
| 689 | 696 |
| 690 } // namespace cc | 697 } // namespace cc |
| OLD | NEW |