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

Side by Side Diff: content/browser/compositor/gl_helper_readback_support.cc

Issue 1802383002: Move gl_helper to content/browser/compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/common/gpu/client/gl_helper_readback_support.h" 5 #include "content/browser/compositor/gl_helper_readback_support.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "gpu/GLES2/gl2extchromium.h" 7 #include "gpu/GLES2/gl2extchromium.h"
8 #include "third_party/skia/include/core/SkImageInfo.h" 8 #include "third_party/skia/include/core/SkImageInfo.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 GLHelperReadbackSupport::GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl) 12 GLHelperReadbackSupport::GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl)
13 : gl_(gl) { 13 : gl_(gl) {
14 InitializeReadbackSupport(); 14 InitializeReadbackSupport();
15 } 15 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 } 75 }
76 76
77 const int kTestSize = 64; 77 const int kTestSize = 64;
78 content::ScopedTexture dst_texture(gl_); 78 content::ScopedTexture dst_texture(gl_);
79 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture); 79 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
80 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 80 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
81 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 81 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
82 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 82 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
83 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 83 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
84 gl_->TexImage2D( 84 gl_->TexImage2D(GL_TEXTURE_2D, 0, format, kTestSize, kTestSize, 0, format,
85 GL_TEXTURE_2D, 0, format, kTestSize, kTestSize, 0, format, type, NULL); 85 type, NULL);
86 ScopedFramebuffer dst_framebuffer(gl_); 86 ScopedFramebuffer dst_framebuffer(gl_);
87 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_, 87 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
88 dst_framebuffer); 88 dst_framebuffer);
89 gl_->FramebufferTexture2D( 89 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
90 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_texture, 0); 90 dst_texture, 0);
91 GLint format_tmp = 0, type_tmp = 0; 91 GLint format_tmp = 0, type_tmp = 0;
92 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format_tmp); 92 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format_tmp);
93 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type_tmp); 93 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type_tmp);
94 *format_out = format_tmp; 94 *format_out = format_tmp;
95 *type_out = type_tmp; 95 *type_out = type_tmp;
96 96
97 struct FormatCacheEntry entry = { format, type, *format_out, *type_out }; 97 struct FormatCacheEntry entry = {format, type, *format_out, *type_out};
98 format_cache_.push_back(entry); 98 format_cache_.push_back(entry);
99 } 99 }
100 100
101 bool GLHelperReadbackSupport::SupportsFormat(GLenum format, GLenum type) { 101 bool GLHelperReadbackSupport::SupportsFormat(GLenum format, GLenum type) {
102 // GLES2.0 Specification says this pairing is always supported 102 // GLES2.0 Specification says this pairing is always supported
103 // with additional format from GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE 103 // with additional format from GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE
104 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) 104 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE)
105 return true; 105 return true;
106 106
107 bool supports_format = false; 107 bool supports_format = false;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return GLHelperReadbackSupport::NOT_SUPPORTED; 163 return GLHelperReadbackSupport::NOT_SUPPORTED;
164 default: 164 default:
165 NOTREACHED(); 165 NOTREACHED();
166 break; 166 break;
167 } 167 }
168 168
169 return GLHelperReadbackSupport::NOT_SUPPORTED; 169 return GLHelperReadbackSupport::NOT_SUPPORTED;
170 } 170 }
171 171
172 } // namespace content 172 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/gl_helper_readback_support.h ('k') | content/browser/compositor/gl_helper_scaling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698