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

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

Issue 621073002: Revert of GrContext::copyTexture->GrContext::copySurface. Add a flush writes pixel ops flag. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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 | « src/gpu/GrSurface.cpp ('k') | src/image/SkSurface_Gpu.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 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
67 SkIRect srcRect; 67 SkIPoint pointStorage;
68 68 SkIPoint* topLeft;
69 if (!subset) { 69 if (subset != NULL) {
70 desc.fWidth = texture->width();
71 desc.fHeight = texture->height();
72 srcRect = SkIRect::MakeWH(texture->width(), texture->height());
73 } else {
74 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(* subset)); 70 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(* subset));
75 // Create a new texture that is the size of subset. 71 // Create a new texture that is the size of subset.
76 desc.fWidth = subset->width(); 72 desc.fWidth = subset->width();
77 desc.fHeight = subset->height(); 73 desc.fHeight = subset->height();
78 srcRect = *subset; 74 pointStorage.set(subset->x(), subset->y());
75 topLeft = &pointStorage;
76 } else {
77 desc.fWidth = texture->width();
78 desc.fHeight = texture->height();
79 topLeft = NULL;
79 } 80 }
80 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 81 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
81 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType); 82 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType);
82 83
83 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); 84 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
84 if (NULL == dst) { 85 if (NULL == dst) {
85 return NULL; 86 return NULL;
86 } 87 }
87 88
89 context->copyTexture(texture, dst->asRenderTarget(), topLeft);
90
88 // Blink is relying on the above copy being sent to GL immediately in the ca se when the source 91 // Blink is relying on the above copy being sent to GL immediately in the ca se when the source
89 // is a WebGL canvas backing store. We could have a TODO to remove this flus h flag, but we have 92 // is a WebGL canvas backing store. We could have a TODO to remove this flus h, but we have a
90 // a larger TODO to remove SkGrPixelRef entirely. 93 // larger TODO to remove SkGrPixelRef entirely.
91 context->copySurface(texture, dst->asRenderTarget(), srcRect, SkIPoint::Make (0,0), 94 context->flush();
92 GrContext::kFlushWrites_PixelOp); 95
93
94 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);
95 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst)); 97 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
96 SkSafeUnref(dst); 98 SkSafeUnref(dst);
97 return pixelRef; 99 return pixelRef;
98 } 100 }
99 101
100 /////////////////////////////////////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////////
101 103
102 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, 104 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
103 bool transferCacheLock) : INHERITED(info) { 105 bool transferCacheLock) : INHERITED(info) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 cachedBitmap.setImmutable(); 199 cachedBitmap.setImmutable();
198 //Add to the cache 200 //Add to the cache
199 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap); 201 SkBitmapCache::Add(this->getGenerationID(), bounds, cachedBitmap);
200 202
201 dst->swap(cachedBitmap); 203 dst->swap(cachedBitmap);
202 } 204 }
203 205
204 return true; 206 return true;
205 207
206 } 208 }
OLDNEW
« no previous file with comments | « 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