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

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

Issue 608353002: Cherry-pick of https://skia.googlesource.com/skia.git/+/96c118edff293af93db0a2b1b6775428117924b1 to… (Closed) Base URL: https://skia.googlesource.com/skia.git@m38_2125
Patch Set: Created 6 years, 2 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/SkGrPixelRef.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 /* 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 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 } 1549 }
1550 target->discard(renderTarget); 1550 target->discard(renderTarget);
1551 } 1551 }
1552 1552
1553 void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLeft) { 1553 void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint* topLeft) {
1554 if (NULL == src || NULL == dst) { 1554 if (NULL == src || NULL == dst) {
1555 return; 1555 return;
1556 } 1556 }
1557 ASSERT_OWNED_RESOURCE(src); 1557 ASSERT_OWNED_RESOURCE(src);
1558 1558
1559 // Writes pending to the source texture are not tracked, so a flush
1560 // is required to ensure that the copy captures the most recent contents
1561 // of the source texture. See similar behavior in
1562 // GrContext::resolveRenderTarget.
1563 this->flush();
1564
1565 GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
1566 GrDrawState* drawState = fGpu->drawState();
1567 drawState->setRenderTarget(dst);
1568 SkMatrix sampleM;
1569 sampleM.setIDiv(src->width(), src->height());
1570 SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height()); 1559 SkIRect srcRect = SkIRect::MakeWH(dst->width(), dst->height());
1571 if (NULL != topLeft) { 1560 if (NULL != topLeft) {
1572 srcRect.offset(*topLeft); 1561 srcRect.offset(*topLeft);
1573 } 1562 }
1574 SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height()); 1563 SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height());
1575 if (!srcRect.intersect(srcBounds)) { 1564 if (!srcRect.intersect(srcBounds)) {
1576 return; 1565 return;
1577 } 1566 }
1578 sampleM.preTranslate(SkIntToScalar(srcRect.fLeft), SkIntToScalar(srcRect.fTo p)); 1567
1579 drawState->addColorTextureEffect(src, sampleM); 1568 GrDrawTarget* target = this->prepareToDraw(NULL, BUFFERED_DRAW, NULL, NULL);
1580 SkRect dstR = SkRect::MakeWH(SkIntToScalar(srcRect.width()), SkIntToScalar(s rcRect.height())); 1569 if (NULL == target) {
1581 fGpu->drawSimpleRect(dstR); 1570 return;
1571 }
1572 SkIPoint dstPoint;
1573 dstPoint.setZero();
1574 target->copySurface(dst, src, srcRect, dstPoint);
1582 } 1575 }
1583 1576
1584 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target, 1577 bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
1585 int left, int top, int width, int height , 1578 int left, int top, int width, int height ,
1586 GrPixelConfig srcConfig, 1579 GrPixelConfig srcConfig,
1587 const void* buffer, 1580 const void* buffer,
1588 size_t rowBytes, 1581 size_t rowBytes,
1589 uint32_t flags) { 1582 uint32_t flags) {
1590 ASSERT_OWNED_RESOURCE(target); 1583 ASSERT_OWNED_RESOURCE(target);
1591 1584
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 fDrawBuffer->removeGpuTraceMarker(marker); 1924 fDrawBuffer->removeGpuTraceMarker(marker);
1932 } 1925 }
1933 } 1926 }
1934 1927
1935 /////////////////////////////////////////////////////////////////////////////// 1928 ///////////////////////////////////////////////////////////////////////////////
1936 #if GR_CACHE_STATS 1929 #if GR_CACHE_STATS
1937 void GrContext::printCacheStats() const { 1930 void GrContext::printCacheStats() const {
1938 fResourceCache->printStats(); 1931 fResourceCache->printStats();
1939 } 1932 }
1940 #endif 1933 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698