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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); | 133 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); |
134 res->SetInteger("renderer_pid", channel->renderer_pid()); | 134 res->SetInteger("renderer_pid", channel->renderer_pid()); |
135 res->SetDouble("used_bytes", channel->GetMemoryUsage()); | 135 res->SetDouble("used_bytes", channel->GetMemoryUsage()); |
136 res->SetDouble("limit_bytes", | 136 res->SetDouble("limit_bytes", |
137 channel->gpu_channel_manager() | 137 channel->gpu_channel_manager() |
138 ->gpu_memory_manager() | 138 ->gpu_memory_manager() |
139 ->GetMaximumClientAllocation()); | 139 ->GetMaximumClientAllocation()); |
140 return new DevToolsChannelData(res.release()); | 140 return new DevToolsChannelData(res.release()); |
141 } | 141 } |
142 | 142 |
| 143 bool IsSupportedImageFormat(const gpu::Capabilities& capabilities, |
| 144 gfx::GpuMemoryBuffer::Format format) { |
| 145 switch (format) { |
| 146 case gfx::GpuMemoryBuffer::ATC: |
| 147 case gfx::GpuMemoryBuffer::ATCIA: |
| 148 return capabilities.texture_format_atc; |
| 149 case gfx::GpuMemoryBuffer::BGRA_8888: |
| 150 return capabilities.texture_format_bgra8888; |
| 151 case gfx::GpuMemoryBuffer::DXT1: |
| 152 return capabilities.texture_format_dxt1; |
| 153 case gfx::GpuMemoryBuffer::DXT5: |
| 154 return capabilities.texture_format_dxt5; |
| 155 case gfx::GpuMemoryBuffer::ETC1: |
| 156 return capabilities.texture_format_etc1; |
| 157 case gfx::GpuMemoryBuffer::RGBA_8888: |
| 158 case gfx::GpuMemoryBuffer::RGBX_8888: |
| 159 return true; |
| 160 } |
| 161 |
| 162 NOTREACHED(); |
| 163 return false; |
| 164 } |
| 165 |
143 } // namespace | 166 } // namespace |
144 | 167 |
145 GpuCommandBufferStub::GpuCommandBufferStub( | 168 GpuCommandBufferStub::GpuCommandBufferStub( |
146 GpuChannel* channel, | 169 GpuChannel* channel, |
147 GpuCommandBufferStub* share_group, | 170 GpuCommandBufferStub* share_group, |
148 const gfx::GLSurfaceHandle& handle, | 171 const gfx::GLSurfaceHandle& handle, |
149 gpu::gles2::MailboxManager* mailbox_manager, | 172 gpu::gles2::MailboxManager* mailbox_manager, |
150 gpu::gles2::SubscriptionRefSet* subscription_ref_set, | 173 gpu::gles2::SubscriptionRefSet* subscription_ref_set, |
151 gpu::ValueStateMap* pending_valuebuffer_state, | 174 gpu::ValueStateMap* pending_valuebuffer_state, |
152 const gfx::Size& size, | 175 const gfx::Size& size, |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 if (!decoder_) | 972 if (!decoder_) |
950 return; | 973 return; |
951 | 974 |
952 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 975 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
953 DCHECK(image_manager); | 976 DCHECK(image_manager); |
954 if (image_manager->LookupImage(id)) { | 977 if (image_manager->LookupImage(id)) { |
955 LOG(ERROR) << "Image already exists with same ID."; | 978 LOG(ERROR) << "Image already exists with same ID."; |
956 return; | 979 return; |
957 } | 980 } |
958 | 981 |
| 982 if (!IsSupportedImageFormat(decoder_->GetCapabilities(), format)) { |
| 983 LOG(ERROR) << "Image format is not supported."; |
| 984 return; |
| 985 } |
| 986 |
959 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer( | 987 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer( |
960 handle, size, format, internalformat); | 988 handle, size, format, internalformat); |
961 if (!image.get()) | 989 if (!image.get()) |
962 return; | 990 return; |
963 | 991 |
964 image_manager->AddImage(image.get(), id); | 992 image_manager->AddImage(image.get(), id); |
965 } | 993 } |
966 | 994 |
967 void GpuCommandBufferStub::OnDestroyImage(int32 id) { | 995 void GpuCommandBufferStub::OnDestroyImage(int32 id) { |
968 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage"); | 996 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage"); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); | 1111 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); |
1084 } | 1112 } |
1085 | 1113 |
1086 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1114 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1087 base::TimeDelta interval) { | 1115 base::TimeDelta interval) { |
1088 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1116 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1089 interval)); | 1117 interval)); |
1090 } | 1118 } |
1091 | 1119 |
1092 } // namespace content | 1120 } // namespace content |
OLD | NEW |