skia2/gm/subsetshader.cpp
Florin Malita ab244f045a Revert "Revert "Reland: Remove SkLights include from SkCanvas.h""
This reverts commit 9d5f66d9c2.

Reason for revert: Leon landed Android fixes.

Original change's description:
> Revert "Reland: Remove SkLights include from SkCanvas.h"
> 
> This reverts commit fed00319c9.
> 
> Reason for revert: breaking the Android roll.
> 
> Original change's description:
> > Reland: Remove SkLights include from SkCanvas.h
> > 
> > SkLights.h pulls in a bunch of other headers and is not needed (fwdecl
> > works fine).
> > 
> > Change-Id: I3ed97cd7861e51dcb7cfa7950a97b420dbc6fbfb
> > TBR=reed@google.com
> > Reviewed-on: https://skia-review.googlesource.com/15143
> > Commit-Queue: Florin Malita <fmalita@chromium.org>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> > 
> 
> TBR=fmalita@chromium.org,reed@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> 
> Change-Id: I3b0e69f1d04d160f16a5567b09982d35cc9ca84e
> Reviewed-on: https://skia-review.googlesource.com/15195
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Florin Malita <fmalita@chromium.org>
> 

TBR=msarett@google.com,reviews@skia.org,fmalita@chromium.org,reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I0a1c2f9df61f16987ab72dfb4f3a205fbcc37667
Reviewed-on: https://skia-review.googlesource.com/15229
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2017-05-03 19:17:11 +00:00

37 lines
1.2 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Resources.h"
#include "SkBitmap.h"
#include "SkShader.h"
#include "gm.h"
DEF_SIMPLE_GM(bitmap_subset_shader, canvas, 256, 256) {
canvas->clear(SK_ColorWHITE);
SkBitmap source;
if (!GetResourceAsBitmap("color_wheel.png", &source)) {
return;
}
SkIRect left = SkIRect::MakeWH(source.width()/2, source.height());
SkIRect right = SkIRect::MakeXYWH(source.width()/2, 0,
source.width()/2, source.height());
SkBitmap leftBitmap, rightBitmap;
source.extractSubset(&leftBitmap, left);
source.extractSubset(&rightBitmap, right);
SkMatrix matrix;
matrix.setScale(0.75f, 0.75f);
matrix.preRotate(30.0f);
SkShader::TileMode tm = SkShader::kRepeat_TileMode;
SkPaint paint;
paint.setShader(SkShader::MakeBitmapShader(leftBitmap, tm, tm, &matrix));
canvas->drawRect(SkRect::MakeWH(256.0f, 128.0f), paint);
paint.setShader(SkShader::MakeBitmapShader(rightBitmap, tm, tm, &matrix));
canvas->drawRect(SkRect::MakeXYWH(0, 128.0f, 256.0f, 128.0f), paint);
}