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

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

Issue 100723005: Update all callsites to use info for pixelrefs (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/image/SkDataPixelRef.h » ('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
11 #include "SkGrPixelRef.h" 11 #include "SkGrPixelRef.h"
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrTexture.h" 13 #include "GrTexture.h"
14 #include "SkGr.h" 14 #include "SkGr.h"
15 #include "SkRect.h" 15 #include "SkRect.h"
16 16
17 // since we call lockPixels recursively on fBitmap, we need a distinct mutex, 17 // since we call lockPixels recursively on fBitmap, we need a distinct mutex,
18 // to avoid deadlock with the default one provided by SkPixelRef. 18 // to avoid deadlock with the default one provided by SkPixelRef.
19 SK_DECLARE_STATIC_MUTEX(gROLockPixelsPixelRefMutex); 19 SK_DECLARE_STATIC_MUTEX(gROLockPixelsPixelRefMutex);
20 20
21 SkROLockPixelsPixelRef::SkROLockPixelsPixelRef() : INHERITED(&gROLockPixelsPixel RefMutex) { 21 SkROLockPixelsPixelRef::SkROLockPixelsPixelRef(const SkImageInfo& info)
22 } 22 : INHERITED(info, &gROLockPixelsPixelRefMutex) {}
23 23
24 SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() { 24 SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() {}
25 }
26 25
27 void* SkROLockPixelsPixelRef::onLockPixels(SkColorTable** ctable) { 26 void* SkROLockPixelsPixelRef::onLockPixels(SkColorTable** ctable) {
28 if (ctable) { 27 if (ctable) {
29 *ctable = NULL; 28 *ctable = NULL;
30 } 29 }
31 fBitmap.reset(); 30 fBitmap.reset();
32 // SkDebugf("---------- calling readpixels in support of lockpixels\n"); 31 // SkDebugf("---------- calling readpixels in support of lockpixels\n");
33 if (!this->onReadPixels(&fBitmap, NULL)) { 32 if (!this->onReadPixels(&fBitmap, NULL)) {
34 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n"); 33 SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n");
35 return NULL; 34 return NULL;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 pointStorage.set(subset->x(), subset->y()); 68 pointStorage.set(subset->x(), subset->y());
70 topLeft = &pointStorage; 69 topLeft = &pointStorage;
71 } else { 70 } else {
72 desc.fWidth = texture->width(); 71 desc.fWidth = texture->width();
73 desc.fHeight = texture->height(); 72 desc.fHeight = texture->height();
74 topLeft = NULL; 73 topLeft = NULL;
75 } 74 }
76 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 75 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
77 desc.fConfig = SkBitmapConfig2GrPixelConfig(dstConfig); 76 desc.fConfig = SkBitmapConfig2GrPixelConfig(dstConfig);
78 77
78 SkImageInfo info;
79 if (!GrPixelConfig2ColorType(desc.fConfig, &info.fColorType)) {
80 return NULL;
81 }
82 info.fWidth = desc.fWidth;
83 info.fHeight = desc.fHeight;
84 info.fAlphaType = kPremul_SkAlphaType;
85
79 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0); 86 GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
80 if (NULL == dst) { 87 if (NULL == dst) {
81 return NULL; 88 return NULL;
82 } 89 }
83 90
84 context->copyTexture(texture, dst->asRenderTarget(), topLeft); 91 context->copyTexture(texture, dst->asRenderTarget(), topLeft);
85 92
86 // TODO: figure out if this is responsible for Chrome canvas errors 93 // TODO: figure out if this is responsible for Chrome canvas errors
87 #if 0 94 #if 0
88 // The render texture we have created (to perform the copy) isn't fully 95 // The render texture we have created (to perform the copy) isn't fully
89 // functional (since it doesn't have a stencil buffer). Release it here 96 // functional (since it doesn't have a stencil buffer). Release it here
90 // so the caller doesn't try to render to it. 97 // so the caller doesn't try to render to it.
91 // TODO: we can undo this release when dynamic stencil buffer attach/ 98 // TODO: we can undo this release when dynamic stencil buffer attach/
92 // detach has been implemented 99 // detach has been implemented
93 dst->releaseRenderTarget(); 100 dst->releaseRenderTarget();
94 #endif 101 #endif
95 102
96 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (dst)); 103 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
97 SkSafeUnref(dst); 104 SkSafeUnref(dst);
98 return pixelRef; 105 return pixelRef;
99 } 106 }
100 107
101 /////////////////////////////////////////////////////////////////////////////// 108 ///////////////////////////////////////////////////////////////////////////////
102 109
103 SkGrPixelRef::SkGrPixelRef(GrSurface* surface, bool transferCacheLock) { 110 SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface,
111 bool transferCacheLock) : INHERITED(info) {
104 // TODO: figure out if this is responsible for Chrome canvas errors 112 // TODO: figure out if this is responsible for Chrome canvas errors
105 #if 0 113 #if 0
106 // The GrTexture has a ref to the GrRenderTarget but not vice versa. 114 // The GrTexture has a ref to the GrRenderTarget but not vice versa.
107 // If the GrTexture exists take a ref to that (rather than the render
108 // target)
109 fSurface = surface->asTexture();
110 #else
111 fSurface = NULL;
112 #endif
113 if (NULL == fSurface) {
114 fSurface = surface;
115 }
116 fUnlock = transferCacheLock;
117 SkSafeRef(surface);
118 }
119
120 SkGrPixelRef::SkGrPixelRef(const SkImageInfo&, GrSurface* surface, bool transfer CacheLock) {
121 // TODO: figure out if this is responsible for Chrome canvas errors
122 #if 0
123 // The GrTexture has a ref to the GrRenderTarget but not vice versa.
124 // If the GrTexture exists take a ref to that (rather than the render 115 // If the GrTexture exists take a ref to that (rather than the render
125 // target) 116 // target)
126 fSurface = surface->asTexture(); 117 fSurface = surface->asTexture();
127 #else 118 #else
128 fSurface = NULL; 119 fSurface = NULL;
129 #endif 120 #endif
130 if (NULL == fSurface) { 121 if (NULL == fSurface) {
131 fSurface = surface; 122 fSurface = surface;
132 } 123 }
133 fUnlock = transferCacheLock; 124 fUnlock = transferCacheLock;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (!dst->allocPixels()) { 178 if (!dst->allocPixels()) {
188 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n"); 179 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\ n");
189 return false; 180 return false;
190 } 181 }
191 SkAutoLockPixels al(*dst); 182 SkAutoLockPixels al(*dst);
192 void* buffer = dst->getPixels(); 183 void* buffer = dst->getPixels();
193 return fSurface->readPixels(left, top, width, height, 184 return fSurface->readPixels(left, top, width, height,
194 kSkia8888_GrPixelConfig, 185 kSkia8888_GrPixelConfig,
195 buffer, dst->rowBytes()); 186 buffer, dst->rowBytes());
196 } 187 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/image/SkDataPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698