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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 20017005: gpu: Refactor GpuMemoryBuffer framework for multi-process support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | Annotate | Revision Log
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 // This file is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 index = index * 10 + digit; 708 index = index * 10 + digit;
709 } 709 }
710 getting_array_location = true; 710 getting_array_location = true;
711 } 711 }
712 *getting_array = getting_array_location; 712 *getting_array = getting_array_location;
713 *element_index = index; 713 *element_index = index;
714 *array_pos = open_pos; 714 *array_pos = open_pos;
715 return true; 715 return true;
716 } 716 }
717 717
718 ContextCreationAttribParser::ContextCreationAttribParser() 718 namespace {
719
720 // From <EGL/egl.h>.
721 const int32 EGL_ALPHA_SIZE = 0x3021;
722 const int32 EGL_BLUE_SIZE = 0x3022;
723 const int32 EGL_GREEN_SIZE = 0x3023;
724 const int32 EGL_RED_SIZE = 0x3024;
725 const int32 EGL_DEPTH_SIZE = 0x3025;
726 const int32 EGL_STENCIL_SIZE = 0x3026;
727 const int32 EGL_SAMPLES = 0x3031;
728 const int32 EGL_SAMPLE_BUFFERS = 0x3032;
729 const int32 EGL_NONE = 0x3038;
730 const int32 EGL_SWAP_BEHAVIOR = 0x3093;
731 const int32 EGL_BUFFER_PRESERVED = 0x3094;
732
733 // Chromium only.
734 const int32 SHARE_RESOURCES = 0x10000;
735 const int32 BIND_GENERATES_RESOURCES = 0x10001;
736
737 } // namespace
738
739 ContextCreationAttribHelper::ContextCreationAttribHelper()
719 : alpha_size_(-1), 740 : alpha_size_(-1),
720 blue_size_(-1), 741 blue_size_(-1),
721 green_size_(-1), 742 green_size_(-1),
722 red_size_(-1), 743 red_size_(-1),
723 depth_size_(-1), 744 depth_size_(-1),
724 stencil_size_(-1), 745 stencil_size_(-1),
725 samples_(-1), 746 samples_(-1),
726 sample_buffers_(-1), 747 sample_buffers_(-1),
727 buffer_preserved_(true), 748 buffer_preserved_(true),
728 share_resources_(false), 749 share_resources_(false),
729 bind_generates_resource_(true) { 750 bind_generates_resource_(true) {
730 } 751 }
731 752
732 bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) { 753 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) {
733 // From <EGL/egl.h>. 754 if (alpha_size_ != -1) {
734 const int32 EGL_ALPHA_SIZE = 0x3021; 755 attribs->push_back(EGL_ALPHA_SIZE);
735 const int32 EGL_BLUE_SIZE = 0x3022; 756 attribs->push_back(alpha_size_);
736 const int32 EGL_GREEN_SIZE = 0x3023; 757 }
737 const int32 EGL_RED_SIZE = 0x3024; 758 if (blue_size_ != -1) {
738 const int32 EGL_DEPTH_SIZE = 0x3025; 759 attribs->push_back(EGL_BLUE_SIZE);
739 const int32 EGL_STENCIL_SIZE = 0x3026; 760 attribs->push_back(blue_size_);
740 const int32 EGL_SAMPLES = 0x3031; 761 }
741 const int32 EGL_SAMPLE_BUFFERS = 0x3032; 762 if (green_size_ != -1) {
742 const int32 EGL_NONE = 0x3038; 763 attribs->push_back(EGL_GREEN_SIZE);
743 const int32 EGL_SWAP_BEHAVIOR = 0x3093; 764 attribs->push_back(green_size_);
744 const int32 EGL_BUFFER_PRESERVED = 0x3094; 765 }
766 if (red_size_ != -1) {
767 attribs->push_back(EGL_RED_SIZE);
768 attribs->push_back(red_size_);
769 }
770 if (depth_size_ != -1) {
771 attribs->push_back(EGL_DEPTH_SIZE);
772 attribs->push_back(depth_size_);
773 }
774 if (stencil_size_ != -1) {
775 attribs->push_back(EGL_STENCIL_SIZE);
776 attribs->push_back(stencil_size_);
777 }
778 if (samples_ != -1) {
779 attribs->push_back(EGL_SAMPLES);
780 attribs->push_back(samples_);
781 }
782 if (sample_buffers_ != -1) {
783 attribs->push_back(EGL_SAMPLE_BUFFERS);
784 attribs->push_back(sample_buffers_);
785 }
786 attribs->push_back(EGL_SWAP_BEHAVIOR);
787 attribs->push_back(buffer_preserved_);
788 attribs->push_back(SHARE_RESOURCES);
789 attribs->push_back(share_resources_ ? 1 : 0);
790 attribs->push_back(BIND_GENERATES_RESOURCES);
791 attribs->push_back(bind_generates_resource_ ? 1 : 0);
792 attribs->push_back(EGL_NONE);
793 }
745 794
746 // Chromium only. 795 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) {
747 const int32 SHARE_RESOURCES = 0x10000;
748 const int32 BIND_GENERATES_RESOURCES = 0x10001;
749
750 for (size_t i = 0; i < attribs.size(); i += 2) { 796 for (size_t i = 0; i < attribs.size(); i += 2) {
751 const int32 attrib = attribs[i]; 797 const int32 attrib = attribs[i];
752 if (i + 1 >= attribs.size()) { 798 if (i + 1 >= attribs.size()) {
753 if (attrib == EGL_NONE) { 799 if (attrib == EGL_NONE) {
754 return true; 800 return true;
755 } 801 }
756 802
757 GPU_DLOG(ERROR) << "Missing value after context creation attribute: " 803 GPU_DLOG(ERROR) << "Missing value after context creation attribute: "
758 << attrib; 804 << attrib;
759 return false; 805 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } 850 }
805 851
806 return true; 852 return true;
807 } 853 }
808 854
809 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" 855 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h"
810 856
811 } // namespace gles2 857 } // namespace gles2
812 } // namespace gpu 858 } // namespace gpu
813 859
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698