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

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

Issue 15579002: Implement transform/clip support for Android WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make MailboxOutputSurface use surface_size_ Created 7 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 (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"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 } 39 }
40 40
41 void MailboxOutputSurface::EnsureBackbuffer() { 41 void MailboxOutputSurface::EnsureBackbuffer() {
42 is_backbuffer_discarded_ = false; 42 is_backbuffer_discarded_ = false;
43 43
44 if (!current_backing_.texture_id) { 44 if (!current_backing_.texture_id) {
45 // Find a texture of matching size to recycle. 45 // Find a texture of matching size to recycle.
46 while (!returned_textures_.empty()) { 46 while (!returned_textures_.empty()) {
47 TransferableFrame& texture = returned_textures_.front(); 47 TransferableFrame& texture = returned_textures_.front();
48 if (texture.size == size_) { 48 if (texture.size == surface_size_) {
49 current_backing_ = texture; 49 current_backing_ = texture;
50 ConsumeTexture(texture); 50 ConsumeTexture(texture);
51 returned_textures_.pop(); 51 returned_textures_.pop();
52 break; 52 break;
53 } 53 }
54 54
55 ConsumeTexture(texture); 55 ConsumeTexture(texture);
56 context3d_->deleteTexture(texture.texture_id); 56 context3d_->deleteTexture(texture.texture_id);
57 returned_textures_.pop(); 57 returned_textures_.pop();
58 } 58 }
59 59
60 if (!current_backing_.texture_id) { 60 if (!current_backing_.texture_id) {
61 current_backing_.texture_id = context3d_->createTexture(); 61 current_backing_.texture_id = context3d_->createTexture();
62 current_backing_.size = size_; 62 current_backing_.size = surface_size_;
63 context3d_->genMailboxCHROMIUM(current_backing_.mailbox.name); 63 context3d_->genMailboxCHROMIUM(current_backing_.mailbox.name);
64 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); 64 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id);
65 context3d_->texParameteri( 65 context3d_->texParameteri(
66 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 66 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
67 context3d_->texParameteri( 67 context3d_->texParameteri(
68 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 68 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
69 context3d_->texParameteri( 69 context3d_->texParameteri(
70 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 70 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
71 context3d_->texParameteri( 71 context3d_->texParameteri(
72 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 72 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
73 context3d_->texImage2D( 73 context3d_->texImage2D(
74 GL_TEXTURE_2D, 0, GL_RGBA, size_.width(), size_.height(), 0, 74 GL_TEXTURE_2D, 0, GL_RGBA,
75 surface_size_.width(), surface_size_.height(), 0,
75 GL_RGBA, GL_UNSIGNED_BYTE, NULL); 76 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
76 } 77 }
77 } 78 }
78 } 79 }
79 80
80 void MailboxOutputSurface::DiscardBackbuffer() { 81 void MailboxOutputSurface::DiscardBackbuffer() {
81 is_backbuffer_discarded_ = true; 82 is_backbuffer_discarded_ = true;
82 83
83 if (current_backing_.texture_id) { 84 if (current_backing_.texture_id) {
84 context3d_->deleteTexture(current_backing_.texture_id); 85 context3d_->deleteTexture(current_backing_.texture_id);
85 current_backing_ = TransferableFrame(); 86 current_backing_ = TransferableFrame();
86 } 87 }
87 88
88 while (!returned_textures_.empty()) { 89 while (!returned_textures_.empty()) {
89 const TransferableFrame& frame = returned_textures_.front(); 90 const TransferableFrame& frame = returned_textures_.front();
90 ConsumeTexture(frame); 91 ConsumeTexture(frame);
91 context3d_->deleteTexture(frame.texture_id); 92 context3d_->deleteTexture(frame.texture_id);
92 returned_textures_.pop(); 93 returned_textures_.pop();
93 } 94 }
94 95
95 if (fbo_) { 96 if (fbo_) {
96 context3d_->bindFramebuffer(GL_FRAMEBUFFER, fbo_); 97 context3d_->bindFramebuffer(GL_FRAMEBUFFER, fbo_);
97 context3d_->deleteFramebuffer(fbo_); 98 context3d_->deleteFramebuffer(fbo_);
98 fbo_ = 0; 99 fbo_ = 0;
99 } 100 }
100 } 101 }
101 102
102 void MailboxOutputSurface::Reshape(gfx::Size size, float scale_factor) { 103 void MailboxOutputSurface::Reshape(gfx::Size size, float scale_factor) {
103 if (size == size_) 104 if (size == surface_size_)
104 return; 105 return;
105 106
106 size_ = size; 107 surface_size_ = size;
piman 2013/06/05 00:52:08 Also set device_scale_factor_ so that it doesn't g
107 DiscardBackbuffer(); 108 DiscardBackbuffer();
108 EnsureBackbuffer(); 109 EnsureBackbuffer();
109 } 110 }
110 111
111 void MailboxOutputSurface::BindFramebuffer() { 112 void MailboxOutputSurface::BindFramebuffer() {
112 EnsureBackbuffer(); 113 EnsureBackbuffer();
113 DCHECK(current_backing_.texture_id); 114 DCHECK(current_backing_.texture_id);
114 115
115 if (!fbo_) 116 if (!fbo_)
116 fbo_ = context3d_->createFramebuffer(); 117 fbo_ = context3d_->createFramebuffer();
117 context3d_->bindFramebuffer(GL_FRAMEBUFFER, fbo_); 118 context3d_->bindFramebuffer(GL_FRAMEBUFFER, fbo_);
118 context3d_->framebufferTexture2D( 119 context3d_->framebufferTexture2D(
119 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 120 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
120 current_backing_.texture_id, 0); 121 current_backing_.texture_id, 0);
121 } 122 }
122 123
123 void MailboxOutputSurface::SendFrameToParentCompositor( 124 void MailboxOutputSurface::SendFrameToParentCompositor(
124 cc::CompositorFrame* frame) { 125 cc::CompositorFrame* frame) {
125 frame->gl_frame_data.reset(new GLFrameData()); 126 frame->gl_frame_data.reset(new GLFrameData());
126 127
127 DCHECK(!size_.IsEmpty()); 128 DCHECK(!surface_size_.IsEmpty());
128 DCHECK(size_ == current_backing_.size); 129 DCHECK(surface_size_ == current_backing_.size);
129 DCHECK(!current_backing_.mailbox.IsZero()); 130 DCHECK(!current_backing_.mailbox.IsZero());
130 131
131 context3d_->framebufferTexture2D( 132 context3d_->framebufferTexture2D(
132 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 133 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
133 context3d_->bindFramebuffer(GL_FRAMEBUFFER, 0); 134 context3d_->bindFramebuffer(GL_FRAMEBUFFER, 0);
134 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); 135 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id);
135 context3d_->produceTextureCHROMIUM( 136 context3d_->produceTextureCHROMIUM(
136 GL_TEXTURE_2D, current_backing_.mailbox.name); 137 GL_TEXTURE_2D, current_backing_.mailbox.name);
137 frame->gl_frame_data->mailbox = current_backing_.mailbox; 138 frame->gl_frame_data->mailbox = current_backing_.mailbox;
138 frame->gl_frame_data->size = current_backing_.size; 139 frame->gl_frame_data->size = current_backing_.size;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 context3d_->bindTexture(GL_TEXTURE_2D, frame.texture_id); 204 context3d_->bindTexture(GL_TEXTURE_2D, frame.texture_id);
204 context3d_->consumeTextureCHROMIUM(GL_TEXTURE_2D, frame.mailbox.name); 205 context3d_->consumeTextureCHROMIUM(GL_TEXTURE_2D, frame.mailbox.name);
205 } 206 }
206 207
207 size_t MailboxOutputSurface::GetNumAcksPending() { 208 size_t MailboxOutputSurface::GetNumAcksPending() {
208 DCHECK(pending_textures_.size()); 209 DCHECK(pending_textures_.size());
209 return pending_textures_.size() - 1; 210 return pending_textures_.size() - 1;
210 } 211 }
211 212
212 } // namespace content 213 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698