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

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

Issue 1643653002: cc: make partially-resident textures use 1 - y, not h - y. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More plausible mask fix; new test Created 4 years, 11 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/direct_renderer.cc ('k') | cc/output/renderer_pixeltest.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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 SkImageInfo dst_info = 638 SkImageInfo dst_info =
639 SkImageInfo::MakeN32Premul(dst_rect.width(), dst_rect.height()); 639 SkImageInfo::MakeN32Premul(dst_rect.width(), dst_rect.height());
640 skia::RefPtr<SkSurface> surface = skia::AdoptRef(SkSurface::NewRenderTarget( 640 skia::RefPtr<SkSurface> surface = skia::AdoptRef(SkSurface::NewRenderTarget(
641 use_gr_context->context(), SkSurface::kYes_Budgeted, dst_info, 0)); 641 use_gr_context->context(), SkSurface::kYes_Budgeted, dst_info, 0));
642 if (!surface) { 642 if (!surface) {
643 TRACE_EVENT_INSTANT0("cc", "ApplyImageFilter surface allocation failed", 643 TRACE_EVENT_INSTANT0("cc", "ApplyImageFilter surface allocation failed",
644 TRACE_EVENT_SCOPE_THREAD); 644 TRACE_EVENT_SCOPE_THREAD);
645 return skia::RefPtr<SkImage>(); 645 return skia::RefPtr<SkImage>();
646 } 646 }
647 647
648 // The origin of the filter is top-left and the origin of the source is
649 // bottom-left, but the orientation is the same, so we must translate the
650 // filter so that it renders at the bottom of the texture to avoid
651 // misregistration.
652 float y_offset = source_texture_resource->size().height() - src_rect.height();
653 SkMatrix local_matrix; 648 SkMatrix local_matrix;
654 local_matrix.setScale(scale.x(), scale.y()); 649 local_matrix.setScale(scale.x(), scale.y());
655 skia::RefPtr<SkImageFilter> filter_with_local_scale = 650 skia::RefPtr<SkImageFilter> filter_with_local_scale =
656 skia::AdoptRef(filter->newWithLocalMatrix(local_matrix)); 651 skia::AdoptRef(filter->newWithLocalMatrix(local_matrix));
657 652
658 SkPaint paint; 653 SkPaint paint;
659 paint.setImageFilter(filter_with_local_scale.get()); 654 paint.setImageFilter(filter_with_local_scale.get());
660 surface->getCanvas()->translate(-dst_rect.x(), -dst_rect.y()); 655 surface->getCanvas()->translate(-dst_rect.x(), -dst_rect.y());
661 surface->getCanvas()->drawImage(srcImage.get(), src_rect.x(), 656 surface->getCanvas()->drawImage(srcImage.get(), src_rect.x(), src_rect.y(),
662 src_rect.y() - y_offset, &paint); 657 &paint);
663 658
664 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot()); 659 skia::RefPtr<SkImage> image = skia::AdoptRef(surface->newImageSnapshot());
665 if (!image || !image->isTextureBacked()) { 660 if (!image || !image->isTextureBacked()) {
666 return skia::RefPtr<SkImage>(); 661 return skia::RefPtr<SkImage>();
667 } 662 }
668 663
669 CHECK(image->isTextureBacked()); 664 CHECK(image->isTextureBacked());
670 return image; 665 return image;
671 } 666 }
672 667
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 tex_scale_y = quad->rect.height() / 1131 tex_scale_y = quad->rect.height() /
1137 static_cast<float>(contents_texture->size().height()); 1132 static_cast<float>(contents_texture->size().height());
1138 } 1133 }
1139 DCHECK_LE(tex_scale_x, 1.0f); 1134 DCHECK_LE(tex_scale_x, 1.0f);
1140 DCHECK_LE(tex_scale_y, 1.0f); 1135 DCHECK_LE(tex_scale_y, 1.0f);
1141 1136
1142 DCHECK(locations.tex_transform != -1 || IsContextLost()); 1137 DCHECK(locations.tex_transform != -1 || IsContextLost());
1143 // Flip the content vertically in the shader, as the RenderPass input 1138 // Flip the content vertically in the shader, as the RenderPass input
1144 // texture is already oriented the same way as the framebuffer, but the 1139 // texture is already oriented the same way as the framebuffer, but the
1145 // projection transform does a flip. 1140 // projection transform does a flip.
1146 gl_->Uniform4f(locations.tex_transform, 0.0f, tex_scale_y, tex_scale_x, 1141 gl_->Uniform4f(locations.tex_transform, 0.0f, 1.0f, tex_scale_x,
1147 -tex_scale_y); 1142 -tex_scale_y);
1148 1143
1149 GLint last_texture_unit = 0; 1144 GLint last_texture_unit = 0;
1150 if (locations.mask_sampler != -1) { 1145 if (locations.mask_sampler != -1) {
1151 DCHECK_NE(locations.mask_tex_coord_scale, 1); 1146 DCHECK_NE(locations.mask_tex_coord_scale, 1);
1152 DCHECK_NE(locations.mask_tex_coord_offset, 1); 1147 DCHECK_NE(locations.mask_tex_coord_offset, 1);
1153 gl_->Uniform1i(locations.mask_sampler, 1); 1148 gl_->Uniform1i(locations.mask_sampler, 1);
1154 1149
1155 gfx::RectF mask_uv_rect = quad->MaskUVRect(); 1150 gfx::RectF mask_uv_rect = quad->MaskUVRect();
1156 if (mask_sampler != SAMPLER_TYPE_2D) { 1151 if (mask_sampler != SAMPLER_TYPE_2D) {
1157 mask_uv_rect.Scale(quad->mask_texture_size.width(), 1152 mask_uv_rect.Scale(quad->mask_texture_size.width(),
1158 quad->mask_texture_size.height()); 1153 quad->mask_texture_size.height());
1159 } 1154 }
1160 1155
1161 // Mask textures are oriented vertically flipped relative to the framebuffer 1156 // Mask textures are oriented vertically flipped relative to the framebuffer
1162 // and the RenderPass contents texture, so we flip the tex coords from the 1157 // and the RenderPass contents texture, so we flip the tex coords from the
1163 // RenderPass texture to find the mask texture coords. 1158 // RenderPass texture to find the mask texture coords.
1164 gl_->Uniform2f(locations.mask_tex_coord_offset, mask_uv_rect.x(), 1159 gl_->Uniform2f(locations.mask_tex_coord_offset, mask_uv_rect.x(),
1165 mask_uv_rect.bottom()); 1160 mask_uv_rect.height() / tex_scale_y + mask_uv_rect.y());
1166 gl_->Uniform2f(locations.mask_tex_coord_scale, 1161 gl_->Uniform2f(locations.mask_tex_coord_scale,
1167 mask_uv_rect.width() / tex_scale_x, 1162 mask_uv_rect.width() / tex_scale_x,
1168 -mask_uv_rect.height() / tex_scale_y); 1163 -mask_uv_rect.height() / tex_scale_y);
1169 1164
1170 last_texture_unit = 1; 1165 last_texture_unit = 1;
1171 } 1166 }
1172 1167
1173 if (locations.edge != -1) 1168 if (locations.edge != -1)
1174 gl_->Uniform3fv(locations.edge, 8, edge); 1169 gl_->Uniform3fv(locations.edge, 8, edge);
1175 1170
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 texture_id = pending_overlay_resources_.back()->texture_id(); 3607 texture_id = pending_overlay_resources_.back()->texture_id();
3613 } 3608 }
3614 3609
3615 context_support_->ScheduleOverlayPlane( 3610 context_support_->ScheduleOverlayPlane(
3616 overlay.plane_z_order, overlay.transform, texture_id, 3611 overlay.plane_z_order, overlay.transform, texture_id,
3617 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3612 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3618 } 3613 }
3619 } 3614 }
3620 3615
3621 } // namespace cc 3616 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698