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

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

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and feedback 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
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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 int top, right, bottom, left; 655 int top, right, bottom, left;
656 filters.GetOutsets(&top, &right, &bottom, &left); 656 filters.GetOutsets(&top, &right, &bottom, &left);
657 window_rect.Inset(-left, -top, -right, -bottom); 657 window_rect.Inset(-left, -top, -right, -bottom);
658 658
659 window_rect.Intersect( 659 window_rect.Intersect(
660 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); 660 MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect));
661 661
662 scoped_ptr<ScopedResource> device_background_texture = 662 scoped_ptr<ScopedResource> device_background_texture =
663 ScopedResource::create(resource_provider_); 663 ScopedResource::create(resource_provider_);
664 if (!device_background_texture->Allocate(window_rect.size(), 664 if (!device_background_texture->Allocate(window_rect.size(),
665 GL_RGB, 665 GL_RGBA,
vangelis 2013/09/11 06:11:37 Is the switch from RGB to RGBA done on purpose her
kaanb 2013/09/12 07:53:44 Yes, epenner@ thought it was a bug we were using G
666 ResourceProvider::TextureUsageAny)) { 666 ResourceProvider::TextureUsageAny,
667 ResourceProvider::RGBA_8888)) {
667 return scoped_ptr<ScopedResource>(); 668 return scoped_ptr<ScopedResource>();
668 } else { 669 } else {
669 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 670 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
670 device_background_texture->id()); 671 device_background_texture->id());
671 GetFramebufferTexture(lock.texture_id(), 672 GetFramebufferTexture(lock.texture_id(),
672 device_background_texture->format(), 673 device_background_texture->format(),
673 window_rect); 674 window_rect);
674 } 675 }
675 676
676 SkBitmap filtered_device_background = 677 SkBitmap filtered_device_background =
677 ApplyFilters(this, 678 ApplyFilters(this,
678 frame->offscreen_context_provider, 679 frame->offscreen_context_provider,
679 filters, 680 filters,
680 device_background_texture.get()); 681 device_background_texture.get());
681 if (!filtered_device_background.getTexture()) 682 if (!filtered_device_background.getTexture())
682 return scoped_ptr<ScopedResource>(); 683 return scoped_ptr<ScopedResource>();
683 684
684 GrTexture* texture = 685 GrTexture* texture =
685 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); 686 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture());
686 int filtered_device_background_texture_id = texture->getTextureHandle(); 687 int filtered_device_background_texture_id = texture->getTextureHandle();
687 688
688 scoped_ptr<ScopedResource> background_texture = 689 scoped_ptr<ScopedResource> background_texture =
689 ScopedResource::create(resource_provider_); 690 ScopedResource::create(resource_provider_);
690 if (!background_texture->Allocate(quad->rect.size(), 691 if (!background_texture->Allocate(quad->rect.size(),
691 GL_RGBA, 692 GL_RGBA,
692 ResourceProvider::TextureUsageFramebuffer)) 693 ResourceProvider::TextureUsageFramebuffer,
694 ResourceProvider::RGBA_8888))
693 return scoped_ptr<ScopedResource>(); 695 return scoped_ptr<ScopedResource>();
694 696
695 const RenderPass* target_render_pass = frame->current_render_pass; 697 const RenderPass* target_render_pass = frame->current_render_pass;
696 bool using_background_texture = 698 bool using_background_texture =
697 UseScopedTexture(frame, background_texture.get(), quad->rect); 699 UseScopedTexture(frame, background_texture.get(), quad->rect);
698 700
699 if (using_background_texture) { 701 if (using_background_texture) {
700 // Copy the readback pixels from device to the background texture for the 702 // Copy the readback pixels from device to the background texture for the
701 // surface. 703 // surface.
702 gfx::Transform device_to_framebuffer_transform; 704 gfx::Transform device_to_framebuffer_transform;
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 on_demand_tile_raster_bitmap_.allocPixels(); 1709 on_demand_tile_raster_bitmap_.allocPixels();
1708 1710
1709 if (on_demand_tile_raster_resource_id_) 1711 if (on_demand_tile_raster_resource_id_)
1710 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 1712 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
1711 1713
1712 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( 1714 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture(
1713 quad->texture_size, 1715 quad->texture_size,
1714 GL_RGBA, 1716 GL_RGBA,
1715 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, 1717 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
1716 GL_CLAMP_TO_EDGE, 1718 GL_CLAMP_TO_EDGE,
1717 ResourceProvider::TextureUsageAny); 1719 ResourceProvider::TextureUsageAny,
1720 settings_->use_rgba_4444_textures
1721 ? ResourceProvider::RGBA_4444 : ResourceProvider::RGBA_8888);
1718 } 1722 }
1719 1723
1720 SkBitmapDevice device(on_demand_tile_raster_bitmap_); 1724 SkBitmapDevice device(on_demand_tile_raster_bitmap_);
1721 SkCanvas canvas(&device); 1725 SkCanvas canvas(&device);
1722 1726
1723 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, 1727 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect,
1724 quad->contents_scale, NULL); 1728 quad->contents_scale, NULL);
1725 1729
1730 const uint8_t* bitmap_pixels = NULL;
1731 if (settings_->use_rgba_4444_textures) {
1732 on_demand_tile_raster_bitmap_.copyTo(
1733 &on_demand_tile_raster_bitmap_4444_, SkBitmap::kARGB_4444_Config);
1734 bitmap_pixels = reinterpret_cast<uint8_t*>(
1735 on_demand_tile_raster_bitmap_4444_.getPixels());
1736 } else {
1737 bitmap_pixels = reinterpret_cast<uint8_t*>(
1738 on_demand_tile_raster_bitmap_.getPixels());
1739 }
1740
1726 resource_provider_->SetPixels( 1741 resource_provider_->SetPixels(
1727 on_demand_tile_raster_resource_id_, 1742 on_demand_tile_raster_resource_id_,
1728 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), 1743 bitmap_pixels,
1729 gfx::Rect(quad->texture_size), 1744 gfx::Rect(quad->texture_size),
1730 gfx::Rect(quad->texture_size), 1745 gfx::Rect(quad->texture_size),
1731 gfx::Vector2d()); 1746 gfx::Vector2d());
1732 1747
1733 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); 1748 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_);
1734 } 1749 }
1735 1750
1736 struct TextureProgramBinding { 1751 struct TextureProgramBinding {
1737 template <class Program> 1752 template <class Program>
1738 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { 1753 void Set(Program* program, WebKit::WebGraphicsContext3D* context) {
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 return; 3155 return;
3141 offscreen_context_labelled_ = true; 3156 offscreen_context_labelled_ = true;
3142 std::string unique_context_name = base::StringPrintf( 3157 std::string unique_context_name = base::StringPrintf(
3143 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_); 3158 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_);
3144 offscreen_context_provider->Context3d() 3159 offscreen_context_provider->Context3d()
3145 ->pushGroupMarkerEXT(unique_context_name.c_str()); 3160 ->pushGroupMarkerEXT(unique_context_name.c_str());
3146 } 3161 }
3147 3162
3148 3163
3149 } // namespace cc 3164 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698