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

Side by Side Diff: src/gpu/GrDrawTarget.cpp

Issue 2113303002: Use bounds of batches for render pass bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix int to scalar Created 4 years, 5 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 | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrDrawTarget.h" 8 #include "GrDrawTarget.h"
9 9
10 #include "GrAuditTrail.h" 10 #include "GrAuditTrail.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (fInstancedRendering) { 208 if (fInstancedRendering) {
209 fInstancedRendering->beginFlush(flushState->resourceProvider()); 209 fInstancedRendering->beginFlush(flushState->resourceProvider());
210 } 210 }
211 } 211 }
212 212
213 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { 213 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
214 // Draw all the generated geometry. 214 // Draw all the generated geometry.
215 SkRandom random; 215 SkRandom random;
216 GrRenderTarget* currentRT = nullptr; 216 GrRenderTarget* currentRT = nullptr;
217 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer; 217 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer;
218 SkRect bounds = SkRect::MakeEmpty();
218 for (int i = 0; i < fBatches.count(); ++i) { 219 for (int i = 0; i < fBatches.count(); ++i) {
219 if (!fBatches[i]) { 220 if (!fBatches[i]) {
220 continue; 221 continue;
221 } 222 }
222 if (fBatches[i]->renderTarget() != currentRT) { 223 if (fBatches[i]->renderTarget() != currentRT) {
223 if (commandBuffer) { 224 if (commandBuffer) {
224 commandBuffer->end(); 225 commandBuffer->end();
225 // For now just use size of whole render target, but this should be updated to 226 if (bounds.intersect(0, 0,
226 // only be the actual bounds of the various draws. 227 SkIntToScalar(currentRT->width()),
227 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT-> height()); 228 SkIntToScalar(currentRT->height()))) {
228 commandBuffer->submit(bounds); 229 SkIRect iBounds;
230 bounds.roundOut(&iBounds);
231 commandBuffer->submit(iBounds);
232 }
229 commandBuffer.reset(); 233 commandBuffer.reset();
230 } 234 }
235 bounds.setEmpty();
231 currentRT = fBatches[i]->renderTarget(); 236 currentRT = fBatches[i]->renderTarget();
232 if (currentRT) { 237 if (currentRT) {
233 static const GrGpuCommandBuffer::LoadAndStoreInfo kBasicLoadStor eInfo 238 static const GrGpuCommandBuffer::LoadAndStoreInfo kBasicLoadStor eInfo
234 { GrGpuCommandBuffer::LoadOp::kLoad,GrGpuCommandBuffer::Stor eOp::kStore, 239 { GrGpuCommandBuffer::LoadOp::kLoad,GrGpuCommandBuffer::Stor eOp::kStore,
235 GrColor_ILLEGAL }; 240 GrColor_ILLEGAL };
236 commandBuffer.reset(fGpu->createCommandBuffer(currentRT, 241 commandBuffer.reset(fGpu->createCommandBuffer(currentRT,
237 kBasicLoadStoreInf o, // Color 242 kBasicLoadStoreInf o, // Color
238 kBasicLoadStoreInf o)); // Stencil 243 kBasicLoadStoreInf o)); // Stencil
239 } 244 }
240 flushState->setCommandBuffer(commandBuffer); 245 flushState->setCommandBuffer(commandBuffer);
241 } 246 }
247 if (commandBuffer) {
248 bounds.join(fBatches[i]->bounds());
249 }
242 if (fDrawBatchBounds) { 250 if (fDrawBatchBounds) {
243 const SkRect& bounds = fBatches[i]->bounds(); 251 const SkRect& batchBounds = fBatches[i]->bounds();
244 SkIRect ibounds; 252 SkIRect iBatchBounds;
245 bounds.roundOut(&ibounds); 253 batchBounds.roundOut(&iBatchBounds);
246 // In multi-draw buffer all the batches use the same render target a nd we won't need to 254 // In multi-draw buffer all the batches use the same render target a nd we won't need to
247 // get the batchs bounds. 255 // get the batchs bounds.
248 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { 256 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) {
249 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() ); 257 fGpu->drawDebugWireRect(rt, iBatchBounds, 0xFF000000 | random.ne xtU());
250 } 258 }
251 } 259 }
252 fBatches[i]->draw(flushState); 260 fBatches[i]->draw(flushState);
253 } 261 }
254 if (commandBuffer) { 262 if (commandBuffer) {
255 commandBuffer->end(); 263 commandBuffer->end();
256 // For now just use size of whole render target, but this should be upda ted to 264 if (bounds.intersect(0, 0,
257 // only be the actual bounds of the various draws. 265 SkIntToScalar(currentRT->width()),
258 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height() ); 266 SkIntToScalar(currentRT->height()))) {
259 commandBuffer->submit(bounds); 267 SkIRect iBounds;
268 bounds.roundOut(&iBounds);
269 commandBuffer->submit(iBounds);
270 }
260 flushState->setCommandBuffer(nullptr); 271 flushState->setCommandBuffer(nullptr);
261 } 272 }
262 273
263 fGpu->finishDrawTarget(); 274 fGpu->finishDrawTarget();
264 } 275 }
265 276
266 void GrDrawTarget::reset() { 277 void GrDrawTarget::reset() {
267 fBatches.reset(); 278 fBatches.reset();
268 if (fInstancedRendering) { 279 if (fInstancedRendering) {
269 fInstancedRendering->endFlush(); 280 fInstancedRendering->endFlush();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 572 }
562 } 573 }
563 574
564 /////////////////////////////////////////////////////////////////////////////// 575 ///////////////////////////////////////////////////////////////////////////////
565 576
566 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 577 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
567 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 578 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
568 this->recordBatch(batch); 579 this->recordBatch(batch);
569 batch->unref(); 580 batch->unref();
570 } 581 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698