Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index bfd387c175d8c036e79cad910f4455f7815004fc..ad1ed5f2b4f3d32a8f9cbab385dab9de026842cf 100644 |
--- a/cc/output/gl_renderer.cc |
+++ b/cc/output/gl_renderer.cc |
@@ -22,6 +22,7 @@ |
#include "cc/output/gl_frame_data.h" |
#include "cc/output/output_surface.h" |
#include "cc/output/render_surface_filters.h" |
+#include "cc/quads/picture_draw_quad.h" |
#include "cc/quads/render_pass.h" |
#include "cc/quads/stream_video_draw_quad.h" |
#include "cc/quads/texture_draw_quad.h" |
@@ -102,7 +103,9 @@ GLRenderer::GLRenderer(RendererClient* client, |
discard_backbuffer_when_not_visible_(false), |
is_using_bind_uniform_(false), |
visible_(true), |
- is_scissor_enabled_(false) { |
+ is_scissor_enabled_(false), |
+ on_demand_tile_raster_texture_(0), |
+ on_demand_tile_raster_resource_id_(0) { |
DCHECK(context_); |
} |
@@ -301,6 +304,9 @@ void GLRenderer::DoDrawQuad(DrawingFrame& frame, const DrawQuad* quad) { |
case DrawQuad::IO_SURFACE_CONTENT: |
DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad)); |
break; |
+ case DrawQuad::PICTURE_CONTENT: |
+ DrawPictureQuad(frame, PictureDrawQuad::MaterialCast(quad)); |
+ break; |
case DrawQuad::RENDER_PASS: |
DrawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad)); |
break; |
@@ -313,9 +319,11 @@ void GLRenderer::DoDrawQuad(DrawingFrame& frame, const DrawQuad* quad) { |
case DrawQuad::TEXTURE_CONTENT: |
EnqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad)); |
break; |
- case DrawQuad::TILED_CONTENT: |
- DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); |
+ case DrawQuad::TILED_CONTENT: { |
+ const TileDrawQuad* tile_draw_quad = TileDrawQuad::MaterialCast(quad); |
+ DrawTileQuad(frame, tile_draw_quad, tile_draw_quad->resource_id); |
break; |
+ } |
case DrawQuad::YUV_VIDEO_CONTENT: |
DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); |
break; |
@@ -1034,7 +1042,8 @@ static void TileUniformLocation(T program, TileProgramUniforms* uniforms) { |
} |
void GLRenderer::DrawTileQuad(const DrawingFrame& frame, |
danakj
2013/03/21 02:34:42
nit: Can you call this function DrawTileOrPictureQ
Leandro Graciá Gil
2013/03/21 16:42:48
Done.
|
- const TileDrawQuad* quad) { |
+ const TileDrawQuadBase* quad, |
+ unsigned resource_id) { |
gfx::Rect tile_rect = quad->visible_rect; |
gfx::RectF tex_coord_rect = quad->tex_coord_rect; |
@@ -1123,7 +1132,7 @@ void GLRenderer::DrawTileQuad(const DrawingFrame& frame, |
? GL_LINEAR |
: GL_NEAREST; |
ResourceProvider::ScopedSamplerGL quad_resource_lock( |
- resource_provider_, quad->resource_id, GL_TEXTURE_2D, filter); |
+ resource_provider_, resource_id, GL_TEXTURE_2D, filter); |
if (use_aa) { |
GLC(Context(), Context()->uniform3fv(uniforms.edge_location, 8, edge)); |
@@ -1277,6 +1286,44 @@ void GLRenderer::DrawStreamVideoQuad(const DrawingFrame& frame, |
program->vertex_shader().matrixLocation()); |
} |
+void GLRenderer::DrawPictureQuad(const DrawingFrame& frame, const PictureDrawQuad* quad) { |
+ if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || |
+ on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { |
+ on_demand_tile_raster_bitmap_.setConfig( |
+ SkBitmap::kARGB_8888_Config, |
+ quad->texture_size.width(), |
+ quad->texture_size.height()); |
+ on_demand_tile_raster_bitmap_.allocPixels(); |
+ } |
+ |
+ SkDevice device(on_demand_tile_raster_bitmap_); |
+ SkCanvas canvas(&device); |
+ |
+ int64 total_pixels_rasterized = 0; |
+ quad->picture_pile->Raster( |
+ &canvas, |
+ quad->content_rect, |
+ quad->contents_scale, |
+ &total_pixels_rasterized); |
+ |
+ GLC(Context(), Context()->bindTexture( |
+ GL_TEXTURE_2D, |
+ on_demand_tile_raster_texture_)); |
+ |
+ GLC(Context(), Context()->texImage2D( |
+ GL_TEXTURE_2D, |
+ 0, |
+ GL_RGBA, |
+ quad->texture_size.width(), |
+ quad->texture_size.height(), |
+ 0, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ on_demand_tile_raster_bitmap_.getPixels())); |
+ |
+ DrawTileQuad(frame, quad, on_demand_tile_raster_resource_id_); |
+} |
+ |
struct TextureProgramBinding { |
template <class Program> |
void Set(Program* program, WebKit::WebGraphicsContext3D* context) { |
@@ -1960,6 +2007,11 @@ bool GLRenderer::InitializeSharedObjects() { |
tile_program_ = make_scoped_ptr(new TileProgram(context_)); |
tile_program_opaque_ = make_scoped_ptr(new TileProgramOpaque(context_)); |
+ on_demand_tile_raster_texture_ = Context()->createTexture(); |
danakj
2013/03/21 02:34:42
Can you do this in DrawPictureQuad() the first tim
Leandro Graciá Gil
2013/03/21 16:42:48
Done.
|
+ on_demand_tile_raster_resource_id_ = |
+ resource_provider_->CreateResourceFromExternalTexture( |
+ on_demand_tile_raster_texture_); |
+ |
GLC(context_, context_->flush()); |
return true; |
@@ -2222,6 +2274,9 @@ void GLRenderer::CleanupSharedObjects() { |
if (offscreen_framebuffer_id_) |
GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
+ if (on_demand_tile_raster_texture_) |
+ GLC(context_, context_->deleteTexture(on_demand_tile_raster_texture_)); |
danakj
2013/03/21 02:34:42
You need to clean up with the ResourceProvider too
Leandro Graciá Gil
2013/03/21 03:35:50
Can I use ResourceProvider to clean external textu
danakj
2013/03/21 04:33:39
ya, there's actually no need for this to be an ext
Leandro Graciá Gil
2013/03/21 16:42:48
Looking at ResourceProvider it seems that doing it
danakj
2013/03/21 17:20:22
I talked to piman@ and he suggested to just not re
Leandro Graciá Gil
2013/03/21 18:14:16
Registering as an external texture makes things si
piman
2013/03/21 18:26:30
I want to get rid of the non-mailbox external text
|
+ |
ReleaseRenderPassTextures(); |
} |