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

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

Issue 1884553003: cc: optimize texture allocation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 7 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 | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 case SkXfermode::kColor_Mode: 134 case SkXfermode::kColor_Mode:
135 return BLEND_MODE_COLOR; 135 return BLEND_MODE_COLOR;
136 case SkXfermode::kLuminosity_Mode: 136 case SkXfermode::kLuminosity_Mode:
137 return BLEND_MODE_LUMINOSITY; 137 return BLEND_MODE_LUMINOSITY;
138 default: 138 default:
139 NOTREACHED(); 139 NOTREACHED();
140 return BLEND_MODE_NONE; 140 return BLEND_MODE_NONE;
141 } 141 }
142 } 142 }
143 143
144 void RoundUpToPow2(gfx::RectF* rect) {
145 int w, h;
danakj 2016/05/04 21:24:58 you're using ints here but it's a RectF.
Stephen White 2016/05/04 21:27:31 Yep. There are implicit casts in the comparisons a
146 for (w = 1; w < rect->width(); w *= 2) {
enne (OOO) 2016/05/04 21:32:22 If you're casting to ints here for performance, mi
Stephen White 2016/05/04 21:47:17 Cute! I don't really care about performance here;
147 }
148 for (h = 1; h < rect->height(); h *= 2) {
149 }
150 rect->set_width(w);
151 rect->set_height(h);
152 }
153
144 // Smallest unit that impact anti-aliasing output. We use this to 154 // Smallest unit that impact anti-aliasing output. We use this to
145 // determine when anti-aliasing is unnecessary. 155 // determine when anti-aliasing is unnecessary.
146 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; 156 const float kAntiAliasingEpsilon = 1.0f / 1024.0f;
147 157
148 // Block or crash if the number of pending sync queries reach this high as 158 // Block or crash if the number of pending sync queries reach this high as
149 // something is seriously wrong on the service side if this happens. 159 // something is seriously wrong on the service side if this happens.
150 const size_t kMaxPendingSyncQueries = 16; 160 const size_t kMaxPendingSyncQueries = 16;
151 161
152 } // anonymous namespace 162 } // anonymous namespace
153 163
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 gfx::Transform transform = 1035 gfx::Transform transform =
1026 quad->shared_quad_state->quad_to_target_transform; 1036 quad->shared_quad_state->quad_to_target_transform;
1027 gfx::QuadF clip_quad = gfx::QuadF(gfx::RectF(clip_rect)); 1037 gfx::QuadF clip_quad = gfx::QuadF(gfx::RectF(clip_rect));
1028 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad); 1038 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad);
1029 dst_rect.Intersect(local_clip.BoundingBox()); 1039 dst_rect.Intersect(local_clip.BoundingBox());
1030 // If we've been fully clipped out (by crop rect or clipping), there's 1040 // If we've been fully clipped out (by crop rect or clipping), there's
1031 // nothing to draw. 1041 // nothing to draw.
1032 if (dst_rect.IsEmpty()) { 1042 if (dst_rect.IsEmpty()) {
1033 return; 1043 return;
1034 } 1044 }
1045 // Expand dst_rect size to the nearest power of 2, in order to get
enne (OOO) 2016/05/04 21:32:22 Are there limits on the size that is supported her
Stephen White 2016/05/04 21:47:17 If you mean, will the allocation fail due to an in
1046 // more cache hits in Skia's texture cache.
1047 RoundUpToPow2(&dst_rect);
1035 filter_image = ApplyImageFilter( 1048 filter_image = ApplyImageFilter(
1036 ScopedUseGrContext::Create(this, frame), resource_provider_, rect, 1049 ScopedUseGrContext::Create(this, frame), resource_provider_, rect,
1037 dst_rect, scale, std::move(filter), contents_texture); 1050 dst_rect, scale, std::move(filter), contents_texture);
1038 if (filter_image) { 1051 if (filter_image) {
1039 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo( 1052 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo(
1040 filter_image->getTextureHandle(true)) 1053 filter_image->getTextureHandle(true))
1041 ->fID; 1054 ->fID;
1042 DCHECK(filter_image_id); 1055 DCHECK(filter_image_id);
1043 rect = dst_rect; 1056 rect = dst_rect;
1044 } 1057 }
(...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after
3648 texture_id = pending_overlay_resources_.back()->texture_id(); 3661 texture_id = pending_overlay_resources_.back()->texture_id();
3649 } 3662 }
3650 3663
3651 context_support_->ScheduleOverlayPlane( 3664 context_support_->ScheduleOverlayPlane(
3652 overlay.plane_z_order, overlay.transform, texture_id, 3665 overlay.plane_z_order, overlay.transform, texture_id,
3653 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3666 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3654 } 3667 }
3655 } 3668 }
3656 3669
3657 } // namespace cc 3670 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698