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

Side by Side Diff: ppapi/proxy/compositor_layer_resource.cc

Issue 475123003: [PPAPI] Add target param for CompositorLayer::SetTexture(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review issues Created 6 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
« no previous file with comments | « ppapi/proxy/compositor_layer_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/proxy/compositor_layer_resource.h" 5 #include "ppapi/proxy/compositor_layer_resource.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/GLES2/gl2extchromium.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h" 9 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "gpu/command_buffer/common/mailbox.h" 10 #include "gpu/command_buffer/common/mailbox.h"
10 #include "ppapi/proxy/compositor_resource.h" 11 #include "ppapi/proxy/compositor_resource.h"
11 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" 12 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
12 #include "ppapi/thunk/enter.h" 13 #include "ppapi/thunk/enter.h"
13 #include "ppapi/thunk/ppb_graphics_3d_api.h" 14 #include "ppapi/thunk/ppb_graphics_3d_api.h"
14 #include "ppapi/thunk/ppb_image_data_api.h" 15 #include "ppapi/thunk/ppb_image_data_api.h"
15 16
16 using gpu::gles2::GLES2Implementation; 17 using gpu::gles2::GLES2Implementation;
17 using ppapi::thunk::EnterResourceNoLock; 18 using ppapi::thunk::EnterResourceNoLock;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 data_.color->red = clamp(red); 116 data_.color->red = clamp(red);
116 data_.color->green = clamp(green); 117 data_.color->green = clamp(green);
117 data_.color->blue = clamp(blue); 118 data_.color->blue = clamp(blue);
118 data_.color->alpha = clamp(alpha); 119 data_.color->alpha = clamp(alpha);
119 data_.common.size = *size; 120 data_.common.size = *size;
120 121
121 return PP_OK; 122 return PP_OK;
122 } 123 }
123 124
125 int32_t CompositorLayerResource::SetTexture0_1(
126 PP_Resource context,
127 uint32_t texture,
128 const PP_Size* size,
129 const scoped_refptr<TrackedCallback>& release_callback) {
130 return SetTexture(context, GL_TEXTURE_2D, texture, size, release_callback);
131 }
132
124 int32_t CompositorLayerResource::SetTexture( 133 int32_t CompositorLayerResource::SetTexture(
125 PP_Resource context, 134 PP_Resource context,
135 uint32_t target,
126 uint32_t texture, 136 uint32_t texture,
127 const PP_Size* size, 137 const PP_Size* size,
128 const scoped_refptr<TrackedCallback>& release_callback) { 138 const scoped_refptr<TrackedCallback>& release_callback) {
129 int32_t rv = CheckForSetTextureAndImage(TYPE_TEXTURE, release_callback); 139 int32_t rv = CheckForSetTextureAndImage(TYPE_TEXTURE, release_callback);
130 if (rv != PP_OK) 140 if (rv != PP_OK)
131 return rv; 141 return rv;
132 DCHECK(data_.texture); 142 DCHECK(data_.texture);
133 143
134 EnterResourceNoLock<PPB_Graphics3D_API> enter(context, true); 144 EnterResourceNoLock<PPB_Graphics3D_API> enter(context, true);
135 if (enter.failed()) 145 if (enter.failed())
136 return PP_ERROR_BADRESOURCE; 146 return PP_ERROR_BADRESOURCE;
137 147
148 if (target != GL_TEXTURE_2D &&
149 target != GL_TEXTURE_EXTERNAL_OES &&
150 target != GL_TEXTURE_RECTANGLE_ARB) {
151 return PP_ERROR_BADARGUMENT;
152 }
153
138 if (!size || size->width <= 0 || size->height <= 0) 154 if (!size || size->width <= 0 || size->height <= 0)
139 return PP_ERROR_BADARGUMENT; 155 return PP_ERROR_BADARGUMENT;
140 156
141 PPB_Graphics3D_Shared* graphics = 157 PPB_Graphics3D_Shared* graphics =
142 static_cast<PPB_Graphics3D_Shared*>(enter.object()); 158 static_cast<PPB_Graphics3D_Shared*>(enter.object());
143 159
144 GLES2Implementation* gl = graphics->gles2_impl(); 160 GLES2Implementation* gl = graphics->gles2_impl();
145 161
146 // Generate a Mailbox for the texture. 162 // Generate a Mailbox for the texture.
147 gl->GenMailboxCHROMIUM( 163 gl->GenMailboxCHROMIUM(
148 reinterpret_cast<GLbyte*>(data_.texture->mailbox.name)); 164 reinterpret_cast<GLbyte*>(data_.texture->mailbox.name));
149 gl->ProduceTextureDirectCHROMIUM( 165 gl->ProduceTextureDirectCHROMIUM(
150 texture, GL_TEXTURE_2D, 166 texture, target,
151 reinterpret_cast<const GLbyte*>(data_.texture->mailbox.name)); 167 reinterpret_cast<const GLbyte*>(data_.texture->mailbox.name));
152 168
153 // Set the source size to (1, 1). It will be used to verify the source_rect 169 // Set the source size to (1, 1). It will be used to verify the source_rect
154 // passed to SetSourceRect(). 170 // passed to SetSourceRect().
155 source_size_ = PP_MakeFloatSize(1.0f, 1.0f); 171 source_size_ = PP_MakeFloatSize(1.0f, 1.0f);
156 172
157 data_.common.size = *size; 173 data_.common.size = *size;
158 data_.common.resource_id = compositor_->GenerateResourceId(); 174 data_.common.resource_id = compositor_->GenerateResourceId();
175 data_.texture->target = target;
159 data_.texture->sync_point = gl->InsertSyncPointCHROMIUM(); 176 data_.texture->sync_point = gl->InsertSyncPointCHROMIUM();
160 data_.texture->source_rect.point = PP_MakeFloatPoint(0.0f, 0.0f); 177 data_.texture->source_rect.point = PP_MakeFloatPoint(0.0f, 0.0f);
161 data_.texture->source_rect.size = source_size_; 178 data_.texture->source_rect.size = source_size_;
162 179
163 // If the PP_Resource of this layer is released by the plugin, the 180 // If the PP_Resource of this layer is released by the plugin, the
164 // release_callback will be aborted immediately, but the texture or image 181 // release_callback will be aborted immediately, but the texture or image
165 // in this layer may still being used by chromium compositor. So we have to 182 // in this layer may still being used by chromium compositor. So we have to
166 // use ScopedPPResource to keep this resource alive until the texture or image 183 // use ScopedPPResource to keep this resource alive until the texture or image
167 // is released by the chromium compositor. 184 // is released by the chromium compositor.
168 release_callback_ = base::Bind( 185 release_callback_ = base::Bind(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 376
360 // Do not allow using a block callback as a release callback. 377 // Do not allow using a block callback as a release callback.
361 if (release_callback->is_blocking()) 378 if (release_callback->is_blocking())
362 return PP_ERROR_BADARGUMENT; 379 return PP_ERROR_BADARGUMENT;
363 380
364 return PP_OK; 381 return PP_OK;
365 } 382 }
366 383
367 } // namespace proxy 384 } // namespace proxy
368 } // namespace ppapi 385 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/compositor_layer_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698