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

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

Issue 589143004: Use draw buffer for texture copy impl. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment, turn off clip bit Created 6 years, 3 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 | no next file » | 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 /* 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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698