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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 23447048: cc: Reland r233830. "Adding support for RGBA_4444 tile textures". r223830 had a bug in async_pixel_… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@16bitbitmap
Patch Set: Adding 4444 tile texture support to compositor Created 7 years, 3 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
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 int top, right, bottom, left; 646 int top, right, bottom, left;
647 filters.GetOutsets(&top, &right, &bottom, &left); 647 filters.GetOutsets(&top, &right, &bottom, &left);
648 window_rect.Inset(-left, -top, -right, -bottom); 648 window_rect.Inset(-left, -top, -right, -bottom);
649 649
650 window_rect.Intersect( 650 window_rect.Intersect(
651 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); 651 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect));
652 652
653 scoped_ptr<ScopedResource> device_background_texture = 653 scoped_ptr<ScopedResource> device_background_texture =
654 ScopedResource::create(resource_provider_); 654 ScopedResource::create(resource_provider_);
655 if (!device_background_texture->Allocate(window_rect.size(), 655 if (!device_background_texture->Allocate(window_rect.size(),
656 GL_RGB, 656 ResourceProvider::TextureUsageAny,
657 ResourceProvider::TextureUsageAny)) { 657 RGBA_8888)) {
658 return scoped_ptr<ScopedResource>(); 658 return scoped_ptr<ScopedResource>();
659 } else { 659 } else {
660 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 660 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
661 device_background_texture->id()); 661 device_background_texture->id());
662 GetFramebufferTexture(lock.texture_id(), 662 GetFramebufferTexture(lock.texture_id(),
663 device_background_texture->format(), 663 device_background_texture->format(),
664 window_rect); 664 window_rect);
665 } 665 }
666 666
667 SkBitmap filtered_device_background = 667 SkBitmap filtered_device_background =
668 ApplyFilters(this, 668 ApplyFilters(this,
669 frame->offscreen_context_provider, 669 frame->offscreen_context_provider,
670 filters, 670 filters,
671 device_background_texture.get()); 671 device_background_texture.get());
672 if (!filtered_device_background.getTexture()) 672 if (!filtered_device_background.getTexture())
673 return scoped_ptr<ScopedResource>(); 673 return scoped_ptr<ScopedResource>();
674 674
675 GrTexture* texture = 675 GrTexture* texture =
676 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); 676 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture());
677 int filtered_device_background_texture_id = texture->getTextureHandle(); 677 int filtered_device_background_texture_id = texture->getTextureHandle();
678 678
679 scoped_ptr<ScopedResource> background_texture = 679 scoped_ptr<ScopedResource> background_texture =
680 ScopedResource::create(resource_provider_); 680 ScopedResource::create(resource_provider_);
681 if (!background_texture->Allocate(quad->rect.size(), 681 if (!background_texture->Allocate(quad->rect.size(),
682 GL_RGBA, 682 ResourceProvider::TextureUsageFramebuffer,
683 ResourceProvider::TextureUsageFramebuffer)) 683 RGBA_8888))
684 return scoped_ptr<ScopedResource>(); 684 return scoped_ptr<ScopedResource>();
685 685
686 const RenderPass* target_render_pass = frame->current_render_pass; 686 const RenderPass* target_render_pass = frame->current_render_pass;
687 bool using_background_texture = 687 bool using_background_texture =
688 UseScopedTexture(frame, background_texture.get(), quad->rect); 688 UseScopedTexture(frame, background_texture.get(), quad->rect);
689 689
690 if (using_background_texture) { 690 if (using_background_texture) {
691 // Copy the readback pixels from device to the background texture for the 691 // Copy the readback pixels from device to the background texture for the
692 // surface. 692 // surface.
693 gfx::Transform device_to_framebuffer_transform; 693 gfx::Transform device_to_framebuffer_transform;
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 SkBitmap::kARGB_8888_Config, 1695 SkBitmap::kARGB_8888_Config,
1696 quad->texture_size.width(), 1696 quad->texture_size.width(),
1697 quad->texture_size.height()); 1697 quad->texture_size.height());
1698 on_demand_tile_raster_bitmap_.allocPixels(); 1698 on_demand_tile_raster_bitmap_.allocPixels();
1699 1699
1700 if (on_demand_tile_raster_resource_id_) 1700 if (on_demand_tile_raster_resource_id_)
1701 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 1701 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
1702 1702
1703 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( 1703 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture(
1704 quad->texture_size, 1704 quad->texture_size,
1705 GL_RGBA,
1706 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, 1705 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
1707 GL_CLAMP_TO_EDGE, 1706 GL_CLAMP_TO_EDGE,
1708 ResourceProvider::TextureUsageAny); 1707 ResourceProvider::TextureUsageAny,
1708 quad->texture_format);
1709 } 1709 }
1710 1710
1711 SkBitmapDevice device(on_demand_tile_raster_bitmap_); 1711 SkBitmapDevice device(on_demand_tile_raster_bitmap_);
1712 SkCanvas canvas(&device); 1712 SkCanvas canvas(&device);
1713 1713
1714 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, 1714 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect,
1715 quad->contents_scale, NULL); 1715 quad->contents_scale, NULL);
1716 1716
1717 uint8_t* bitmap_pixels = NULL;
1718 SkBitmap on_demand_tile_raster_bitmap_dest;
1719 SkBitmap::Config config = SkBitmapConfigFromFormat(quad->texture_format);
1720 if (on_demand_tile_raster_bitmap_.getConfig() != config) {
1721 on_demand_tile_raster_bitmap_.copyTo(&on_demand_tile_raster_bitmap_dest,
1722 config);
1723 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
1724 // bitmap data. This check will be removed once crbug.com/293728 is fixed.
1725 CHECK_EQ(0u, on_demand_tile_raster_bitmap_dest.rowBytes() % 4);
1726 bitmap_pixels = reinterpret_cast<uint8_t*>(
1727 on_demand_tile_raster_bitmap_dest.getPixels());
1728 } else {
1729 bitmap_pixels = reinterpret_cast<uint8_t*>(
1730 on_demand_tile_raster_bitmap_.getPixels());
1731 }
1732
1717 resource_provider_->SetPixels( 1733 resource_provider_->SetPixels(
1718 on_demand_tile_raster_resource_id_, 1734 on_demand_tile_raster_resource_id_,
1719 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), 1735 bitmap_pixels,
1720 gfx::Rect(quad->texture_size), 1736 gfx::Rect(quad->texture_size),
1721 gfx::Rect(quad->texture_size), 1737 gfx::Rect(quad->texture_size),
1722 gfx::Vector2d()); 1738 gfx::Vector2d());
1723 1739
1724 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); 1740 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_);
1725 } 1741 }
1726 1742
1727 struct TextureProgramBinding { 1743 struct TextureProgramBinding {
1728 template <class Program> 1744 template <class Program>
1729 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { 1745 void Set(Program* program, WebKit::WebGraphicsContext3D* context) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 unsigned int texture_id = context_->createTexture(); 2207 unsigned int texture_id = context_->createTexture();
2192 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2208 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
2193 GLC(context_, context_->texParameteri( 2209 GLC(context_, context_->texParameteri(
2194 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2210 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2195 GLC(context_, context_->texParameteri( 2211 GLC(context_, context_->texParameteri(
2196 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2212 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2197 GLC(context_, context_->texParameteri( 2213 GLC(context_, context_->texParameteri(
2198 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 2214 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2199 GLC(context_, context_->texParameteri( 2215 GLC(context_, context_->texParameteri(
2200 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 2216 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2201 GetFramebufferTexture(texture_id, GL_RGBA, window_rect); 2217 GetFramebufferTexture(texture_id, RGBA_8888, window_rect);
2202 2218
2203 gpu::Mailbox mailbox; 2219 gpu::Mailbox mailbox;
2204 unsigned sync_point = 0; 2220 unsigned sync_point = 0;
2205 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name)); 2221 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name));
2206 if (mailbox.IsZero()) { 2222 if (mailbox.IsZero()) {
2207 context_->deleteTexture(texture_id); 2223 context_->deleteTexture(texture_id);
2208 request->SendEmptyResult(); 2224 request->SendEmptyResult();
2209 return; 2225 return;
2210 } 2226 }
2211 2227
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2299 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2284 GLC(context_, context_->texParameteri( 2300 GLC(context_, context_->texParameteri(
2285 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2301 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2286 GLC(context_, context_->texParameteri( 2302 GLC(context_, context_->texParameteri(
2287 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 2303 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2288 GLC(context_, context_->texParameteri( 2304 GLC(context_, context_->texParameteri(
2289 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 2305 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2290 // Copy the contents of the current (IOSurface-backed) framebuffer into a 2306 // Copy the contents of the current (IOSurface-backed) framebuffer into a
2291 // temporary texture. 2307 // temporary texture.
2292 GetFramebufferTexture(temporary_texture, 2308 GetFramebufferTexture(temporary_texture,
2293 GL_RGBA, 2309 RGBA_8888,
2294 gfx::Rect(current_surface_size_)); 2310 gfx::Rect(current_surface_size_));
2295 temporary_fbo = context_->createFramebuffer(); 2311 temporary_fbo = context_->createFramebuffer();
2296 // Attach this texture to an FBO, and perform the readback from that FBO. 2312 // Attach this texture to an FBO, and perform the readback from that FBO.
2297 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo)); 2313 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo));
2298 GLC(context_, context_->framebufferTexture2D(GL_FRAMEBUFFER, 2314 GLC(context_, context_->framebufferTexture2D(GL_FRAMEBUFFER,
2299 GL_COLOR_ATTACHMENT0, 2315 GL_COLOR_ATTACHMENT0,
2300 GL_TEXTURE_2D, 2316 GL_TEXTURE_2D,
2301 temporary_texture, 2317 temporary_texture,
2302 0)); 2318 0));
2303 2319
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 scoped_ptr<SkAutoLockPixels> lock, 2449 scoped_ptr<SkAutoLockPixels> lock,
2434 scoped_ptr<CopyOutputRequest> request, 2450 scoped_ptr<CopyOutputRequest> request,
2435 bool success) { 2451 bool success) {
2436 DCHECK(request->force_bitmap_result()); 2452 DCHECK(request->force_bitmap_result());
2437 2453
2438 lock.reset(); 2454 lock.reset();
2439 if (success) 2455 if (success)
2440 request->SendBitmapResult(bitmap.Pass()); 2456 request->SendBitmapResult(bitmap.Pass());
2441 } 2457 }
2442 2458
2443 void GLRenderer::GetFramebufferTexture(unsigned texture_id, 2459 void GLRenderer::GetFramebufferTexture(
2444 unsigned texture_format, 2460 unsigned texture_id, ResourceFormat texture_format, gfx::Rect window_rect) {
2445 gfx::Rect window_rect) {
2446 DCHECK(texture_id); 2461 DCHECK(texture_id);
2447 DCHECK_GE(window_rect.x(), 0); 2462 DCHECK_GE(window_rect.x(), 0);
2448 DCHECK_GE(window_rect.y(), 0); 2463 DCHECK_GE(window_rect.y(), 0);
2449 DCHECK_LE(window_rect.right(), current_surface_size_.width()); 2464 DCHECK_LE(window_rect.right(), current_surface_size_.width());
2450 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); 2465 DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
2451 2466
2452 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2467 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
2453 GLC(context_, 2468 GLC(context_,
2454 context_->copyTexImage2D(GL_TEXTURE_2D, 2469 context_->copyTexImage2D(
2455 0, 2470 GL_TEXTURE_2D,
2456 texture_format, 2471 0,
2457 window_rect.x(), 2472 ResourceProvider::GetGLDataFormat(texture_format),
2458 window_rect.y(), 2473 window_rect.x(),
2459 window_rect.width(), 2474 window_rect.y(),
2460 window_rect.height(), 2475 window_rect.width(),
2461 0)); 2476 window_rect.height(),
2477 0));
2462 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 2478 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
2463 } 2479 }
2464 2480
2465 bool GLRenderer::UseScopedTexture(DrawingFrame* frame, 2481 bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
2466 const ScopedResource* texture, 2482 const ScopedResource* texture,
2467 gfx::Rect viewport_rect) { 2483 gfx::Rect viewport_rect) {
2468 DCHECK(texture->id()); 2484 DCHECK(texture->id());
2469 frame->current_render_pass = NULL; 2485 frame->current_render_pass = NULL;
2470 frame->current_texture = texture; 2486 frame->current_texture = texture;
2471 2487
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas 3128 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas
3113 // implementation. 3129 // implementation.
3114 return gr_context_ && context_->getContextAttributes().stencil; 3130 return gr_context_ && context_->getContextAttributes().stencil;
3115 } 3131 }
3116 3132
3117 bool GLRenderer::IsContextLost() { 3133 bool GLRenderer::IsContextLost() {
3118 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); 3134 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR);
3119 } 3135 }
3120 3136
3121 } // namespace cc 3137 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698