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

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

Issue 622663002: GrContext::copyTexture->GrContext::copySurface. Add a flush writes pixel ops flag. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: line wrap 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 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 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp e dstCT, 56 static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp e dstCT,
57 const SkIRect* subset) { 57 const SkIRect* subset) {
58 if (NULL == texture || kUnknown_SkColorType == dstCT) { 58 if (NULL == texture || kUnknown_SkColorType == dstCT) {
59 return NULL; 59 return NULL;
60 } 60 }
61 GrContext* context = texture->getContext(); 61 GrContext* context = texture->getContext();
62 if (NULL == context) { 62 if (NULL == context) {
63 return NULL; 63 return NULL;
64 } 64 }
65 GrTextureDesc desc; 65 GrTextureDesc desc;
66 66
robertphillips 2014/10/02 15:40:41 It would be nice to have a SkIPoint::Zero or Origi
bsalomon 2014/10/02 17:34:06 Done. (Make(0,0) in call site)
67 SkIPoint pointStorage; 67 SkIPoint dstPoint;
68 SkIPoint* topLeft; 68 dstPoint.setZero();
69 if (subset != NULL) { 69 SkIRect srcRect;
70
71 if (!subset) {
72 desc.fWidth = texture->width();
73 desc.fHeight = texture->height();
74 srcRect = SkIRect::MakeWH(texture->width(), texture->height());
75 } else {
70 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(* subset)); 76 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(* subset));
71 // Create a new texture that is the size of subset. 77 // Create a new texture that is the size of subset.
72 desc.fWidth = subset->width(); 78 desc.fWidth = subset->width();
73 desc.fHeight = subset->height(); 79 desc.fHeight = subset->height();
74 pointStorage.set(subset->x(), subset->y()); 80 srcRect = *subset;
75 topLeft = &pointStorage;
76 } else {
77 desc.fWidth = texture->width();
78 desc.fHeight = texture->height();
79 topLeft = NULL;
80 } 81 }
81 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 82 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
82 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType); 83 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType);
83 84
84 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); 85 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
85 if (NULL == dst) { 86 if (NULL == dst) {
86 return NULL; 87 return NULL;
87 } 88 }
88 89
89 context->copyTexture(texture, dst->asRenderTarget(), topLeft);
90
91 // Blink is relying on the above copy being sent to GL immediately in the ca se when the source 90 // Blink is relying on the above copy being sent to GL immediately in the ca se when the source
92 // is a WebGL canvas backing store. We could have a TODO to remove this flus h, but we have a 91 // is a WebGL canvas backing store. We could have a TODO to remove this flus h flag, but we have
93 // larger TODO to remove SkGrPixelRef entirely. 92 // a larger TODO to remove SkGrPixelRef entirely.
94 context->flush(); 93 context->copySurface(texture, dst->asRenderTarget(), srcRect, dstPoint,
95 94 GrContext::kFlushWrites_PixelOp);
95
96 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType); 96 SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPrem ul_SkAlphaType);
97 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst)); 97 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
98 SkSafeUnref(dst); 98 SkSafeUnref(dst);
99 return pixelRef; 99 return pixelRef;
100 } 100 }
101 101
102 /////////////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////////
103 103
104 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, 104 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
105 bool transferCacheLock) : INHERITED(info) { 105 bool transferCacheLock) : INHERITED(info) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 cachedBitmap.setImmutable(); 199 cachedBitmap.setImmutable();
200 //Add to the cache 200 //Add to the cache
201 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); 201 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap);
202 202
203 dst->swap(cachedBitmap); 203 dst->swap(cachedBitmap);
204 } 204 }
205 205
206 return true; 206 return true;
207 207
208 } 208 }
OLDNEW
« src/gpu/GrSurface.cpp ('K') | « src/gpu/GrSurface.cpp ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698