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

Side by Side Diff: gpu/command_buffer/service/memory_program_cache_unittest.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/memory_program_cache.h" 5 #include "gpu/command_buffer/service/memory_program_cache.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "gpu/command_buffer/common/gles2_cmd_format.h" 13 #include "gpu/command_buffer/common/gles2_cmd_format.h"
12 #include "gpu/command_buffer/service/gl_utils.h" 14 #include "gpu/command_buffer/service/gl_utils.h"
13 #include "gpu/command_buffer/service/gpu_service_test.h" 15 #include "gpu/command_buffer/service/gpu_service_test.h"
14 #include "gpu/command_buffer/service/shader_manager.h" 16 #include "gpu/command_buffer/service/shader_manager.h"
15 #include "gpu/command_buffer/service/shader_translator.h" 17 #include "gpu/command_buffer/service/shader_translator.h"
16 #include "gpu/command_buffer/service/test_helper.h" 18 #include "gpu/command_buffer/service/test_helper.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gl/gl_bindings.h" 20 #include "ui/gl/gl_bindings.h"
19 #include "ui/gl/gl_mock.h" 21 #include "ui/gl/gl_mock.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 ProgramBinary(program_id, 177 ProgramBinary(program_id,
176 emulator->format(), 178 emulator->format(),
177 _, 179 _,
178 emulator->length())) 180 emulator->length()))
179 .WillOnce(Invoke(emulator, &ProgramBinaryEmulator::ProgramBinary)); 181 .WillOnce(Invoke(emulator, &ProgramBinaryEmulator::ProgramBinary));
180 EXPECT_CALL(*gl_.get(), 182 EXPECT_CALL(*gl_.get(),
181 GetProgramiv(program_id, GL_LINK_STATUS, _)) 183 GetProgramiv(program_id, GL_LINK_STATUS, _))
182 .WillOnce(SetArgPointee<2>(GL_FALSE)); 184 .WillOnce(SetArgPointee<2>(GL_FALSE));
183 } 185 }
184 186
185 scoped_ptr<MemoryProgramCache> cache_; 187 std::unique_ptr<MemoryProgramCache> cache_;
186 ShaderManager shader_manager_; 188 ShaderManager shader_manager_;
187 Shader* vertex_shader_; 189 Shader* vertex_shader_;
188 Shader* fragment_shader_; 190 Shader* fragment_shader_;
189 int32_t shader_cache_count_; 191 int32_t shader_cache_count_;
190 std::string shader_cache_shader_; 192 std::string shader_cache_shader_;
191 std::vector<std::string> varyings_; 193 std::vector<std::string> varyings_;
192 }; 194 };
193 195
194 TEST_F(MemoryProgramCacheTest, CacheSave) { 196 TEST_F(MemoryProgramCacheTest, CacheSave) {
195 const GLenum kFormat = 1; 197 const GLenum kFormat = 1;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 base::Unretained(this))); 555 base::Unretained(this)));
554 556
555 const int kEvictingProgramId = 11; 557 const int kEvictingProgramId = 11;
556 const GLuint kEvictingBinaryLength = kCacheSizeBytes - kBinaryLength + 1; 558 const GLuint kEvictingBinaryLength = kCacheSizeBytes - kBinaryLength + 1;
557 559
558 // save old source and modify for new program 560 // save old source and modify for new program
559 const std::string& old_sig = fragment_shader_->last_compiled_signature(); 561 const std::string& old_sig = fragment_shader_->last_compiled_signature();
560 fragment_shader_->set_source("al sdfkjdk"); 562 fragment_shader_->set_source("al sdfkjdk");
561 TestHelper::SetShaderStates(gl_.get(), fragment_shader_, true); 563 TestHelper::SetShaderStates(gl_.get(), fragment_shader_, true);
562 564
563 scoped_ptr<char[]> bigTestBinary = 565 std::unique_ptr<char[]> bigTestBinary =
564 scoped_ptr<char[]>(new char[kEvictingBinaryLength]); 566 std::unique_ptr<char[]>(new char[kEvictingBinaryLength]);
565 for (size_t i = 0; i < kEvictingBinaryLength; ++i) { 567 for (size_t i = 0; i < kEvictingBinaryLength; ++i) {
566 bigTestBinary[i] = i % 250; 568 bigTestBinary[i] = i % 250;
567 } 569 }
568 ProgramBinaryEmulator emulator2(kEvictingBinaryLength, 570 ProgramBinaryEmulator emulator2(kEvictingBinaryLength,
569 kFormat, 571 kFormat,
570 bigTestBinary.get()); 572 bigTestBinary.get());
571 573
572 SetExpectationsForSaveLinkedProgram(kEvictingProgramId, &emulator2); 574 SetExpectationsForSaveLinkedProgram(kEvictingProgramId, &emulator2);
573 cache_->SaveLinkedProgram(kEvictingProgramId, 575 cache_->SaveLinkedProgram(kEvictingProgramId,
574 vertex_shader_, 576 vertex_shader_,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 fragment_shader_, 684 fragment_shader_,
683 NULL, 685 NULL,
684 varyings_, 686 varyings_,
685 GL_NONE, 687 GL_NONE,
686 base::Bind(&MemoryProgramCacheTest::ShaderCacheCb, 688 base::Bind(&MemoryProgramCacheTest::ShaderCacheCb,
687 base::Unretained(this)))); 689 base::Unretained(this))));
688 } 690 }
689 691
690 } // namespace gles2 692 } // namespace gles2
691 } // namespace gpu 693 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/memory_program_cache.cc ('k') | gpu/command_buffer/service/path_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698