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

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

Issue 916083002: Add support for compressed GPU memory buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ATC and DXT feature detection and checking Created 5 years, 10 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"
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 if (!decoder_) 949 if (!decoder_)
950 return; 950 return;
951 951
952 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 952 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
953 DCHECK(image_manager); 953 DCHECK(image_manager);
954 if (image_manager->LookupImage(id)) { 954 if (image_manager->LookupImage(id)) {
955 LOG(ERROR) << "Image already exists with same ID."; 955 LOG(ERROR) << "Image already exists with same ID.";
956 return; 956 return;
957 } 957 }
958 958
959 bool supported_format = true;
960
961 gpu::Capabilities capabilities = decoder_->GetCapabilities();
962 switch (format) {
963 case gfx::GpuMemoryBuffer::ATC:
964 case gfx::GpuMemoryBuffer::ATCIA:
965 if (!capabilities.texture_format_atc)
966 supported_format = false;
967 break;
968 case gfx::GpuMemoryBuffer::BGRA_8888:
969 if (!capabilities.texture_format_bgra8888)
970 supported_format = false;
971 break;
972 case gfx::GpuMemoryBuffer::DXT1:
973 if (!capabilities.texture_format_dxt1)
974 supported_format = false;
975 break;
976 case gfx::GpuMemoryBuffer::DXT5:
977 if (!capabilities.texture_format_dxt5)
978 supported_format = false;
979 break;
980 case gfx::GpuMemoryBuffer::ETC1:
981 if (!capabilities.texture_format_etc1)
982 supported_format = false;
983 break;
984 case gfx::GpuMemoryBuffer::RGBA_8888:
985 case gfx::GpuMemoryBuffer::RGBX_8888:
986 break;
987 }
reveman 2015/02/13 23:51:25 Looks good. Can you just move this into a IsSuppor
christiank 2015/02/18 14:38:25 Sure! I'll fix this.
988
989 if (!supported_format) {
990 LOG(ERROR) << "Image format is not supported.";
991 return;
992 }
993
959 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer( 994 scoped_refptr<gfx::GLImage> image = channel()->CreateImageForGpuMemoryBuffer(
960 handle, size, format, internalformat); 995 handle, size, format, internalformat);
961 if (!image.get()) 996 if (!image.get())
962 return; 997 return;
963 998
964 image_manager->AddImage(image.get(), id); 999 image_manager->AddImage(image.get(), id);
965 } 1000 }
966 1001
967 void GpuCommandBufferStub::OnDestroyImage(int32 id) { 1002 void GpuCommandBufferStub::OnDestroyImage(int32 id) {
968 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage"); 1003 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyImage");
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 1112 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
1078 return GetMemoryManager()->GetClientMemoryUsage(this); 1113 return GetMemoryManager()->GetClientMemoryUsage(this);
1079 } 1114 }
1080 1115
1081 void GpuCommandBufferStub::SwapBuffersCompleted( 1116 void GpuCommandBufferStub::SwapBuffersCompleted(
1082 const std::vector<ui::LatencyInfo>& latency_info) { 1117 const std::vector<ui::LatencyInfo>& latency_info) {
1083 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); 1118 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
1084 } 1119 }
1085 1120
1086 } // namespace content 1121 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698