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

Side by Side Diff: cc/test/test_web_graphics_context_3d.cc

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/test/test_web_graphics_context_3d.h" 5 #include "cc/test/test_web_graphics_context_3d.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // static 46 // static
47 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { 47 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() {
48 return make_scoped_ptr(new TestWebGraphicsContext3D()); 48 return make_scoped_ptr(new TestWebGraphicsContext3D());
49 } 49 }
50 50
51 TestWebGraphicsContext3D::TestWebGraphicsContext3D() 51 TestWebGraphicsContext3D::TestWebGraphicsContext3D()
52 : context_id_(s_context_id++), 52 : context_id_(s_context_id++),
53 times_bind_texture_succeeds_(-1), 53 times_bind_texture_succeeds_(-1),
54 times_end_query_succeeds_(-1), 54 times_end_query_succeeds_(-1),
55 context_lost_(false), 55 context_lost_(false),
56 times_map_image_chromium_succeeds_(-1),
57 times_map_buffer_chromium_succeeds_(-1), 56 times_map_buffer_chromium_succeeds_(-1),
58 current_used_transfer_buffer_usage_bytes_(0), 57 current_used_transfer_buffer_usage_bytes_(0),
59 max_used_transfer_buffer_usage_bytes_(0), 58 max_used_transfer_buffer_usage_bytes_(0),
60 next_program_id_(1000), 59 next_program_id_(1000),
61 next_shader_id_(2000), 60 next_shader_id_(2000),
62 max_texture_size_(2048), 61 max_texture_size_(2048),
63 reshape_called_(false), 62 reshape_called_(false),
64 width_(0), 63 width_(0),
65 height_(0), 64 height_(0),
66 scale_factor_(-1.f), 65 scale_factor_(-1.f),
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 base::AutoLock lock(namespace_->lock); 539 base::AutoLock lock(namespace_->lock);
541 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; 540 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers;
542 DCHECK_GT(buffers.count(bound_buffer_), 0u); 541 DCHECK_GT(buffers.count(bound_buffer_), 0u);
543 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); 542 DCHECK_EQ(target, buffers.get(bound_buffer_)->target);
544 buffers.get(bound_buffer_)->pixels = nullptr; 543 buffers.get(bound_buffer_)->pixels = nullptr;
545 return true; 544 return true;
546 } 545 }
547 546
548 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(GLsizei width, 547 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(GLsizei width,
549 GLsizei height, 548 GLsizei height,
550 GLenum internalformat, 549 GLenum internalformat) {
551 GLenum usage) { 550 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat));
552 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat));
553 GLuint image_id = NextImageId(); 551 GLuint image_id = NextImageId();
554 base::AutoLock lock(namespace_->lock); 552 base::AutoLock lock(namespace_->lock);
555 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; 553 base::hash_set<unsigned>& images = namespace_->images;
556 images.set(image_id, make_scoped_ptr(new Image).Pass()); 554 images.insert(image_id);
557 images.get(image_id)->pixels.reset(new uint8[width * height * 4]);
558 return image_id; 555 return image_id;
559 } 556 }
560 557
561 void TestWebGraphicsContext3D::destroyImageCHROMIUM( 558 void TestWebGraphicsContext3D::destroyImageCHROMIUM(
562 GLuint id) { 559 GLuint id) {
563 RetireImageId(id); 560 RetireImageId(id);
564 }
565
566 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM(
567 GLuint image_id,
568 GLenum pname,
569 GLint* params) {
570 base::AutoLock lock(namespace_->lock); 561 base::AutoLock lock(namespace_->lock);
571 DCHECK_GT(namespace_->images.count(image_id), 0u); 562 base::hash_set<unsigned>& images = namespace_->images;
572 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); 563 if (!images.count(id))
573 *params = 0; 564 ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id;
574 } 565 images.erase(id);
575
576 void* TestWebGraphicsContext3D::mapImageCHROMIUM(GLuint image_id) {
577 base::AutoLock lock(namespace_->lock);
578 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images;
579 DCHECK_GT(images.count(image_id), 0u);
580 if (times_map_image_chromium_succeeds_ >= 0) {
581 if (!times_map_image_chromium_succeeds_) {
582 return NULL;
583 }
584 --times_map_image_chromium_succeeds_;
585 }
586 return images.get(image_id)->pixels.get();
587 }
588
589 void TestWebGraphicsContext3D::unmapImageCHROMIUM(
590 GLuint image_id) {
591 base::AutoLock lock(namespace_->lock);
592 DCHECK_GT(namespace_->images.count(image_id), 0u);
593 }
594
595 GLuint TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM(
596 GLsizei width,
597 GLsizei height,
598 GLenum internalformat,
599 GLenum usage) {
600 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat));
601 GLuint image_id = NextImageId();
602 base::AutoLock lock(namespace_->lock);
603 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images;
604 images.set(image_id, make_scoped_ptr(new Image).Pass());
605 images.get(image_id)->pixels.reset(new uint8[width * height * 4]);
606 return image_id;
607 } 566 }
608 567
609 unsigned TestWebGraphicsContext3D::insertSyncPoint() { 568 unsigned TestWebGraphicsContext3D::insertSyncPoint() {
610 return next_insert_sync_point_++; 569 return next_insert_sync_point_++;
611 } 570 }
612 571
613 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point) { 572 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point) {
614 if (sync_point) 573 if (sync_point)
615 last_waited_sync_point_ = sync_point; 574 last_waited_sync_point_ = sync_point;
616 } 575 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 699
741 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} 700 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
742 701
743 TestWebGraphicsContext3D::Buffer::~Buffer() {} 702 TestWebGraphicsContext3D::Buffer::~Buffer() {}
744 703
745 TestWebGraphicsContext3D::Image::Image() {} 704 TestWebGraphicsContext3D::Image::Image() {}
746 705
747 TestWebGraphicsContext3D::Image::~Image() {} 706 TestWebGraphicsContext3D::Image::~Image() {}
748 707
749 } // namespace cc 708 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698