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

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

Issue 10826073: Added null check for shader source when compiling, and fixed re-caching behavior to spec (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 "gpu/command_buffer/common/gl_mock.h" 7 #include "gpu/command_buffer/common/gl_mock.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" 8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/service/gl_utils.h" 9 #include "gpu/command_buffer/service/gl_utils.h"
10 #include "gpu/command_buffer/service/shader_translator.h" 10 #include "gpu/command_buffer/service/shader_translator.h"
(...skipping 20 matching lines...) Expand all
31 const char* binary) 31 const char* binary)
32 : length_(length), 32 : length_(length),
33 format_(format), 33 format_(format),
34 binary_(binary) { } 34 binary_(binary) { }
35 35
36 void GetProgramBinary(GLuint program, 36 void GetProgramBinary(GLuint program,
37 GLsizei buffer_size, 37 GLsizei buffer_size,
38 GLsizei* length, 38 GLsizei* length,
39 GLenum* format, 39 GLenum* format,
40 GLvoid* binary) { 40 GLvoid* binary) {
41 *length = length_; 41 if (length) {
42 *length = length_;
43 }
42 *format = format_; 44 *format = format_;
43 memcpy(binary, binary_, length_); 45 memcpy(binary, binary_, length_);
44 } 46 }
45 47
46 void ProgramBinary(GLuint program, 48 void ProgramBinary(GLuint program,
47 GLenum format, 49 GLenum format,
48 const GLvoid* binary, 50 const GLvoid* binary,
49 GLsizei length) { 51 GLsizei length) {
50 // format and length are verified by matcher 52 // format and length are verified by matcher
51 EXPECT_EQ(0, memcmp(binary_, binary, length)); 53 EXPECT_EQ(0, memcmp(binary_, binary, length));
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 SetExpectationsForLoadLinkedProgram(kProgramId, &emulator); 408 SetExpectationsForLoadLinkedProgram(kProgramId, &emulator);
407 409
408 fragment_shader_->UpdateSource("different!"); 410 fragment_shader_->UpdateSource("different!");
409 EXPECT_EQ(ProgramCache::PROGRAM_LOAD_SUCCESS, cache_->LoadLinkedProgram( 411 EXPECT_EQ(ProgramCache::PROGRAM_LOAD_SUCCESS, cache_->LoadLinkedProgram(
410 kProgramId, 412 kProgramId,
411 vertex_shader_, 413 vertex_shader_,
412 fragment_shader_, 414 fragment_shader_,
413 NULL)); 415 NULL));
414 } 416 }
415 417
418 TEST_F(MemoryProgramCacheTest, OverwriteOnNewSave) {
419 const GLenum kFormat = 1;
420 const int kProgramId = 10;
421 const int kBinaryLength = 20;
422 char test_binary[kBinaryLength];
423 for (int i = 0; i < kBinaryLength; ++i) {
424 test_binary[i] = i;
425 }
426 ProgramBinaryEmulator emulator(kBinaryLength, kFormat, test_binary);
427
428 SetExpectationsForSaveLinkedProgram(kProgramId, &emulator);
429 cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);
430
431
432 char test_binary2[kBinaryLength];
433 for (int i = 0; i < kBinaryLength; ++i) {
434 test_binary2[i] = (i*2) % 250;
435 }
436 ProgramBinaryEmulator emulator2(kBinaryLength, kFormat, test_binary2);
437 SetExpectationsForSaveLinkedProgram(kProgramId, &emulator2);
438 cache_->SaveLinkedProgram(kProgramId, vertex_shader_, fragment_shader_, NULL);
439
440 SetExpectationsForLoadLinkedProgram(kProgramId, &emulator2);
441 EXPECT_EQ(ProgramCache::PROGRAM_LOAD_SUCCESS, cache_->LoadLinkedProgram(
442 kProgramId,
443 vertex_shader_,
444 fragment_shader_,
445 NULL));
446 }
447
416 } // namespace gles2 448 } // namespace gles2
417 } // namespace gpu 449 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/memory_program_cache.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698