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

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

Issue 65133003: [GPU] Use view matrix + rect to implement subrect for drawBitmap when there is a mask filter and ble (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: cleanup 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 | « gm/bleed.cpp ('k') | no next file » | 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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 } else { 1109 } else {
1110 srcRect = *srcRectPtr; 1110 srcRect = *srcRectPtr;
1111 } 1111 }
1112 1112
1113 if (paint.getMaskFilter()){ 1113 if (paint.getMaskFilter()){
1114 // Convert the bitmap to a shader so that the rect can be drawn 1114 // Convert the bitmap to a shader so that the rect can be drawn
1115 // through drawRect, which supports mask filters. 1115 // through drawRect, which supports mask filters.
1116 SkMatrix newM(m); 1116 SkMatrix newM(m);
1117 SkBitmap tmp; // subset of bitmap, if necessary 1117 SkBitmap tmp; // subset of bitmap, if necessary
1118 const SkBitmap* bitmapPtr = &bitmap; 1118 const SkBitmap* bitmapPtr = &bitmap;
1119 SkMatrix localM;
1120 localM.reset();
reed1 2013/11/22 16:23:29 Where is localM referenced after it is set?
bsalomon 2013/11/22 16:36:56 woah, you're right. I picked up this change after
1119 if (NULL != srcRectPtr) { 1121 if (NULL != srcRectPtr) {
1120 SkIRect iSrc; 1122 if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) {
1121 srcRect.roundOut(&iSrc); 1123 // In bleed mode we simply want to position the bitmap based on the src rect
1124 localM.setTranslate(srcRect.fLeft, srcRect.fTop);
1125 } else {
1126 SkIRect iSrc;
1127 srcRect.roundOut(&iSrc);
1122 1128
1123 SkPoint offset = SkPoint::Make(SkIntToScalar(iSrc.fLeft), 1129 SkPoint offset = SkPoint::Make(SkIntToScalar(iSrc.fLeft),
1124 SkIntToScalar(iSrc.fTop)); 1130 SkIntToScalar(iSrc.fTop));
1125 1131
1126 if (SkCanvas::kBleed_DrawBitmapRectFlag & flags) { 1132 if (!bitmap.extractSubset(&tmp, iSrc)) {
1127 // In bleed mode we want to expand the src rect on all sides 1133 return; // extraction failed
1128 // but stay within the bitmap bounds 1134 }
1129 SkIRect iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.heig ht()); 1135 bitmapPtr = &tmp;
1130 clamped_unit_outset_with_offset(&iSrc, &offset, iClampRect); 1136 srcRect.offset(-offset.fX, -offset.fY);
1137 // The source rect has changed so update the matrix
1138 newM.preTranslate(offset.fX, offset.fY);
1131 } 1139 }
1132
1133 if (!bitmap.extractSubset(&tmp, iSrc)) {
1134 return; // extraction failed
1135 }
1136 bitmapPtr = &tmp;
1137 srcRect.offset(-offset.fX, -offset.fY);
1138 // The source rect has changed so update the matrix
1139 newM.preTranslate(offset.fX, offset.fY);
1140 } 1140 }
1141 1141
1142 SkPaint paintWithTexture(paint); 1142 SkPaint paintWithTexture(paint);
1143 paintWithTexture.setShader(SkShader::CreateBitmapShader(*bitmapPtr, 1143 paintWithTexture.setShader(SkShader::CreateBitmapShader(*bitmapPtr,
1144 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref(); 1144 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref();
1145 1145
1146 // Transform 'newM' needs to be concatenated to the current matrix, 1146 // Transform 'newM' needs to be concatenated to the current matrix,
1147 // rather than transforming the primitive directly, so that 'newM' will 1147 // rather than transforming the primitive directly, so that 'newM' will
1148 // also affect the behavior of the mask filter. 1148 // also affect the behavior of the mask filter.
1149 SkMatrix drawMatrix; 1149 SkMatrix drawMatrix;
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 GrTexture* texture, 1860 GrTexture* texture,
1861 bool needClear) 1861 bool needClear)
1862 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1862 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1863 1863
1864 SkASSERT(texture && texture->asRenderTarget()); 1864 SkASSERT(texture && texture->asRenderTarget());
1865 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture 1865 // This constructor is called from onCreateCompatibleDevice. It has locked t he RT in the texture
1866 // cache. We pass true for the third argument so that it will get unlocked. 1866 // cache. We pass true for the third argument so that it will get unlocked.
1867 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1867 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1868 fNeedClear = needClear; 1868 fNeedClear = needClear;
1869 } 1869 }
OLDNEW
« no previous file with comments | « gm/bleed.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698