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

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: deprecate GLenum format throughout cc 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 ResourceProvider::TextureUsageAny,
666 ResourceProvider::TextureUsageAny)) { 666 ResourceProvider::RGBA_8888)) {
667 return scoped_ptr<ScopedResource>(); 667 return scoped_ptr<ScopedResource>();
668 } else { 668 } else {
669 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 669 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
670 device_background_texture->id()); 670 device_background_texture->id());
671 GetFramebufferTexture(lock.texture_id(), 671 GetFramebufferTexture(lock.texture_id(),
672 device_background_texture->format(), 672 device_background_texture->format(),
673 window_rect); 673 window_rect);
674 } 674 }
675 675
676 SkBitmap filtered_device_background = 676 SkBitmap filtered_device_background =
677 ApplyFilters(this, 677 ApplyFilters(this,
678 frame->offscreen_context_provider, 678 frame->offscreen_context_provider,
679 filters, 679 filters,
680 device_background_texture.get()); 680 device_background_texture.get());
681 if (!filtered_device_background.getTexture()) 681 if (!filtered_device_background.getTexture())
682 return scoped_ptr<ScopedResource>(); 682 return scoped_ptr<ScopedResource>();
683 683
684 GrTexture* texture = 684 GrTexture* texture =
685 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture()); 685 reinterpret_cast<GrTexture*>(filtered_device_background.getTexture());
686 int filtered_device_background_texture_id = texture->getTextureHandle(); 686 int filtered_device_background_texture_id = texture->getTextureHandle();
687 687
688 scoped_ptr<ScopedResource> background_texture = 688 scoped_ptr<ScopedResource> background_texture =
689 ScopedResource::create(resource_provider_); 689 ScopedResource::create(resource_provider_);
690 if (!background_texture->Allocate(quad->rect.size(), 690 if (!background_texture->Allocate(quad->rect.size(),
691 GL_RGBA, 691 ResourceProvider::TextureUsageFramebuffer,
692 ResourceProvider::TextureUsageFramebuffer)) 692 ResourceProvider::RGBA_8888))
693 return scoped_ptr<ScopedResource>(); 693 return scoped_ptr<ScopedResource>();
694 694
695 const RenderPass* target_render_pass = frame->current_render_pass; 695 const RenderPass* target_render_pass = frame->current_render_pass;
696 bool using_background_texture = 696 bool using_background_texture =
697 UseScopedTexture(frame, background_texture.get(), quad->rect); 697 UseScopedTexture(frame, background_texture.get(), quad->rect);
698 698
699 if (using_background_texture) { 699 if (using_background_texture) {
700 // Copy the readback pixels from device to the background texture for the 700 // Copy the readback pixels from device to the background texture for the
701 // surface. 701 // surface.
702 gfx::Transform device_to_framebuffer_transform; 702 gfx::Transform device_to_framebuffer_transform;
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 SkBitmap::kARGB_8888_Config, 1704 SkBitmap::kARGB_8888_Config,
1705 quad->texture_size.width(), 1705 quad->texture_size.width(),
1706 quad->texture_size.height()); 1706 quad->texture_size.height());
1707 on_demand_tile_raster_bitmap_.allocPixels(); 1707 on_demand_tile_raster_bitmap_.allocPixels();
1708 1708
1709 if (on_demand_tile_raster_resource_id_) 1709 if (on_demand_tile_raster_resource_id_)
1710 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 1710 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
1711 1711
1712 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( 1712 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture(
1713 quad->texture_size, 1713 quad->texture_size,
1714 GL_RGBA,
1715 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, 1714 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
1716 GL_CLAMP_TO_EDGE, 1715 GL_CLAMP_TO_EDGE,
1717 ResourceProvider::TextureUsageAny); 1716 ResourceProvider::TextureUsageAny,
1717 settings_->use_rgba_4444_textures
1718 ? ResourceProvider::RGBA_4444 : ResourceProvider::RGBA_8888);
1718 } 1719 }
1719 1720
1720 SkBitmapDevice device(on_demand_tile_raster_bitmap_); 1721 SkBitmapDevice device(on_demand_tile_raster_bitmap_);
1721 SkCanvas canvas(&device); 1722 SkCanvas canvas(&device);
1722 1723
1723 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, 1724 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect,
1724 quad->contents_scale, NULL); 1725 quad->contents_scale, NULL);
1725 1726
1727 const uint8_t* bitmap_pixels = NULL;
1728 if (settings_->use_rgba_4444_textures) {
1729 on_demand_tile_raster_bitmap_.copyTo(
1730 &on_demand_tile_raster_bitmap_4444_, SkBitmap::kARGB_4444_Config);
1731 bitmap_pixels = reinterpret_cast<uint8_t*>(
1732 on_demand_tile_raster_bitmap_4444_.getPixels());
1733 } else {
1734 bitmap_pixels = reinterpret_cast<uint8_t*>(
1735 on_demand_tile_raster_bitmap_.getPixels());
1736 }
1737
1738 LOG(ERROR) << "KAANB: on demand raster!!!!!!!!!!!!!!!!!!!!";
1739
1726 resource_provider_->SetPixels( 1740 resource_provider_->SetPixels(
1727 on_demand_tile_raster_resource_id_, 1741 on_demand_tile_raster_resource_id_,
1728 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), 1742 bitmap_pixels,
1729 gfx::Rect(quad->texture_size), 1743 gfx::Rect(quad->texture_size),
1730 gfx::Rect(quad->texture_size), 1744 gfx::Rect(quad->texture_size),
1731 gfx::Vector2d()); 1745 gfx::Vector2d());
1732 1746
1733 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); 1747 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_);
1734 } 1748 }
1735 1749
1736 struct TextureProgramBinding { 1750 struct TextureProgramBinding {
1737 template <class Program> 1751 template <class Program>
1738 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { 1752 void Set(Program* program, WebKit::WebGraphicsContext3D* context) {
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 unsigned int texture_id = context_->createTexture(); 2221 unsigned int texture_id = context_->createTexture();
2208 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2222 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
2209 GLC(context_, context_->texParameteri( 2223 GLC(context_, context_->texParameteri(
2210 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2224 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2211 GLC(context_, context_->texParameteri( 2225 GLC(context_, context_->texParameteri(
2212 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2226 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2213 GLC(context_, context_->texParameteri( 2227 GLC(context_, context_->texParameteri(
2214 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 2228 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2215 GLC(context_, context_->texParameteri( 2229 GLC(context_, context_->texParameteri(
2216 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 2230 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2217 GetFramebufferTexture(texture_id, GL_RGBA, window_rect); 2231 GetFramebufferTexture(texture_id, ResourceProvider::RGBA_8888, window_rect);
2218 2232
2219 gpu::Mailbox mailbox; 2233 gpu::Mailbox mailbox;
2220 unsigned sync_point = 0; 2234 unsigned sync_point = 0;
2221 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name)); 2235 GLC(context_, context_->genMailboxCHROMIUM(mailbox.name));
2222 if (mailbox.IsZero()) { 2236 if (mailbox.IsZero()) {
2223 context_->deleteTexture(texture_id); 2237 context_->deleteTexture(texture_id);
2224 request->SendEmptyResult(); 2238 request->SendEmptyResult();
2225 return; 2239 return;
2226 } 2240 }
2227 2241
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2313 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2300 GLC(context_, context_->texParameteri( 2314 GLC(context_, context_->texParameteri(
2301 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2315 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2302 GLC(context_, context_->texParameteri( 2316 GLC(context_, context_->texParameteri(
2303 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); 2317 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2304 GLC(context_, context_->texParameteri( 2318 GLC(context_, context_->texParameteri(
2305 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); 2319 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2306 // Copy the contents of the current (IOSurface-backed) framebuffer into a 2320 // Copy the contents of the current (IOSurface-backed) framebuffer into a
2307 // temporary texture. 2321 // temporary texture.
2308 GetFramebufferTexture(temporary_texture, 2322 GetFramebufferTexture(temporary_texture,
2309 GL_RGBA, 2323 ResourceProvider::RGBA_8888,
2310 gfx::Rect(current_surface_size_)); 2324 gfx::Rect(current_surface_size_));
2311 temporary_fbo = context_->createFramebuffer(); 2325 temporary_fbo = context_->createFramebuffer();
2312 // Attach this texture to an FBO, and perform the readback from that FBO. 2326 // Attach this texture to an FBO, and perform the readback from that FBO.
2313 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo)); 2327 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo));
2314 GLC(context_, context_->framebufferTexture2D(GL_FRAMEBUFFER, 2328 GLC(context_, context_->framebufferTexture2D(GL_FRAMEBUFFER,
2315 GL_COLOR_ATTACHMENT0, 2329 GL_COLOR_ATTACHMENT0,
2316 GL_TEXTURE_2D, 2330 GL_TEXTURE_2D,
2317 temporary_texture, 2331 temporary_texture,
2318 0)); 2332 0));
2319 2333
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 scoped_ptr<SkAutoLockPixels> lock, 2463 scoped_ptr<SkAutoLockPixels> lock,
2450 scoped_ptr<CopyOutputRequest> request, 2464 scoped_ptr<CopyOutputRequest> request,
2451 bool success) { 2465 bool success) {
2452 DCHECK(request->force_bitmap_result()); 2466 DCHECK(request->force_bitmap_result());
2453 2467
2454 lock.reset(); 2468 lock.reset();
2455 if (success) 2469 if (success)
2456 request->SendBitmapResult(bitmap.Pass()); 2470 request->SendBitmapResult(bitmap.Pass());
2457 } 2471 }
2458 2472
2459 void GLRenderer::GetFramebufferTexture(unsigned texture_id, 2473 void GLRenderer::GetFramebufferTexture(
2460 unsigned texture_format, 2474 unsigned texture_id,
2461 gfx::Rect window_rect) { 2475 ResourceProvider::TextureFormat texture_format,
2476 gfx::Rect window_rect) {
2462 DCHECK(texture_id); 2477 DCHECK(texture_id);
2463 DCHECK_GE(window_rect.x(), 0); 2478 DCHECK_GE(window_rect.x(), 0);
2464 DCHECK_GE(window_rect.y(), 0); 2479 DCHECK_GE(window_rect.y(), 0);
2465 DCHECK_LE(window_rect.right(), current_surface_size_.width()); 2480 DCHECK_LE(window_rect.right(), current_surface_size_.width());
2466 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); 2481 DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
2467 2482
2468 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2483 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
2469 GLC(context_, 2484 GLC(context_,
2470 context_->copyTexImage2D(GL_TEXTURE_2D, 2485 context_->copyTexImage2D(
2471 0, 2486 GL_TEXTURE_2D,
2472 texture_format, 2487 0,
2473 window_rect.x(), 2488 ResourceProvider::GetGLDataFormat(texture_format),
2474 window_rect.y(), 2489 window_rect.x(),
2475 window_rect.width(), 2490 window_rect.y(),
2476 window_rect.height(), 2491 window_rect.width(),
2477 0)); 2492 window_rect.height(),
2493 0));
2478 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 2494 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
2479 } 2495 }
2480 2496
2481 bool GLRenderer::UseScopedTexture(DrawingFrame* frame, 2497 bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
2482 const ScopedResource* texture, 2498 const ScopedResource* texture,
2483 gfx::Rect viewport_rect) { 2499 gfx::Rect viewport_rect) {
2484 DCHECK(texture->id()); 2500 DCHECK(texture->id());
2485 frame->current_render_pass = NULL; 2501 frame->current_render_pass = NULL;
2486 frame->current_texture = texture; 2502 frame->current_texture = texture;
2487 2503
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 return; 3156 return;
3141 offscreen_context_labelled_ = true; 3157 offscreen_context_labelled_ = true;
3142 std::string unique_context_name = base::StringPrintf( 3158 std::string unique_context_name = base::StringPrintf(
3143 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_); 3159 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_);
3144 offscreen_context_provider->Context3d() 3160 offscreen_context_provider->Context3d()
3145 ->pushGroupMarkerEXT(unique_context_name.c_str()); 3161 ->pushGroupMarkerEXT(unique_context_name.c_str());
3146 } 3162 }
3147 3163
3148 3164
3149 } // namespace cc 3165 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698