OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "GrVkPipeline.h" | 8 #include "GrVkPipeline.h" |
9 | 9 |
10 #include "GrGeometryProcessor.h" | 10 #include "GrGeometryProcessor.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 GrVkCommandBuffer* cmdBuffer, | 488 GrVkCommandBuffer* cmdBuffer, |
489 const GrPipeline& pipeline, | 489 const GrPipeline& pipeline, |
490 const GrRenderTarget& target) { | 490 const GrRenderTarget& target) { |
491 // We always use one scissor and if it is disabled we just make it the size
of the RT | 491 // We always use one scissor and if it is disabled we just make it the size
of the RT |
492 const GrScissorState& scissorState = pipeline.getScissorState(); | 492 const GrScissorState& scissorState = pipeline.getScissorState(); |
493 VkRect2D scissor; | 493 VkRect2D scissor; |
494 if (scissorState.enabled() && | 494 if (scissorState.enabled() && |
495 !scissorState.rect().contains(0, 0, target.width(), target.height())) { | 495 !scissorState.rect().contains(0, 0, target.width(), target.height())) { |
496 // This all assumes the scissorState has previously been clipped to the
device space render | 496 // This all assumes the scissorState has previously been clipped to the
device space render |
497 // target. | 497 // target. |
498 scissor.offset.x = scissorState.rect().fLeft; | 498 scissor.offset.x = SkTMax(scissorState.rect().fLeft, 0); |
499 scissor.extent.width = scissorState.rect().width(); | 499 scissor.extent.width = scissorState.rect().width(); |
500 if (kTopLeft_GrSurfaceOrigin == target.origin()) { | 500 if (kTopLeft_GrSurfaceOrigin == target.origin()) { |
501 scissor.offset.y = scissorState.rect().fTop; | 501 scissor.offset.y = scissorState.rect().fTop; |
502 } else { | 502 } else { |
503 SkASSERT(kBottomLeft_GrSurfaceOrigin == target.origin()); | 503 SkASSERT(kBottomLeft_GrSurfaceOrigin == target.origin()); |
504 scissor.offset.y = target.height() - scissorState.rect().fBottom; | 504 scissor.offset.y = target.height() - scissorState.rect().fBottom; |
505 } | 505 } |
| 506 scissor.offset.y = SkTMax(scissor.offset.y, 0); |
506 scissor.extent.height = scissorState.rect().height(); | 507 scissor.extent.height = scissorState.rect().height(); |
507 | 508 |
508 SkASSERT(scissor.offset.x >= 0); | 509 SkASSERT(scissor.offset.x >= 0); |
509 SkASSERT(scissor.offset.x + scissor.extent.width <= (uint32_t)target.wid
th()); | |
510 SkASSERT(scissor.offset.y >= 0); | 510 SkASSERT(scissor.offset.y >= 0); |
511 SkASSERT(scissor.offset.y + scissor.extent.height <= (uint32_t)target.he
ight()); | |
512 } else { | 511 } else { |
513 scissor.extent.width = target.width(); | 512 scissor.extent.width = target.width(); |
514 scissor.extent.height = target.height(); | 513 scissor.extent.height = target.height(); |
515 scissor.offset.x = 0; | 514 scissor.offset.x = 0; |
516 scissor.offset.y = 0; | 515 scissor.offset.y = 0; |
517 } | 516 } |
518 cmdBuffer->setScissor(gpu, 0, 1, &scissor); | 517 cmdBuffer->setScissor(gpu, 0, 1, &scissor); |
519 } | 518 } |
520 | 519 |
521 void set_dynamic_viewport_state(GrVkGpu* gpu, | 520 void set_dynamic_viewport_state(GrVkGpu* gpu, |
(...skipping 27 matching lines...) Expand all Loading... |
549 } | 548 } |
550 | 549 |
551 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, | 550 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, |
552 GrVkCommandBuffer* cmdBuffer, | 551 GrVkCommandBuffer* cmdBuffer, |
553 const GrPipeline& pipeline) { | 552 const GrPipeline& pipeline) { |
554 const GrRenderTarget& target = *pipeline.getRenderTarget(); | 553 const GrRenderTarget& target = *pipeline.getRenderTarget(); |
555 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); | 554 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); |
556 set_dynamic_viewport_state(gpu, cmdBuffer, target); | 555 set_dynamic_viewport_state(gpu, cmdBuffer, target); |
557 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); | 556 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); |
558 } | 557 } |
OLD | NEW |