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

Side by Side Diff: content/renderer/gpu/mailbox_output_surface.cc

Issue 2002303002: Consolidate OutputSurface constructors into GL vs Vulkan. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: outputsurface-constructors: . Created 4 years, 7 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 "content/renderer/gpu/mailbox_output_surface.h" 5 #include "content/renderer/gpu/mailbox_output_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/output/gl_frame_data.h" 10 #include "cc/output/gl_frame_data.h"
11 #include "cc/resources/resource_provider.h" 11 #include "cc/resources/resource_provider.h"
12 #include "content/renderer/gpu/frame_swap_message_queue.h" 12 #include "content/renderer/gpu/frame_swap_message_queue.h"
13 #include "gpu/command_buffer/client/gles2_interface.h" 13 #include "gpu/command_buffer/client/gles2_interface.h"
14 #include "third_party/khronos/GLES2/gl2.h" 14 #include "third_party/khronos/GLES2/gl2.h"
15 #include "third_party/khronos/GLES2/gl2ext.h" 15 #include "third_party/khronos/GLES2/gl2ext.h"
16 16
17 using cc::CompositorFrame; 17 using cc::CompositorFrame;
18 using cc::GLFrameData; 18 using cc::GLFrameData;
19 using cc::ResourceProvider; 19 using cc::ResourceProvider;
20 using gpu::Mailbox; 20 using gpu::Mailbox;
21 using gpu::gles2::GLES2Interface; 21 using gpu::gles2::GLES2Interface;
22 22
23 namespace content { 23 namespace content {
24 24
25 MailboxOutputSurface::MailboxOutputSurface( 25 MailboxOutputSurface::MailboxOutputSurface(
26 int32_t routing_id, 26 int32_t routing_id,
27 uint32_t output_surface_id, 27 uint32_t output_surface_id,
28 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, 28 scoped_refptr<cc::ContextProvider> context_provider,
29 const scoped_refptr<ContextProviderCommandBuffer>& worker_context_provider, 29 scoped_refptr<cc::ContextProvider> worker_context_provider,
30 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue, 30 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue)
31 cc::ResourceFormat format)
32 : CompositorOutputSurface(routing_id, 31 : CompositorOutputSurface(routing_id,
33 output_surface_id, 32 output_surface_id,
34 context_provider, 33 std::move(context_provider),
35 worker_context_provider, 34 std::move(worker_context_provider),
36 nullptr, 35 std::move(swap_frame_message_queue)),
37 nullptr,
38 swap_frame_message_queue,
39 true),
40 fbo_(0), 36 fbo_(0),
41 is_backbuffer_discarded_(false), 37 is_backbuffer_discarded_(false) {
42 format_(format) {
43 pending_textures_.push_back(TransferableFrame()); 38 pending_textures_.push_back(TransferableFrame());
44 capabilities_.uses_default_gl_framebuffer = false; 39 capabilities_.uses_default_gl_framebuffer = false;
45 } 40 }
46 41
47 MailboxOutputSurface::~MailboxOutputSurface() {} 42 MailboxOutputSurface::~MailboxOutputSurface() {}
48 43
49 void MailboxOutputSurface::DetachFromClient() { 44 void MailboxOutputSurface::DetachFromClient() {
50 DiscardBackbuffer(); 45 DiscardBackbuffer();
51 while (!pending_textures_.empty()) { 46 while (!pending_textures_.empty()) {
52 if (pending_textures_.front().texture_id) { 47 if (pending_textures_.front().texture_id) {
(...skipping 27 matching lines...) Expand all
80 } 75 }
81 76
82 if (!current_backing_.texture_id) { 77 if (!current_backing_.texture_id) {
83 gl->GenTextures(1, &current_backing_.texture_id); 78 gl->GenTextures(1, &current_backing_.texture_id);
84 current_backing_.size = surface_size_; 79 current_backing_.size = surface_size_;
85 gl->BindTexture(GL_TEXTURE_2D, current_backing_.texture_id); 80 gl->BindTexture(GL_TEXTURE_2D, current_backing_.texture_id);
86 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 81 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
87 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 82 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
88 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 83 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
89 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 84 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
90 gl->TexImage2D(GL_TEXTURE_2D, 85 gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(cc::RGBA_8888),
91 0, 86 surface_size_.width(), surface_size_.height(), 0,
92 GLInternalFormat(format_), 87 GLDataFormat(cc::RGBA_8888), GLDataType(cc::RGBA_8888),
93 surface_size_.width(),
94 surface_size_.height(),
95 0,
96 GLDataFormat(format_),
97 GLDataType(format_),
98 NULL); 88 NULL);
99 gl->GenMailboxCHROMIUM(current_backing_.mailbox.name); 89 gl->GenMailboxCHROMIUM(current_backing_.mailbox.name);
100 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, current_backing_.mailbox.name); 90 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, current_backing_.mailbox.name);
101 } 91 }
102 } 92 }
103 } 93 }
104 94
105 void MailboxOutputSurface::DiscardBackbuffer() { 95 void MailboxOutputSurface::DiscardBackbuffer() {
106 is_backbuffer_discarded_ = true; 96 is_backbuffer_discarded_ = true;
107 97
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 220
231 MailboxOutputSurface::TransferableFrame::TransferableFrame() : texture_id(0) {} 221 MailboxOutputSurface::TransferableFrame::TransferableFrame() : texture_id(0) {}
232 222
233 MailboxOutputSurface::TransferableFrame::TransferableFrame( 223 MailboxOutputSurface::TransferableFrame::TransferableFrame(
234 uint32_t texture_id, 224 uint32_t texture_id,
235 const gpu::Mailbox& mailbox, 225 const gpu::Mailbox& mailbox,
236 const gfx::Size size) 226 const gfx::Size size)
237 : texture_id(texture_id), mailbox(mailbox), size(size) {} 227 : texture_id(texture_id), mailbox(mailbox), size(size) {}
238 228
239 } // namespace content 229 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698