OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1569 } | 1569 } |
1570 target->discard(renderTarget); | 1570 target->discard(renderTarget); |
1571 } | 1571 } |
1572 | 1572 |
1573 void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLeft) { | 1573 void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLeft) { |
1574 if (NULL == src || NULL == dst) { | 1574 if (NULL == src || NULL == dst) { |
1575 return; | 1575 return; |
1576 } | 1576 } |
1577 ASSERT_OWNED_RESOURCE(src); | 1577 ASSERT_OWNED_RESOURCE(src); |
1578 | 1578 |
1579 | |
1580 if (src->hasPendingWrite() || dst->hasPendingIO()) { | |
1581 this->flush(); | |
Justin Novosad
2014/09/26 18:48:23
Pretty sure this is no longer necessary now that w
bsalomon
2014/09/26 18:50:37
correct
| |
1582 } | |
1583 | |
1584 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit); | |
1585 GrDrawState* drawState = fGpu->drawState(); | |
1586 drawState->setRenderTarget(dst); | |
1587 SkMatrix sampleM; | |
1588 sampleM.setIDiv(src->width(), src->height()); | |
1589 SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height()); | 1579 SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height()); |
1590 if (topLeft) { | 1580 if (topLeft) { |
1591 srcRect.offset(*topLeft); | 1581 srcRect.offset(*topLeft); |
1592 } | 1582 } |
1593 SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height()); | 1583 SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height()); |
1594 if (!srcRect.intersect(srcBounds)) { | 1584 if (!srcRect.intersect(srcBounds)) { |
1595 return; | 1585 return; |
1596 } | 1586 } |
1597 sampleM.preTranslate(SkIntToScalar(srcRect.fLeft), SkIntToScalar(srcRect.fTo p)); | 1587 |
1598 drawState->addColorTextureProcessor(src, sampleM); | 1588 AutoRestoreEffects are; |
1599 SkRect dstR = SkRect::MakeWH(SkIntToScalar(srcRect.width()), SkIntToScalar(s rcRect.height())); | 1589 AutoCheckFlush acf(this); |
1600 fGpu->drawSimpleRect(dstR); | 1590 GrDrawTarget* target = this->prepareToDraw(NULL, BUFFERED_DRAW, &are, &acf); |
Justin Novosad
2014/09/26 18:48:23
This is just boilerplate stuff that I cargo-culted
| |
1591 if (NULL == target) { | |
1592 return; | |
1593 } | |
1594 SkIPoint dstPoint; | |
1595 dstPoint.setZero(); | |
1596 target->copySurface(dst, src, srcRect, dstPoint); | |
1601 } | 1597 } |
1602 | 1598 |
1603 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, | 1599 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, |
1604 int left, int top, int width, int height , | 1600 int left, int top, int width, int height , |
1605 GrPixelConfig srcConfig, | 1601 GrPixelConfig srcConfig, |
1606 const void* buffer, | 1602 const void* buffer, |
1607 size_t rowBytes, | 1603 size_t rowBytes, |
1608 uint32_t flags) { | 1604 uint32_t flags) { |
1609 ASSERT_OWNED_RESOURCE(target); | 1605 ASSERT_OWNED_RESOURCE(target); |
1610 | 1606 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1944 fResourceCache->printStats(); | 1940 fResourceCache->printStats(); |
1945 } | 1941 } |
1946 #endif | 1942 #endif |
1947 | 1943 |
1948 #if GR_GPU_STATS | 1944 #if GR_GPU_STATS |
1949 const GrContext::GPUStats* GrContext::gpuStats() const { | 1945 const GrContext::GPUStats* GrContext::gpuStats() const { |
1950 return fGpu->gpuStats(); | 1946 return fGpu->gpuStats(); |
1951 } | 1947 } |
1952 #endif | 1948 #endif |
1953 | 1949 |
OLD | NEW |