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

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

Powered by Google App Engine
This is Rietveld 408576698