blob: 1cf3d20c8be187933e514129db48ecc72a5abeba [file] [log] [blame]
Romain Guye2d345e2010-09-24 18:39:22 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "OpenGLRenderer"
18
19#include <utils/StopWatch.h>
20
21#include "OpenGLDebugRenderer.h"
22
23namespace android {
24namespace uirenderer {
25
Romain Guy6b7bd242010-10-06 19:49:23 -070026void OpenGLDebugRenderer::prepare(bool opaque) {
Romain Guye2d345e2010-09-24 18:39:22 -070027 mPrimitivesCount = 0;
28 LOGD("========= Frame start =========");
Romain Guy6b7bd242010-10-06 19:49:23 -070029 OpenGLRenderer::prepare(opaque);
Romain Guye2d345e2010-09-24 18:39:22 -070030}
31
32void OpenGLDebugRenderer::finish() {
33 LOGD("========= Frame end =========");
34 LOGD("Primitives draw count = %d", mPrimitivesCount);
35 OpenGLRenderer::finish();
36}
37
38void OpenGLDebugRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
39 mPrimitivesCount++;
40 StopWatch w("composeLayer");
41 return OpenGLRenderer::composeLayer(current, previous);
42}
43
44int OpenGLDebugRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -070045 SkPaint* p, int flags) {
Romain Guye2d345e2010-09-24 18:39:22 -070046 mPrimitivesCount++;
47 StopWatch w("saveLayer");
48 return OpenGLRenderer::saveLayer(left, top, right, bottom, p, flags);
49}
50
Romain Guy0fe478e2010-11-08 12:08:41 -080051void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList) {
52 mPrimitivesCount++;
53 StopWatch w("drawDisplayList");
54 OpenGLRenderer::drawDisplayList(displayList);
55}
56
Romain Guye2d345e2010-09-24 18:39:22 -070057void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float left, float top,
Chet Haase5c13d892010-10-08 08:37:55 -070058 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070059 mPrimitivesCount++;
60 StopWatch w("drawBitmap");
61 OpenGLRenderer::drawBitmap(bitmap, left, top, paint);
62}
63
Chet Haase5c13d892010-10-08 08:37:55 -070064void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix,
65 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070066 mPrimitivesCount++;
67 StopWatch w("drawBitmapMatrix");
68 OpenGLRenderer::drawBitmap(bitmap, matrix, paint);
69}
70
71void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
72 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -070073 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070074 mPrimitivesCount++;
75 StopWatch w("drawBitmapRect");
76 OpenGLRenderer::drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
77 dstLeft, dstTop, dstRight, dstBottom, paint);
78}
79
Romain Guy4aa90572010-09-26 18:40:37 -070080void OpenGLDebugRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
Romain Guy4bb94202010-10-12 15:59:26 -070081 const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
Chet Haase5c13d892010-10-08 08:37:55 -070082 float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070083 mPrimitivesCount++;
84 StopWatch w("drawPatch");
Romain Guy4bb94202010-10-12 15:59:26 -070085 OpenGLRenderer::drawPatch(bitmap, xDivs, yDivs, colors, width, height, numColors,
Romain Guy4aa90572010-09-26 18:40:37 -070086 left, top, right, bottom, paint);
Romain Guye2d345e2010-09-24 18:39:22 -070087}
88
89void OpenGLDebugRenderer::drawColor(int color, SkXfermode::Mode mode) {
90 mPrimitivesCount++;
91 StopWatch w("drawColor");
92 OpenGLRenderer::drawColor(color, mode);
93}
94
95void OpenGLDebugRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -070096 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070097 mPrimitivesCount++;
98 StopWatch w("drawRect");
99 OpenGLRenderer::drawRect(left, top, right, bottom, paint);
100}
101
102void OpenGLDebugRenderer::drawPath(SkPath* path, SkPaint* paint) {
103 mPrimitivesCount++;
104 StopWatch w("drawPath");
105 OpenGLRenderer::drawPath(path, paint);
106}
107
Chet Haase5c13d892010-10-08 08:37:55 -0700108void OpenGLDebugRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -0700109 mPrimitivesCount++;
110 StopWatch w("drawLines");
111 OpenGLRenderer::drawLines(points, count, paint);
112}
113
114void OpenGLDebugRenderer::drawText(const char* text, int bytesCount, int count, float x, float y,
115 SkPaint* paint) {
116 mPrimitivesCount++;
117 StopWatch w("drawText");
118 OpenGLRenderer::drawText(text, bytesCount, count, x, y, paint);
119}
120
121}; // namespace uirenderer
122}; // namespace android