| 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 if (NULL == target) { | 1569 if (NULL == target) { |
| 1570 return; | 1570 return; |
| 1571 } | 1571 } |
| 1572 target->discard(renderTarget); | 1572 target->discard(renderTarget); |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint*
topLeft) { | 1575 void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint*
topLeft) { |
| 1576 if (NULL == src || NULL == dst) { | 1576 if (NULL == src || NULL == dst) { |
| 1577 return; | 1577 return; |
| 1578 } | 1578 } |
| 1579 |
| 1579 ASSERT_OWNED_RESOURCE(src); | 1580 ASSERT_OWNED_RESOURCE(src); |
| 1580 | 1581 ASSERT_OWNED_RESOURCE(dst); |
| 1581 | 1582 |
| 1582 if (src->hasPendingWrite() || dst->hasPendingIO()) { | 1583 if (src->hasPendingWrite() || dst->hasPendingIO()) { |
| 1583 this->flush(); | 1584 this->flush(); |
| 1584 } | 1585 } |
| 1585 | 1586 |
| 1586 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit); | 1587 GrDrawTarget* target = this->prepareToDraw(NULL, kYes_BufferedDraw, NULL, NU
LL); |
| 1587 GrDrawState* drawState = fGpu->drawState(); | 1588 GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kReset_ASRInit); |
| 1589 GrDrawState* drawState = target->drawState(); |
| 1590 |
| 1591 drawState->disableState(GrDrawState::kClip_StateBit); |
| 1588 drawState->setRenderTarget(dst); | 1592 drawState->setRenderTarget(dst); |
| 1593 |
| 1589 SkMatrix sampleM; | 1594 SkMatrix sampleM; |
| 1590 sampleM.setIDiv(src->width(), src->height()); | 1595 sampleM.setIDiv(src->width(), src->height()); |
| 1591 SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height()); | 1596 SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height()); |
| 1592 if (topLeft) { | 1597 if (topLeft) { |
| 1593 srcRect.offset(*topLeft); | 1598 srcRect.offset(*topLeft); |
| 1594 } | 1599 } |
| 1595 SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height()); | 1600 SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height()); |
| 1596 if (!srcRect.intersect(srcBounds)) { | 1601 if (!srcRect.intersect(srcBounds)) { |
| 1597 return; | 1602 return; |
| 1598 } | 1603 } |
| 1599 sampleM.preTranslate(SkIntToScalar(srcRect.fLeft), SkIntToScalar(srcRect.fTo
p)); | 1604 sampleM.preTranslate(SkIntToScalar(srcRect.fLeft), SkIntToScalar(srcRect.fTo
p)); |
| 1600 drawState->addColorTextureEffect(src, sampleM); | 1605 drawState->addColorTextureEffect(src, sampleM); |
| 1606 |
| 1601 SkRect dstR = SkRect::MakeWH(SkIntToScalar(srcRect.width()), SkIntToScalar(s
rcRect.height())); | 1607 SkRect dstR = SkRect::MakeWH(SkIntToScalar(srcRect.width()), SkIntToScalar(s
rcRect.height())); |
| 1602 fGpu->drawSimpleRect(dstR); | 1608 target->drawSimpleRect(dstR); |
| 1603 } | 1609 } |
| 1604 | 1610 |
| 1605 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, | 1611 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, |
| 1606 int left, int top, int width, int height
, | 1612 int left, int top, int width, int height
, |
| 1607 GrPixelConfig srcConfig, | 1613 GrPixelConfig srcConfig, |
| 1608 const void* buffer, | 1614 const void* buffer, |
| 1609 size_t rowBytes, | 1615 size_t rowBytes, |
| 1610 uint32_t flags) { | 1616 uint32_t flags) { |
| 1611 ASSERT_OWNED_RESOURCE(target); | 1617 ASSERT_OWNED_RESOURCE(target); |
| 1612 | 1618 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 fResourceCache->printStats(); | 1952 fResourceCache->printStats(); |
| 1947 } | 1953 } |
| 1948 #endif | 1954 #endif |
| 1949 | 1955 |
| 1950 #if GR_GPU_STATS | 1956 #if GR_GPU_STATS |
| 1951 const GrContext::GPUStats* GrContext::gpuStats() const { | 1957 const GrContext::GPUStats* GrContext::gpuStats() const { |
| 1952 return fGpu->gpuStats(); | 1958 return fGpu->gpuStats(); |
| 1953 } | 1959 } |
| 1954 #endif | 1960 #endif |
| 1955 | 1961 |
| OLD | NEW |