summaryrefslogtreecommitdiffstats
path: root/cc/layers/io_surface_layer_impl.cc
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 19:44:37 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-06 19:44:37 +0000
commitfdc6db2930f0df90431cdcd789666281a09d286b (patch)
tree6861cda4bb59829ac7eb219e827944f3d6a4837f /cc/layers/io_surface_layer_impl.cc
parenta8e8af9e020e5bc84b4a745c96d2b739943dd503 (diff)
downloadchromium_src-fdc6db2930f0df90431cdcd789666281a09d286b.zip
chromium_src-fdc6db2930f0df90431cdcd789666281a09d286b.tar.gz
chromium_src-fdc6db2930f0df90431cdcd789666281a09d286b.tar.bz2
cc: Make IOSurfaces transportable.
IOSurfaceLayerImpl is the last client of CreateResourceFromExternalTexture(), which creates resources that aren't transportable. Introduce CreateResourceFromIOSurface which creates a (transportable) resource out of an IOSurface, managing the GL texture. Remove CreateResourceFromExternalTexture. Update assertions and deletion logic since now "External" resources now are always mailbox-backed. BUG=239335 Review URL: https://codereview.chromium.org/265833010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers/io_surface_layer_impl.cc')
-rw-r--r--cc/layers/io_surface_layer_impl.cc57
1 files changed, 8 insertions, 49 deletions
diff --git a/cc/layers/io_surface_layer_impl.cc b/cc/layers/io_surface_layer_impl.cc
index c40e05e..4176c26 100644
--- a/cc/layers/io_surface_layer_impl.cc
+++ b/cc/layers/io_surface_layer_impl.cc
@@ -21,32 +21,19 @@ IOSurfaceLayerImpl::IOSurfaceLayerImpl(LayerTreeImpl* tree_impl, int id)
: LayerImpl(tree_impl, id),
io_surface_id_(0),
io_surface_changed_(false),
- io_surface_texture_id_(0),
io_surface_resource_id_(0) {}
IOSurfaceLayerImpl::~IOSurfaceLayerImpl() {
- if (!io_surface_texture_id_)
- return;
-
- DestroyTexture();
+ DestroyResource();
}
-void IOSurfaceLayerImpl::DestroyTexture() {
+void IOSurfaceLayerImpl::DestroyResource() {
if (io_surface_resource_id_) {
ResourceProvider* resource_provider =
layer_tree_impl()->resource_provider();
resource_provider->DeleteResource(io_surface_resource_id_);
io_surface_resource_id_ = 0;
}
-
- if (io_surface_texture_id_) {
- ContextProvider* context_provider =
- layer_tree_impl()->output_surface()->context_provider().get();
- // TODO(skaslev): Implement this path for software compositing.
- if (context_provider)
- context_provider->ContextGL()->DeleteTextures(1, &io_surface_texture_id_);
- io_surface_texture_id_ = 0;
- }
}
scoped_ptr<LayerImpl> IOSurfaceLayerImpl::CreateLayerImpl(
@@ -64,41 +51,13 @@ void IOSurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) {
bool IOSurfaceLayerImpl::WillDraw(DrawMode draw_mode,
ResourceProvider* resource_provider) {
- if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
+ if (draw_mode != DRAW_MODE_HARDWARE)
return false;
if (io_surface_changed_) {
- ContextProvider* context_provider =
- layer_tree_impl()->output_surface()->context_provider().get();
- if (!context_provider) {
- // TODO(skaslev): Implement this path for software compositing.
- return false;
- }
-
- gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
-
- // TODO(ernstm): Do this in a way that we can track memory usage.
- if (!io_surface_texture_id_) {
- gl->GenTextures(1, &io_surface_texture_id_);
- io_surface_resource_id_ =
- resource_provider->CreateResourceFromExternalTexture(
- GL_TEXTURE_RECTANGLE_ARB,
- io_surface_texture_id_);
- }
-
- GLC(gl, gl->BindTexture(GL_TEXTURE_RECTANGLE_ARB, io_surface_texture_id_));
- gl->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_RECTANGLE_ARB,
- io_surface_size_.width(),
- io_surface_size_.height(),
- io_surface_id_,
- 0);
- // Do not check for error conditions. texImageIOSurface2DCHROMIUM() is
- // supposed to hold on to the last good IOSurface if the new one is already
- // closed. This is only a possibility during live resizing of plugins.
- // However, it seems that this is not sufficient to completely guard against
- // garbage being drawn. If this is found to be a significant issue, it may
- // be necessary to explicitly tell the embedder when to free the surfaces it
- // has allocated.
+ DestroyResource();
+ io_surface_resource_id_ = resource_provider->CreateResourceFromIOSurface(
+ io_surface_size_, io_surface_id_);
io_surface_changed_ = false;
}
@@ -130,9 +89,9 @@ void IOSurfaceLayerImpl::AppendQuads(QuadSink* quad_sink,
}
void IOSurfaceLayerImpl::ReleaseResources() {
- // We don't have a valid texture ID in the new context; however,
+ // We don't have a valid resource ID in the new context; however,
// the IOSurface is still valid.
- DestroyTexture();
+ DestroyResource();
io_surface_changed_ = true;
}