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

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

Issue 2089753003: cc: Use the correct internal format for glCopyTexImage2D calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copytextureformat: comments Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/compositor/offscreen_browser_compositor_output_surface .h" 5 #include "content/browser/compositor/offscreen_browser_compositor_output_surface .h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 12 matching lines...) Expand all
23 #include "third_party/khronos/GLES2/gl2.h" 23 #include "third_party/khronos/GLES2/gl2.h"
24 #include "third_party/khronos/GLES2/gl2ext.h" 24 #include "third_party/khronos/GLES2/gl2ext.h"
25 25
26 using cc::CompositorFrame; 26 using cc::CompositorFrame;
27 using cc::GLFrameData; 27 using cc::GLFrameData;
28 using cc::ResourceProvider; 28 using cc::ResourceProvider;
29 using gpu::gles2::GLES2Interface; 29 using gpu::gles2::GLES2Interface;
30 30
31 namespace content { 31 namespace content {
32 32
33 static cc::ResourceFormat kFboTextureFormat = cc::RGBA_8888;
34
33 OffscreenBrowserCompositorOutputSurface:: 35 OffscreenBrowserCompositorOutputSurface::
34 OffscreenBrowserCompositorOutputSurface( 36 OffscreenBrowserCompositorOutputSurface(
35 scoped_refptr<ContextProviderCommandBuffer> context, 37 scoped_refptr<ContextProviderCommandBuffer> context,
36 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 38 scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
37 cc::SyntheticBeginFrameSource* begin_frame_source, 39 cc::SyntheticBeginFrameSource* begin_frame_source,
38 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 40 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
39 overlay_candidate_validator) 41 overlay_candidate_validator)
40 : BrowserCompositorOutputSurface(std::move(context), 42 : BrowserCompositorOutputSurface(std::move(context),
41 std::move(vsync_manager), 43 std::move(vsync_manager),
42 begin_frame_source, 44 begin_frame_source,
43 std::move(overlay_candidate_validator)), 45 std::move(overlay_candidate_validator)),
44 fbo_(0), 46 fbo_(0),
45 is_backbuffer_discarded_(false), 47 is_backbuffer_discarded_(false),
46 weak_ptr_factory_(this) { 48 weak_ptr_factory_(this) {
47 capabilities_.uses_default_gl_framebuffer = false; 49 capabilities_.uses_default_gl_framebuffer = false;
48 } 50 }
49 51
50 OffscreenBrowserCompositorOutputSurface:: 52 OffscreenBrowserCompositorOutputSurface::
51 ~OffscreenBrowserCompositorOutputSurface() { 53 ~OffscreenBrowserCompositorOutputSurface() {
52 DiscardBackbuffer(); 54 DiscardBackbuffer();
53 } 55 }
54 56
55 void OffscreenBrowserCompositorOutputSurface::EnsureBackbuffer() { 57 void OffscreenBrowserCompositorOutputSurface::EnsureBackbuffer() {
56 is_backbuffer_discarded_ = false; 58 is_backbuffer_discarded_ = false;
57 59
58 if (!reflector_texture_.get()) { 60 if (!reflector_texture_) {
59 reflector_texture_.reset(new ReflectorTexture(context_provider())); 61 reflector_texture_.reset(new ReflectorTexture(context_provider()));
60 62
61 GLES2Interface* gl = context_provider_->ContextGL(); 63 GLES2Interface* gl = context_provider_->ContextGL();
62 64
63 const int max_texture_size = 65 const int max_texture_size =
64 context_provider_->ContextCapabilities().max_texture_size; 66 context_provider_->ContextCapabilities().max_texture_size;
65 int texture_width = std::min(max_texture_size, surface_size_.width()); 67 int texture_width = std::min(max_texture_size, surface_size_.width());
66 int texture_height = std::min(max_texture_size, surface_size_.height()); 68 int texture_height = std::min(max_texture_size, surface_size_.height());
67 69
68 cc::ResourceFormat format = cc::RGBA_8888;
69 gl->BindTexture(GL_TEXTURE_2D, reflector_texture_->texture_id()); 70 gl->BindTexture(GL_TEXTURE_2D, reflector_texture_->texture_id());
70 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 71 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
71 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 72 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
72 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 73 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
73 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 74 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
74 gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format), 75 gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(kFboTextureFormat),
75 texture_width, texture_height, 0, 76 texture_width, texture_height, 0,
76 GLDataFormat(format), GLDataType(format), nullptr); 77 GLDataFormat(kFboTextureFormat),
78 GLDataType(kFboTextureFormat), nullptr);
77 if (!fbo_) 79 if (!fbo_)
78 gl->GenFramebuffers(1, &fbo_); 80 gl->GenFramebuffers(1, &fbo_);
79 81
80 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); 82 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
81 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 83 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
82 GL_TEXTURE_2D, reflector_texture_->texture_id(), 84 GL_TEXTURE_2D, reflector_texture_->texture_id(),
83 0); 85 0);
84 reflector_->OnSourceTextureMailboxUpdated( 86 reflector_->OnSourceTextureMailboxUpdated(
85 reflector_texture_->mailbox()); 87 reflector_texture_->mailbox());
86 } 88 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool need_to_bind = !!reflector_texture_.get(); 122 bool need_to_bind = !!reflector_texture_.get();
121 EnsureBackbuffer(); 123 EnsureBackbuffer();
122 DCHECK(reflector_texture_.get()); 124 DCHECK(reflector_texture_.get());
123 125
124 if (need_to_bind) { 126 if (need_to_bind) {
125 GLES2Interface* gl = context_provider_->ContextGL(); 127 GLES2Interface* gl = context_provider_->ContextGL();
126 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); 128 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
127 } 129 }
128 } 130 }
129 131
132 GLenum
133 OffscreenBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() {
134 return GLCopyTextureInternalFormat(kFboTextureFormat);
135 }
136
130 void OffscreenBrowserCompositorOutputSurface::SwapBuffers( 137 void OffscreenBrowserCompositorOutputSurface::SwapBuffers(
131 cc::CompositorFrame* frame) { 138 cc::CompositorFrame* frame) {
132 if (reflector_) { 139 if (reflector_) {
133 if (frame->gl_frame_data->sub_buffer_rect == 140 if (frame->gl_frame_data->sub_buffer_rect ==
134 gfx::Rect(frame->gl_frame_data->size)) 141 gfx::Rect(frame->gl_frame_data->size))
135 reflector_->OnSourceSwapBuffers(); 142 reflector_->OnSourceSwapBuffers();
136 else 143 else
137 reflector_->OnSourcePostSubBuffer(frame->gl_frame_data->sub_buffer_rect); 144 reflector_->OnSourcePostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
138 } 145 }
139 146
(...skipping 17 matching lines...) Expand all
157 if (reflector_) 164 if (reflector_)
158 EnsureBackbuffer(); 165 EnsureBackbuffer();
159 } 166 }
160 167
161 base::Closure 168 base::Closure
162 OffscreenBrowserCompositorOutputSurface::CreateCompositionStartedCallback() { 169 OffscreenBrowserCompositorOutputSurface::CreateCompositionStartedCallback() {
163 return base::Closure(); 170 return base::Closure();
164 } 171 }
165 172
166 } // namespace content 173 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698