Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 968283002: content: Remove use of GLImage from GpuMemoryBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add size check to gmb code Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/common/gpu/gpu_channel.h" 14 #include "content/common/gpu/gpu_channel.h"
15 #include "content/common/gpu/gpu_channel_manager.h" 15 #include "content/common/gpu/gpu_channel_manager.h"
16 #include "content/common/gpu/gpu_command_buffer_stub.h" 16 #include "content/common/gpu/gpu_command_buffer_stub.h"
17 #include "content/common/gpu/gpu_memory_manager.h" 17 #include "content/common/gpu/gpu_memory_manager.h"
18 #include "content/common/gpu/gpu_memory_tracking.h" 18 #include "content/common/gpu/gpu_memory_tracking.h"
19 #include "content/common/gpu/gpu_messages.h" 19 #include "content/common/gpu/gpu_messages.h"
20 #include "content/common/gpu/gpu_watchdog.h" 20 #include "content/common/gpu/gpu_watchdog.h"
21 #include "content/common/gpu/image_transport_surface.h" 21 #include "content/common/gpu/image_transport_surface.h"
22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" 23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
24 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
25 #include "gpu/command_buffer/common/constants.h" 25 #include "gpu/command_buffer/common/constants.h"
26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
27 #include "gpu/command_buffer/common/mailbox.h" 27 #include "gpu/command_buffer/common/mailbox.h"
28 #include "gpu/command_buffer/service/gl_context_virtual.h" 28 #include "gpu/command_buffer/service/gl_context_virtual.h"
29 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 29 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
30 #include "gpu/command_buffer/service/image_factory.h"
30 #include "gpu/command_buffer/service/image_manager.h" 31 #include "gpu/command_buffer/service/image_manager.h"
31 #include "gpu/command_buffer/service/logger.h" 32 #include "gpu/command_buffer/service/logger.h"
32 #include "gpu/command_buffer/service/mailbox_manager.h" 33 #include "gpu/command_buffer/service/mailbox_manager.h"
33 #include "gpu/command_buffer/service/memory_tracking.h" 34 #include "gpu/command_buffer/service/memory_tracking.h"
34 #include "gpu/command_buffer/service/query_manager.h" 35 #include "gpu/command_buffer/service/query_manager.h"
35 #include "gpu/command_buffer/service/sync_point_manager.h" 36 #include "gpu/command_buffer/service/sync_point_manager.h"
36 #include "gpu/command_buffer/service/valuebuffer_manager.h" 37 #include "gpu/command_buffer/service/valuebuffer_manager.h"
37 #include "ui/gl/gl_bindings.h" 38 #include "ui/gl/gl_bindings.h"
38 #include "ui/gl/gl_switches.h" 39 #include "ui/gl/gl_switches.h"
39 40
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); 134 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue);
134 res->SetInteger("renderer_pid", channel->renderer_pid()); 135 res->SetInteger("renderer_pid", channel->renderer_pid());
135 res->SetDouble("used_bytes", channel->GetMemoryUsage()); 136 res->SetDouble("used_bytes", channel->GetMemoryUsage());
136 res->SetDouble("limit_bytes", 137 res->SetDouble("limit_bytes",
137 channel->gpu_channel_manager() 138 channel->gpu_channel_manager()
138 ->gpu_memory_manager() 139 ->gpu_memory_manager()
139 ->GetMaximumClientAllocation()); 140 ->GetMaximumClientAllocation());
140 return new DevToolsChannelData(res.release()); 141 return new DevToolsChannelData(res.release());
141 } 142 }
142 143
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
166 } // namespace 144 } // namespace
167 145
168 GpuCommandBufferStub::GpuCommandBufferStub( 146 GpuCommandBufferStub::GpuCommandBufferStub(
169 GpuChannel* channel, 147 GpuChannel* channel,
170 GpuCommandBufferStub* share_group, 148 GpuCommandBufferStub* share_group,
171 const gfx::GLSurfaceHandle& handle, 149 const gfx::GLSurfaceHandle& handle,
172 gpu::gles2::MailboxManager* mailbox_manager, 150 gpu::gles2::MailboxManager* mailbox_manager,
173 gpu::gles2::SubscriptionRefSet* subscription_ref_set, 151 gpu::gles2::SubscriptionRefSet* subscription_ref_set,
174 gpu::ValueStateMap* pending_valuebuffer_state, 152 gpu::ValueStateMap* pending_valuebuffer_state,
175 const gfx::Size& size, 153 const gfx::Size& size,
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 if (!decoder_) 950 if (!decoder_)
973 return; 951 return;
974 952
975 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 953 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
976 DCHECK(image_manager); 954 DCHECK(image_manager);
977 if (image_manager->LookupImage(id)) { 955 if (image_manager->LookupImage(id)) {
978 LOG(ERROR) << "Image already exists with same ID."; 956 LOG(ERROR) << "Image already exists with same ID.";
979 return; 957 return;
980 } 958 }
981 959
982 if (!IsSupportedImageFormat(decoder_->GetCapabilities(), format)) { 960 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported(
983 LOG(ERROR) << "Image format is not supported."; 961 format, decoder_->GetCapabilities())) {
962 LOG(ERROR) << "Format is not supported.";
984 return; 963 return;
985 } 964 }
986 965
966 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(size,
967 format)) {
968 LOG(ERROR) << "Invalid image size for format.";
969 return;
970 }
971
972 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
973 internalformat, format)) {
974 LOG(ERROR) << "Incompatible image format.";
975 return;
976 }
977
987 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer( 978 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer(
988 handle, size, format, internalformat); 979 handle, size, format, internalformat);
989 if (!image.get()) 980 if (!image.get())
990 return; 981 return;
991 982
992 image_manager->AddImage(image.get(), id); 983 image_manager->AddImage(image.get(), id);
993 } 984 }
994 985
995 void GpuCommandBufferStub::OnDestroyImage(int32 id) { 986 void GpuCommandBufferStub::OnDestroyImage(int32 id) {
996 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage"); 987 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage");
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); 1102 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
1112 } 1103 }
1113 1104
1114 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1105 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1115 base::TimeDelta interval) { 1106 base::TimeDelta interval) {
1116 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1107 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1117 interval)); 1108 interval));
1118 } 1109 }
1119 1110
1120 } // namespace content 1111 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc ('k') | gpu/command_buffer/service/image_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698