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/SkGpuDevice.cpp

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Updating to ToT (10994) Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkTestImageFilters.cpp ('k') | src/pdf/SkPDFDevice.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "effects/GrTextureDomainEffect.h" 10 #include "effects/GrTextureDomainEffect.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return NULL; 154 return NULL;
155 } 155 }
156 if (surface->asTexture()) { 156 if (surface->asTexture()) {
157 return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asTextur e())); 157 return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asTextur e()));
158 } else { 158 } else {
159 return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asRender Target())); 159 return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asRender Target()));
160 } 160 }
161 } 161 }
162 162
163 SkGpuDevice::SkGpuDevice(GrContext* context, GrTexture* texture) 163 SkGpuDevice::SkGpuDevice(GrContext* context, GrTexture* texture)
164 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { 164 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
165 this->initFromRenderTarget(context, texture->asRenderTarget(), false); 165 this->initFromRenderTarget(context, texture->asRenderTarget(), false);
166 } 166 }
167 167
168 SkGpuDevice::SkGpuDevice(GrContext* context, GrRenderTarget* renderTarget) 168 SkGpuDevice::SkGpuDevice(GrContext* context, GrRenderTarget* renderTarget)
169 : SkDevice(make_bitmap(context, renderTarget)) { 169 : SkBitmapDevice(make_bitmap(context, renderTarget)) {
170 this->initFromRenderTarget(context, renderTarget, false); 170 this->initFromRenderTarget(context, renderTarget, false);
171 } 171 }
172 172
173 void SkGpuDevice::initFromRenderTarget(GrContext* context, 173 void SkGpuDevice::initFromRenderTarget(GrContext* context,
174 GrRenderTarget* renderTarget, 174 GrRenderTarget* renderTarget,
175 bool cached) { 175 bool cached) {
176 fDrawProcs = NULL; 176 fDrawProcs = NULL;
177 177
178 fContext = context; 178 fContext = context;
179 fContext->ref(); 179 fContext->ref();
(...skipping 16 matching lines...) Expand all
196 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (surface, cached)); 196 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (surface, cached));
197 197
198 this->setPixelRef(pr, 0)->unref(); 198 this->setPixelRef(pr, 0)->unref();
199 } 199 }
200 200
201 SkGpuDevice::SkGpuDevice(GrContext* context, 201 SkGpuDevice::SkGpuDevice(GrContext* context,
202 SkBitmap::Config config, 202 SkBitmap::Config config,
203 int width, 203 int width,
204 int height, 204 int height,
205 int sampleCount) 205 int sampleCount)
206 : SkDevice(config, width, height, false /*isOpaque*/) { 206 : SkBitmapDevice(config, width, height, false /*isOpaque*/) {
207 207
208 fDrawProcs = NULL; 208 fDrawProcs = NULL;
209 209
210 fContext = context; 210 fContext = context;
211 fContext->ref(); 211 fContext->ref();
212 212
213 fRenderTarget = NULL; 213 fRenderTarget = NULL;
214 fNeedClear = false; 214 fNeedClear = false;
215 215
216 if (config != SkBitmap::kRGB_565_Config) { 216 if (config != SkBitmap::kRGB_565_Config) {
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 GrPaint grPaint; 1429 GrPaint grPaint;
1430 grPaint.addColorEffect(effect); 1430 grPaint.addColorEffect(effect);
1431 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config()); 1431 bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config());
1432 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) { 1432 if (!skPaint2GrPaintNoShader(this, paint, alphaOnly, false, &grPaint)) {
1433 return; 1433 return;
1434 } 1434 }
1435 1435
1436 fContext->drawRectToRect(grPaint, dstRect, paintRect, &m); 1436 fContext->drawRectToRect(grPaint, dstRect, paintRect, &m);
1437 } 1437 }
1438 1438
1439 static bool filter_texture(SkDevice* device, GrContext* context, 1439 static bool filter_texture(SkBaseDevice* device, GrContext* context,
1440 GrTexture* texture, SkImageFilter* filter, 1440 GrTexture* texture, SkImageFilter* filter,
1441 int w, int h, const SkMatrix& ctm, SkBitmap* result, 1441 int w, int h, const SkMatrix& ctm, SkBitmap* result,
1442 SkIPoint* offset) { 1442 SkIPoint* offset) {
1443 SkASSERT(filter); 1443 SkASSERT(filter);
1444 SkDeviceImageFilterProxy proxy(device); 1444 SkDeviceImageFilterProxy proxy(device);
1445 1445
1446 if (filter->canFilterImageGPU()) { 1446 if (filter->canFilterImageGPU()) {
1447 // Save the render target and set it to NULL, so we don't accidentally d raw to it in the 1447 // Save the render target and set it to NULL, so we don't accidentally d raw to it in the
1448 // filter. Also set the clip wide open and the matrix to identity. 1448 // filter. Also set the clip wide open and the matrix to identity.
1449 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); 1449 GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 if (!bitmapBounds.contains(tmpSrc)) { 1530 if (!bitmapBounds.contains(tmpSrc)) {
1531 if (!tmpSrc.intersect(bitmapBounds)) { 1531 if (!tmpSrc.intersect(bitmapBounds)) {
1532 return; // nothing to draw 1532 return; // nothing to draw
1533 } 1533 }
1534 } 1534 }
1535 } 1535 }
1536 1536
1537 this->drawBitmapCommon(draw, bitmap, &tmpSrc, matrix, paint, flags); 1537 this->drawBitmapCommon(draw, bitmap, &tmpSrc, matrix, paint, flags);
1538 } 1538 }
1539 1539
1540 void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device, 1540 void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
1541 int x, int y, const SkPaint& paint) { 1541 int x, int y, const SkPaint& paint) {
1542 // clear of the source device must occur before CHECK_SHOULD_DRAW 1542 // clear of the source device must occur before CHECK_SHOULD_DRAW
1543 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); 1543 SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
1544 if (dev->fNeedClear) { 1544 if (dev->fNeedClear) {
1545 // TODO: could check here whether we really need to draw at all 1545 // TODO: could check here whether we really need to draw at all
1546 dev->clear(0x0); 1546 dev->clear(0x0);
1547 } 1547 }
1548 1548
1549 // drawDevice is defined to be in device coords. 1549 // drawDevice is defined to be in device coords.
1550 CHECK_SHOULD_DRAW(draw, true); 1550 CHECK_SHOULD_DRAW(draw, true);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 return false; 1815 return false;
1816 } 1816 }
1817 1817
1818 void SkGpuDevice::flush() { 1818 void SkGpuDevice::flush() {
1819 DO_DEFERRED_CLEAR(); 1819 DO_DEFERRED_CLEAR();
1820 fContext->resolveRenderTarget(fRenderTarget); 1820 fContext->resolveRenderTarget(fRenderTarget);
1821 } 1821 }
1822 1822
1823 /////////////////////////////////////////////////////////////////////////////// 1823 ///////////////////////////////////////////////////////////////////////////////
1824 1824
1825 SkDevice* SkGpuDevice::onCreateCompatibleDevice(SkBitmap::Config config, 1825 SkBaseDevice* SkGpuDevice::onCreateCompatibleDevice(SkBitmap::Config config,
1826 int width, int height, 1826 int width, int height,
1827 bool isOpaque, 1827 bool isOpaque,
1828 Usage usage) { 1828 Usage usage) {
1829 GrTextureDesc desc; 1829 GrTextureDesc desc;
1830 desc.fConfig = fRenderTarget->config(); 1830 desc.fConfig = fRenderTarget->config();
1831 desc.fFlags = kRenderTarget_GrTextureFlagBit; 1831 desc.fFlags = kRenderTarget_GrTextureFlagBit;
1832 desc.fWidth = width; 1832 desc.fWidth = width;
1833 desc.fHeight = height; 1833 desc.fHeight = height;
1834 desc.fSampleCnt = fRenderTarget->numSamples(); 1834 desc.fSampleCnt = fRenderTarget->numSamples();
1835 1835
1836 SkAutoTUnref<GrTexture> texture; 1836 SkAutoTUnref<GrTexture> texture;
1837 // Skia's convention is to only clear a device if it is non-opaque. 1837 // Skia's convention is to only clear a device if it is non-opaque.
1838 bool needClear = !isOpaque; 1838 bool needClear = !isOpaque;
(...skipping 12 matching lines...) Expand all
1851 return SkNEW_ARGS(SkGpuDevice,(fContext, texture, needClear)); 1851 return SkNEW_ARGS(SkGpuDevice,(fContext, texture, needClear));
1852 } else { 1852 } else {
1853 GrPrintf("---- failed to create compatible device texture [%d %d]\n", wi dth, height); 1853 GrPrintf("---- failed to create compatible device texture [%d %d]\n", wi dth, height);
1854 return NULL; 1854 return NULL;
1855 } 1855 }
1856 } 1856 }
1857 1857
1858 SkGpuDevice::SkGpuDevice(GrContext* context, 1858 SkGpuDevice::SkGpuDevice(GrContext* context,
1859 GrTexture* texture, 1859 GrTexture* texture,
1860 bool needClear) 1860 bool needClear)
1861 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { 1861 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1862 1862
1863 SkASSERT(texture && texture->asRenderTarget()); 1863 SkASSERT(texture && texture->asRenderTarget());
1864 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1864 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1865 // cache. We pass true for the third argument so that it will get unlocked. 1865 // cache. We pass true for the third argument so that it will get unlocked.
1866 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1866 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1867 fNeedClear = needClear; 1867 fNeedClear = needClear;
1868 } 1868 }
OLDNEW
« no previous file with comments | « src/effects/SkTestImageFilters.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698