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

Side by Side Diff: gpu/command_buffer/service/program_cache.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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 "gpu/command_buffer/service/program_cache.h" 5 #include "gpu/command_buffer/service/program_cache.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include "base/memory/scoped_ptr.h" 11
11 #include "gpu/command_buffer/service/shader_manager.h" 12 #include "gpu/command_buffer/service/shader_manager.h"
12 #include "third_party/angle/src/common/version.h" 13 #include "third_party/angle/src/common/version.h"
13 14
14 namespace gpu { 15 namespace gpu {
15 namespace gles2 { 16 namespace gles2 {
16 17
17 ProgramCache::ProgramCache() {} 18 ProgramCache::ProgramCache() {}
18 ProgramCache::~ProgramCache() {} 19 ProgramCache::~ProgramCache() {}
19 20
20 void ProgramCache::Clear() { 21 void ProgramCache::Clear() {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 GLenum transform_feedback_buffer_mode, 117 GLenum transform_feedback_buffer_mode,
117 char* result) const { 118 char* result) const {
118 const size_t shader0_size = kHashLength; 119 const size_t shader0_size = kHashLength;
119 const size_t shader1_size = kHashLength; 120 const size_t shader1_size = kHashLength;
120 const size_t angle_commit_size = ANGLE_COMMIT_HASH_SIZE; 121 const size_t angle_commit_size = ANGLE_COMMIT_HASH_SIZE;
121 const size_t map_size = CalculateMapSize(bind_attrib_location_map); 122 const size_t map_size = CalculateMapSize(bind_attrib_location_map);
122 const size_t var_size = CalculateVaryingsSize(transform_feedback_varyings); 123 const size_t var_size = CalculateVaryingsSize(transform_feedback_varyings);
123 const size_t total_size = shader0_size + shader1_size + angle_commit_size 124 const size_t total_size = shader0_size + shader1_size + angle_commit_size
124 + map_size + var_size + sizeof(transform_feedback_buffer_mode); 125 + map_size + var_size + sizeof(transform_feedback_buffer_mode);
125 126
126 scoped_ptr<unsigned char[]> buffer(new unsigned char[total_size]); 127 std::unique_ptr<unsigned char[]> buffer(new unsigned char[total_size]);
127 memcpy(buffer.get(), hashed_shader_0, shader0_size); 128 memcpy(buffer.get(), hashed_shader_0, shader0_size);
128 memcpy(&buffer[shader0_size], hashed_shader_1, shader1_size); 129 memcpy(&buffer[shader0_size], hashed_shader_1, shader1_size);
129 size_t current_pos = shader0_size + shader1_size; 130 size_t current_pos = shader0_size + shader1_size;
130 memcpy(&buffer[current_pos], ANGLE_COMMIT_HASH, angle_commit_size); 131 memcpy(&buffer[current_pos], ANGLE_COMMIT_HASH, angle_commit_size);
131 current_pos += angle_commit_size; 132 current_pos += angle_commit_size;
132 if (map_size != 0) { 133 if (map_size != 0) {
133 // copy our map 134 // copy our map
134 for (auto it = bind_attrib_location_map->begin(); 135 for (auto it = bind_attrib_location_map->begin();
135 it != bind_attrib_location_map->end(); 136 it != bind_attrib_location_map->end();
136 ++it) { 137 ++it) {
(...skipping 18 matching lines...) Expand all
155 } 156 }
156 } 157 }
157 memcpy(&buffer[current_pos], &transform_feedback_buffer_mode, 158 memcpy(&buffer[current_pos], &transform_feedback_buffer_mode,
158 sizeof(transform_feedback_buffer_mode)); 159 sizeof(transform_feedback_buffer_mode));
159 base::SHA1HashBytes(buffer.get(), 160 base::SHA1HashBytes(buffer.get(),
160 total_size, reinterpret_cast<unsigned char*>(result)); 161 total_size, reinterpret_cast<unsigned char*>(result));
161 } 162 }
162 163
163 } // namespace gles2 164 } // namespace gles2
164 } // namespace gpu 165 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/path_manager_unittest.cc ('k') | gpu/command_buffer/service/program_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698